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.