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

Re: [PATCH 1/2] renaming quote_path() as quote_path_relative()

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2008, 01:41 UTC
Message-ID
<7vve3z5mzh.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1204852397-20939-1-git-send-email-dpotapov@gmail.com>
Dmitry Potapov <dpotapov@gmail.com> writes:
Show 6 quoted lines
> Based on Junio's suggestion, this patch moves quote_path() from
> wt-status.c to quote.c and renames it as quote_path_relative(),
> because it is a better name for a public function.
>
> Also, instead of handcrafted quoting, quote_c_style_counted() is now
> used, so it will honor core.quotepath specified in configuration.
Thanks.
Show 19 quoted lines
> +	strbuf_grow(out, len);
> +	strbuf_setlen(out, 0);
> +	if (prefix) {
> +		int off = 0;
> +		while (prefix[off] && off < len && prefix[off] == in[off])
> +			if (prefix[off] == '/') {
> +				prefix += off + 1;
> +				in += off + 1;
> +				len -= off + 1;
> +				off = 0;
> +			} else
> +				off++;
> +
> +		for (; *prefix; prefix++)
> +			if (*prefix == '/')
> +				strbuf_addstr(out, "../");
> +	}
> +
> +	quote_c_style_counted (in, len, out, NULL, 1);

Hmmm. Shouldn't the whole path (including the ../ part you add) be surrounded by a pair of dq iff quote_c_style() finds that the path needs to be quoted?

I am reasonably sure that the scripted version of git-status (before wt-status part was rewritten in C) acted that way.

	$ git --version
	git version 1.2.0
	$ echo frotz >qf\\w\"fq
	$ ls
	./  ../  .git/	qf\w"fq
	$ git add qf*q
	$ git status
	#
	# Initial commit
	#
	#
	# Updated but not checked in:
	#   (will commit)
	#
	#	new file: "qf\\w\"fq"
	#
Previous: Dmitry PotapovNext: Dmitry Potapov
Message 5 of 6 in “git-clean: correct printing relative path”
  1. git-clean: correct printing relative pathDmitry Potapov, Mar 6, 2008
  2. Junio C HamanoMar 6, 2008
  3. 1/2 renaming quote_path() as quote_path_relative()Dmitry Potapov, Mar 7, 2008
  4. 2/2 git-clean: correct printing relative pathDmitry Potapov, Mar 7, 2008
  5. Junio C HamanoMar 7, 2008
  6. Dmitry PotapovMar 7, 2008

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.