Skip to content

Commit a361dd3

Browse files
committed
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 e2773aa commit a361dd3

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
@@ -1848,7 +1848,7 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
18481848
} else {
18491849
struct strbuf onebuf = STRBUF_INIT;
18501850
const char *one;
1851-
one = quote_path(it->string, s->prefix, &onebuf, 0);
1851+
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
18521852
printf(" %s\n", one);
18531853
strbuf_release(&onebuf);
18541854
}
@@ -1896,7 +1896,7 @@ static void wt_shortstatus_other(struct string_list_item *it,
18961896
} else {
18971897
struct strbuf onebuf = STRBUF_INIT;
18981898
const char *one;
1899-
one = quote_path(it->string, s->prefix, &onebuf, 0);
1899+
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
19001900
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
19011901
printf(" %s\n", one);
19021902
strbuf_release(&onebuf);

0 commit comments

Comments
 (0)