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

Re: Bug - Status - Space in Filename

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 10, 2017, 00:52 UTC
Message-ID
<xmqqvaijhs5b.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171109132939.3v2z6sf22b4tnwpq@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Yeah, I think the original sin is using " -> " in the --porcelain output
> (which just got it from --short). That should have been a HT all along
> to match the rest of the diff code. The --porcelain=v2 format gets this
> right.
So we at lesat did something right, which is a consolation.
Show 13 quoted lines
>> Perhaps a better approach is to refactor the extra quoting I moved
>> to this emit_with_optional_dq() helper into quote_path() which
>> currently is just aliased to quote_path_relative().  It also is
>> possible that we may want to extend the "no_dq" parameter that is
>> given to quote_c_style() helper from a boolean to a set of flag
>> bits, and allow callers to request "I want SP added to the set of
>> bytes that triggers the quoting".
>
> Yeah, I had the same thought upon digging into the code.
>
> That said, if this is the only place that has this funny quoting, it may
> not be worth polluting the rest of the code with the idea that quoting
> spaces is a good thing to do.
Sounds sane.  We can probably use a helper like this:
static char *quote_path_with_sp(const char *in, const char *prefix, struct strbuf *out)
{
	const char dq = '"';
	quote_path(in, prefix, out);
	if (out->buf[0] != dq && strchr(out->buf, ' ') != NULL) {
		strbuf_insert(out, 0, &dq, 1);
		strbuf_addch(out, dq);
	}
	return out->buf;
}

which allows the current users like shortstatus_status() to become a lot shorter.

Previous: Jeff KingNext: Jeff King
Message 4 of 6 in “RE: Bug - Status - Space in Filename”
  1. Joseph StraussNov 8, 2017
  2. Junio C HamanoNov 9, 2017
  3. Jeff KingNov 9, 2017
  4. Junio C HamanoNov 10, 2017
  5. Jeff KingNov 10, 2017
  6. Junio C HamanoNov 10, 2017

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.