All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH/RFC 3/3] gitignore: support "**" with wildmatch()
Date: Mon,  7 May 2012 20:01:57 +0700	[thread overview]
Message-ID: <1336395717-7799-4-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1336395717-7799-1-git-send-email-pclouds@gmail.com>


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c |   20 ++++++++++++++++----
 dir.h |    1 +
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/dir.c b/dir.c
index e98760c..75140f6 100644
--- a/dir.c
+++ b/dir.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "refs.h"
+#include "compat/wildmatch.h"
 
 struct path_simplify {
 	int len;
@@ -335,6 +336,11 @@ void add_exclude(const char *string, const char *base,
 		x->flags |= EXC_FLAG_NODIR;
 	if (no_wildcard(string))
 		x->flags |= EXC_FLAG_NOWILDCARD;
+	else if (strstr(string, "**")) {
+		if (ignore_case)
+			warning(_("core.ignorecase is ignored in '%s' because of \"**\""), string);
+		x->flags |= EXC_FLAG_WILDMATCH;
+	}
 	if (*string == '*' && no_wildcard(string+1))
 		x->flags |= EXC_FLAG_ENDSWITH;
 	ALLOC_GROW(which->excludes, which->nr + 1, which->alloc);
@@ -549,11 +555,17 @@ int excluded_from_list(const char *pathname,
 				if (x->flags & EXC_FLAG_NOWILDCARD) {
 					if (!strcmp_icase(exclude, pathname + baselen))
 						return to_exclude;
-				} else {
-					if (fnmatch_icase(exclude, pathname+baselen,
-						    FNM_PATHNAME) == 0)
-					    return to_exclude;
+					continue;
+				}
+
+				if (x->flags & EXC_FLAG_WILDMATCH) {
+					if (wildmatch(exclude, pathname + baselen))
+						return to_exclude;
+					continue;
 				}
+				if (fnmatch_icase(exclude, pathname + baselen,
+						  FNM_PATHNAME) == 0)
+					return to_exclude;
 			}
 		}
 	}
diff --git a/dir.h b/dir.h
index 58b6fc7..794f412 100644
--- a/dir.h
+++ b/dir.h
@@ -10,6 +10,7 @@ struct dir_entry {
 #define EXC_FLAG_NOWILDCARD 2
 #define EXC_FLAG_ENDSWITH 4
 #define EXC_FLAG_MUSTBEDIR 8
+#define EXC_FLAG_WILDMATCH 16
 
 struct exclude_list {
 	int nr;
-- 
1.7.8.36.g69ee2

  parent reply	other threads:[~2012-05-07 13:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07 13:01 [PATCH/RFC 0/3] Support ignore rule "**" using wildmatch from rsync Nguyễn Thái Ngọc Duy
2012-05-07 13:01 ` [PATCH/RFC 1/3] Import " Nguyễn Thái Ngọc Duy
2012-05-07 13:01 ` [PATCH/RFC 2/3] Integrate wildmatch to git Nguyễn Thái Ngọc Duy
2012-05-07 13:01 ` Nguyễn Thái Ngọc Duy [this message]
2012-05-07 19:05 ` [PATCH/RFC 0/3] Support ignore rule "**" using wildmatch from rsync Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336395717-7799-4-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.