Skip to content

Commit dbfdc62

Browse files
lilyballgitster
authored andcommitted
status: Quote paths with spaces in short format
According to the documentation for git-status, in short-format mode, paths with spaces or unprintable characters are quoted. However 28fba29 (Do not quote SP., 2005-10-17) removed the behavior that quotes paths that have spaces but not unprintable characters. Unfortunately this makes the output of `git status --porcelain` non-parseable in certain (rather unusual) edge cases. In the interest of removing ambiguity when parsing the output of `git status --porcelain`, restore the behavior of quoting paths with spaces in git-status's short-format mode. Signed-off-by: Kevin Ballard <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af77aee commit dbfdc62

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

wt-status.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,20 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
744744
const char *one;
745745
if (d->head_path) {
746746
one = quote_path(d->head_path, -1, &onebuf, s->prefix);
747+
if (*one != '"' && strchr(one, ' ') != NULL) {
748+
putchar('"');
749+
strbuf_addch(&onebuf, '"');
750+
one = onebuf.buf;
751+
}
747752
printf("%s -> ", one);
748753
strbuf_release(&onebuf);
749754
}
750755
one = quote_path(it->string, -1, &onebuf, s->prefix);
756+
if (*one != '"' && strchr(one, ' ') != NULL) {
757+
putchar('"');
758+
strbuf_addch(&onebuf, '"');
759+
one = onebuf.buf;
760+
}
751761
printf("%s\n", one);
752762
strbuf_release(&onebuf);
753763
}

0 commit comments

Comments
 (0)