@matheusbsbs / matheus-bagliano / commits / a361dd3f79
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Sep 10, 2020 at 10:01 UTC a361dd3f798968b3be4bd10d0f4133dc1f48e50b
2 files changed +29 -2
t/t7508-status.sh
+27
@@ -814,6 +814,33 @@ test_expect_success 'status -s without relative paths' '
814
815 '
816
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 +
844 test_expect_success 'dry-run of partial commit excluding new file in index' '
845 cat >expect <<EOF &&
846 On branch master
wt-status.c
+2 -2
@@ -1848,7 +1848,7 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
1848 } else {
1849 struct strbuf onebuf = STRBUF_INIT;
1850 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);
1852 printf(" %s\n", one);
1853 strbuf_release(&onebuf);
1854 }
@@ -1896,7 +1896,7 @@ static void wt_shortstatus_other(struct string_list_item *it,
1896 } else {
1897 struct strbuf onebuf = STRBUF_INIT;
1898 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);
1900 color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
1901 printf(" %s\n", one);
1902 strbuf_release(&onebuf);