]> git.ipfire.org Git - thirdparty/git.git/commit - wildmatch.c
wildmatch: adjust "**" behavior
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 15 Oct 2012 06:26:00 +0000 (13:26 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Oct 2012 21:58:18 +0000 (14:58 -0700)
commit40bbee0ab07d0ee4f21b11d597c878245c1b05a6
treea966918d4df85bb7a398d4b37286b4ba731b7e98
parent164bf83af6466e03b306b9d63dcf7d36dda2bdae
wildmatch: adjust "**" behavior

Standard wildmatch() sees consecutive asterisks as "*" that can also
match slashes. But that may be hard to explain to users as
"abc/**/def" can match "abcdef", "abcxyzdef", "abc/def", "abc/x/def",
"abc/x/y/def"...

This patch changes wildmatch so that users can do

- "**/def" -> all paths ending with file/directory 'def'
- "abc/**" - equivalent to "/abc/"
- "abc/**/def" -> "abc/x/def", "abc/x/y/def"...
- otherwise consider the pattern malformed if "**" is found

Basically the magic of "**" only remains if it's wrapped around by
slashes.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3070-wildmatch.sh
wildmatch.c
wildmatch.h