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

Re: [PATCH] grep: follow conventions for printing paths w/ unusual chars

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 17, 2020, 06:45 UTC
Message-ID
<xmqq8siuwqxp.fsf@gitster.c.googlers.com>
In-Reply-To
<eaae7214925189f562056b1ee6972c05dcf76a32.1587103366.git.matheus.bernardino@usp.br>
Matheus Tavares <matheus.bernardino@usp.br> writes:
> +	if (opt->relative && opt->prefix_length)
> +		quote_path_relative(filename + tree_name_len, opt->prefix, out);
> +	else
> +		quote_c_style(filename + tree_name_len, out, NULL, 0);

Yup. This solves the discrepancy reported correctly (i.e. both sides should do the quoting, the original only quoted when relative, and the new code corrects the other side).

> +	if (tree_name_len)
> +		strbuf_insert(out, 0, filename, tree_name_len);
I am not quite sure about this part, though.  

Earlier we inserted the latter part of filename (after offset tree_name_len) to strbuf "out" after quoting, and then we are prefixing the earlier part of the filename without quoting to that same "out". Wouldn't a path ABCDEF (I do not literally mean that these ascii alphabets need quoting---just imagine each of these stands for a different letter and some causes the path to be quoted) with tree_name_len pointing somewhere in the middle be added as (an analog of) ABC"DEF", i.e. literal prefix with remainder quoted? I would (perhaps näively) expect that the whole thing would be placed inside a dq pair in such a case, even if the prefix part alone would not require quoting.

Thanks.
Previous: Matheus TavaresNext: Matheus Tavares Bernardino
Message 7 of 13 in “git-grep's "-z" option misbehaves in subdirectory”
  1. Greg HurrellApr 13, 2020
  2. Junio C HamanoApr 13, 2020
  3. Matheus Tavares, Apr 14, 2020
  4. Matheus Tavares BernardinoApr 16, 2020
  5. Junio C HamanoApr 16, 2020
  6. grep: follow conventions for printing paths w/ unusual charsMatheus Tavares, Apr 17, 2020
  7. Junio C HamanoApr 17, 2020
  8. Matheus Tavares BernardinoApr 17, 2020
  9. Junio C HamanoApr 17, 2020
  10. Johannes SchindelinApr 18, 2020
  11. Johannes SchindelinApr 18, 2020
  12. Matheus Tavares BernardinoApr 19, 2020
  13. grep: follow conventions for printing paths w/ unusual charsMatheus Tavares, Apr 19, 2020

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.