summaryrefslogtreecommitdiff
path: root/pathspec.h
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-07-14 15:36:09 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-07-15 12:14:38 -0700
commit93d935371654faf2956a4c37c1ca46f3195ee832 (patch)
tree913861fd9f039c86e4f3a8b3ea1b51391d72d05d /pathspec.h
parentpathspec: support :(glob) syntax (diff)
downloadtgif-93d935371654faf2956a4c37c1ca46f3195ee832.tar.xz
parse_pathspec: accept :(icase)path syntax
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pathspec.h')
-rw-r--r--pathspec.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/pathspec.h b/pathspec.h
index cdf2fa39f6..04b632fa33 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -6,11 +6,13 @@
#define PATHSPEC_MAXDEPTH (1<<1)
#define PATHSPEC_LITERAL (1<<2)
#define PATHSPEC_GLOB (1<<3)
+#define PATHSPEC_ICASE (1<<4)
#define PATHSPEC_ALL_MAGIC \
(PATHSPEC_FROMTOP | \
PATHSPEC_MAXDEPTH | \
PATHSPEC_LITERAL | \
- PATHSPEC_GLOB)
+ PATHSPEC_GLOB | \
+ PATHSPEC_ICASE)
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern sastisfies GFNM_ONESTAR */
@@ -65,6 +67,24 @@ extern void parse_pathspec(struct pathspec *pathspec,
extern void copy_pathspec(struct pathspec *dst, const struct pathspec *src);
extern void free_pathspec(struct pathspec *);
+static inline int ps_strncmp(const struct pathspec_item *item,
+ const char *s1, const char *s2, size_t n)
+{
+ if (item->magic & PATHSPEC_ICASE)
+ return strncasecmp(s1, s2, n);
+ else
+ return strncmp(s1, s2, n);
+}
+
+static inline int ps_strcmp(const struct pathspec_item *item,
+ const char *s1, const char *s2)
+{
+ if (item->magic & PATHSPEC_ICASE)
+ return strcasecmp(s1, s2);
+ else
+ return strcmp(s1, s2);
+}
+
extern char *find_pathspecs_matching_against_index(const struct pathspec *pathspec);
extern void add_pathspec_matches_against_index(const struct pathspec *pathspec, char *seen);
extern const char *check_path_for_gitlink(const char *path);