]> git.ipfire.org Git - thirdparty/git.git/commitdiff
wt-status: consistently quote paths in "status --short" output
authorJunio C Hamano <gitster@pobox.com>
Thu, 10 Sep 2020 17:01:57 +0000 (10:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Sep 2020 20:07:24 +0000 (13:07 -0700)
Tracked paths with SP in them were cquoted in "git status --short"
output, but untracked, ignored, and unmerged paths weren't.

The test was stolen from a patch to fix output for the 'untracked'
paths by brian m. carlson, with similar tests added for 'ignored'
ones.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7508-status.sh
wt-status.c

index e81759319f57b96c1b03afb51dcb93d620f13482..2e9c6daf1a90e2f62be8ebbe4544c3c6087fc3b6 100755 (executable)
@@ -814,6 +814,33 @@ test_expect_success 'status -s without relative paths' '
 
 '
 
+cat >expect <<\EOF
+ M dir1/modified
+A  dir2/added
+A  "file with spaces"
+?? dir1/untracked
+?? dir2/modified
+?? dir2/untracked
+?? "file with spaces 2"
+?? untracked
+EOF
+
+test_expect_success 'status -s without relative paths' '
+       test_when_finished "git rm --cached \"file with spaces\"; rm -f file*" &&
+       >"file with spaces" &&
+       >"file with spaces 2" &&
+       >"expect with spaces" &&
+       git add "file with spaces" &&
+
+       git status -s >output &&
+       test_cmp expect output &&
+
+       git status -s --ignored >output &&
+       grep "^!! \"expect with spaces\"$" output &&
+       grep -v "^!! " output >output-wo-ignored &&
+       test_cmp expect output-wo-ignored
+'
+
 test_expect_success 'dry-run of partial commit excluding new file in index' '
        cat >expect <<EOF &&
 On branch master
index adbf6958bd75eda3aee4e735841ce86df432b2b6..7139623025d232cae5137a5104d4b3a746928425 100644 (file)
@@ -1848,7 +1848,7 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
        } else {
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
-               one = quote_path(it->string, s->prefix, &onebuf, 0);
+               one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
                printf(" %s\n", one);
                strbuf_release(&onebuf);
        }
@@ -1896,7 +1896,7 @@ static void wt_shortstatus_other(struct string_list_item *it,
        } else {
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
-               one = quote_path(it->string, s->prefix, &onebuf, 0);
+               one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
                color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
                printf(" %s\n", one);
                strbuf_release(&onebuf);