Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:21

Dmitry Potapov [off-list ref] 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"
	#
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help