Re: `git status --porcelain` disagrees with documentation about quoting filenames with spaces

Subsystems: the rest

2 messages, 1 author, 2016-06-15 · open the first message on its own page

Re: `git status --porcelain` disagrees with documentation about quoting filenames with spaces

From: Kevin Ballard <hidden>
Date: 2016-06-15 22:49:56

If you don't mind I've brought this back onto the list.

On Oct 28, 2010, at 6:32 PM, Junio C Hamano wrote:
quoted
BTW, I'm trying an experiment here to see if I can just paste the patch into
Mail.app without it being mangled. I sent it to myself first, and Mail.app
is applying quoted-printable encoding to the patch, but it appears git-am
can still understand it. Please let me know if this isn't acceptable and I
will send it separately.
Almost but not quite; it appears that all the leading SP on the context
lines and the diffstat are lost by somebody.
Well, it looks like I screwed up. I sent a test email to myself and it came
through fine, so I selected all, hit copy, and pasted that into the new
reply to the list. Unfortunately, copying from Mail.app's rich markup view
seems to have lost the spaces. If I copy from the Raw Source view it works
fine. I'll have to try again without making that mistake.
The patch seems to unconditionally dq even when there is no rename
(i.e. when d->head_path is NULL).

I think it _is_ intended (otherwise it becomes unwieldy to tell if you
renamed "foo" to "bar" or if you touched "foo -> bar" without looking at
the status letters) but the behaviour does not seem to match what the log
message says it does.
Good point. I hadn't thought this through properly. Here's an updated patch
with a fixed description. And this time I'm not copying it from a test email ;)

---8<---
Subject: 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 <redacted>
---
 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.195.ge42d1.dirty

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

From: Kevin Ballard <hidden>
Date: 2016-06-15 22:49:59

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

This patch was originally attached via scissors to message id
[off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help