git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] status: Quote paths with spaces in short format

From
Kevin Ballard <kevin@sb.org>
Date
Nov 9, 2010, 02:44 UTC
Message-ID
<1289270678-89237-1-git-send-email-kevin@sb.org>
In-Reply-To
<A2E979E4-899B-4295-A8CF-72EF8E585D3A@sb.org>

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>
---

This patch was originally attached via scissors to message id <A2E979E4-899B-4295-A8CF-72EF8E585D3A@sb.org> but it appears to have been overlooked.

 wt-status.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index fc2438f..9624865 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -744,10 +744,20 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
 		const char *one;
 		if (d->head_path) {
 			one = quote_path(d->head_path, -1, &onebuf, s->prefix);
+			if (*one != '"' && strchr(one, ' ') != NULL) {
+				putchar('"');
+				strbuf_addch(&onebuf, '"');
+				one = onebuf.buf;
+			}
 			printf("%s -> ", one);
 			strbuf_release(&onebuf);
 		}
 		one = quote_path(it->string, -1, &onebuf, s->prefix);
+		if (*one != '"' && strchr(one, ' ') != NULL) {
+			putchar('"');
+			strbuf_addch(&onebuf, '"');
+			one = onebuf.buf;
+		}
 		printf("%s\n", one);
 		strbuf_release(&onebuf);
 	}
-- 
1.7.3.2.203.ge51db
Previous: Kevin Ballard
Message 7 of 7 in “`git status --porcelain` disagrees with documentation about quoting filenames with spaces”
  1. Kevin BallardOct 27, 2010
  2. Junio C HamanoOct 28, 2010
  3. Kevin BallardOct 28, 2010
  4. Junio C HamanoOct 28, 2010
  5. Kevin BallardOct 29, 2010
  6. Kevin BallardOct 29, 2010
  7. status: Quote paths with spaces in short formatKevin Ballard, Nov 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.