Web lists-archives.com

Re: Bug - Status - Space in Filename

Jeff King <peff@xxxxxxxx> 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.

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