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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dmitry Potapov <dpotapov@xxxxxxxxx> writes:

> 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.
> +	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"
	#
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux