Skip to content

Commit fab92fd

Browse files
gitsterGit for Windows Build Agent
authored andcommitted
wt-status: consistently quote paths in "status --short" output
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 <[email protected]>
1 parent 67b5842 commit fab92fd

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

t/t7508-status.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,33 @@ test_expect_success 'status -s without relative paths' '
814814
815815
'
816816

817+
cat >expect <<\EOF
818+
M dir1/modified
819+
A dir2/added
820+
A "file with spaces"
821+
?? dir1/untracked
822+
?? dir2/modified
823+
?? dir2/untracked
824+
?? "file with spaces 2"
825+
?? untracked
826+
EOF
827+
828+
test_expect_success 'status -s without relative paths' '
829+
test_when_finished "git rm --cached \"file with spaces\"; rm -f file*" &&
830+
>"file with spaces" &&
831+
>"file with spaces 2" &&
832+
>"expect with spaces" &&
833+
git add "file with spaces" &&
834+
835+
git status -s >output &&
836+
test_cmp expect output &&
837+
838+
git status -s --ignored >output &&
839+
grep "^!! \"expect with spaces\"$" output &&
840+
grep -v "^!! " output >output-wo-ignored &&
841+
test_cmp expect output-wo-ignored
842+
'
843+
817844
test_expect_success 'dry-run of partial commit excluding new file in index' '
818845
cat >expect <<EOF &&
819846
On branch master

wt-status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
18531853
} else {
18541854
struct strbuf onebuf = STRBUF_INIT;
18551855
const char *one;
1856-
one = quote_path(it->string, s->prefix, &onebuf, 0);
1856+
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
18571857
printf(" %s\n", one);
18581858
strbuf_release(&onebuf);
18591859
}
@@ -1901,7 +1901,7 @@ static void wt_shortstatus_other(struct string_list_item *it,
19011901
} else {
19021902
struct strbuf onebuf = STRBUF_INIT;
19031903
const char *one;
1904-
one = quote_path(it->string, s->prefix, &onebuf, 0);
1904+
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
19051905
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
19061906
printf(" %s\n", one);
19071907
strbuf_release(&onebuf);

0 commit comments

Comments
 (0)