wt-status.c:quote_path(): convert empty path to "./"
authorJeff King <peff@peff.net>
Fri, 7 Dec 2007 16:57:04 +0000 (11:57 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sat, 8 Dec 2007 11:33:24 +0000 (03:33 -0800)
Now that we are correctly removing leading prefixes from files in git
status, there is a degenerate case: the directory matching the prefix.
Because we show only the directory name for a directory that contains
only untracked files, it gets collapsed to an empty string.

Example:

$ git init
$ mkdir subdir
$ touch subdir/file
$ git status
...
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# subdir/

So far, so good.

$ cd subdir
$ git status
....
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
#

Oops, that's a bit confusing.

This patch prints './' to show that there is some output.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c
index 02dbb751db86b1c10a018cfb234f267e22d73894..05414bb9e9dd064f65ff21ae2c6c53f996a6bd21 100644 (file)
@@ -121,6 +121,9 @@ static char *quote_path(const char *in, int len,
                }
        }
 
+       if (!out->len)
+               strbuf_addstr(out, "./");
+
        return out->buf;
 }