git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] pathspec: catch prepending :(prefix) on pathspec with short magic
@ 2013-09-05  3:40 Nguyễn Thái Ngọc Duy
  2013-09-05  3:40 ` [PATCH 2/3] add: lift the pathspec magic restriction on "add -p" Nguyễn Thái Ngọc Duy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2013-09-05  3:40 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

:(prefix) is in the long form. Suppose people pass :!foo with '!'
being the short form of magic 'bar', the code will happily turn it to
:(prefix..)!foo, which makes '!' part of the path and no longer a magic.

The correct form must be ':(prefix..,bar)foo', but as so far we
haven't had any magic in short form yet (*), the code to convert from
short form to long one will be inactive anyway. Let's postpone it
until a real short form magic appears.

(*) The short form magic '/' is a special case and won't be caught by
this die(), which is correct. When '/' magic is detected, prefixlen is
set back to 0 and the whole "if (prefixlen..)" block is skipped.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 fixes on top of nd/magic-pathspec.

 pathspec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pathspec.c b/pathspec.c
index d9f4143..62fde50 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -231,7 +231,9 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
 		const char *start = elt;
 		if (prefixlen && !literal_global) {
 			/* Preserve the actual prefix length of each pattern */
-			if (long_magic_end) {
+			if (short_magic)
+				die("BUG: prefixing on short magic is not supported");
+			else if (long_magic_end) {
 				strbuf_add(&sb, start, long_magic_end - start);
 				strbuf_addf(&sb, ",prefix:%d", prefixlen);
 				start = long_magic_end;
-- 
1.8.2.83.gc99314b

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-05 18:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-05  3:40 [PATCH 1/3] pathspec: catch prepending :(prefix) on pathspec with short magic Nguyễn Thái Ngọc Duy
2013-09-05  3:40 ` [PATCH 2/3] add: lift the pathspec magic restriction on "add -p" Nguyễn Thái Ngọc Duy
2013-09-05  3:40 ` [PATCH 3/3] add--interactive: fix external command invocation on Windows Nguyễn Thái Ngọc Duy
2013-09-05 18:39 ` [PATCH 1/3] pathspec: catch prepending :(prefix) on pathspec with short magic Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).