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" #