The comment did not make a good case why it makes sense. It does so now. Pointed out by Junio Hamano. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- dir.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/dir.c b/dir.c index b3329f4..791c566 100644 --- a/dir.c +++ b/dir.c @@ -646,7 +646,16 @@ file_exists(const char *f) /* * get_relative_cwd() gets the prefix of the current working directory * relative to 'dir'. If we are not inside 'dir', it returns NULL. - * As a convenience, it also returns NULL if 'dir' is already NULL. + * + * As a convenience, it also returns NULL if 'dir' is already NULL. The + * reason for this behaviour is that it is natural for functions returning + * directory names to return NULL to say "this directory does not exist" + * or "this directory is invalid". These cases are usually handled the + * same as if the cwd is not inside 'dir' at all, so get_relative_cwd() + * returns NULL for both of them. + * + * Most notably, get_relative_cwd(buffer, size, get_git_work_tree()) + * unifies the handling of "outside work tree" with "no work tree at all". */ char *get_relative_cwd(char *buffer, int size, const char *dir) { -- 1.5.3.rc3.112.gf60b6 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html