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

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 <kevin@sb.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kevin Ballard committed Nov 8, 2010 at 18:44 UTC dbfdc625a5aad10c47e3ffa446d0b92e341a7b44
1 file changed +10
wt-status.c
+10
@@ -744,10 +744,20 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
744 const char *one;
745 if (d->head_path) {
746 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 + }
752 printf("%s -> ", one);
753 strbuf_release(&onebuf);
754 }
755 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 + }
761 printf("%s\n", one);
762 strbuf_release(&onebuf);
763 }