OSDN Git Service

pathspec: rename match_pathspec_depth() to match_pathspec()
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 24 Jan 2014 13:40:30 +0000 (20:40 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2014 22:37:14 +0000 (14:37 -0800)
A long time ago, for some reason I was not happy with
match_pathspec(). I created a better version, match_pathspec_depth()
that was suppose to replace match_pathspec()
eventually. match_pathspec() has finally been gone since 6 months
ago. Use the shorter name for match_pathspec_depth().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clean.c
builtin/ls-files.c
builtin/ls-tree.c
dir.c
dir.h
rerere.c
t/t6131-pathspec-icase.sh

index 2f26297..f59c753 100644 (file)
@@ -961,8 +961,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                        die_errno("Cannot lstat '%s'", ent->name);
 
                if (pathspec.nr)
-                       matches = match_pathspec_depth(&pathspec, ent->name,
-                                                      len, 0, NULL);
+                       matches = match_pathspec(&pathspec, ent->name,
+                                                len, 0, NULL);
 
                if (S_ISDIR(st.st_mode)) {
                        if (remove_directories || (matches == MATCHED_EXACTLY)) {
index e238608..02db0e1 100644 (file)
@@ -139,7 +139,8 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
        if (len >= ce_namelen(ce))
                die("git ls-files: internal error - cache entry not superset of prefix");
 
-       if (!match_pathspec_depth(&pathspec, ce->name, ce_namelen(ce), len, ps_matched))
+       if (!match_pathspec(&pathspec, ce->name, ce_namelen(ce),
+                           len, ps_matched))
                return;
 
        if (tag && *tag && show_valid_bit &&
@@ -195,7 +196,8 @@ static void show_ru_info(void)
                len = strlen(path);
                if (len < max_prefix_len)
                        continue; /* outside of the prefix */
-               if (!match_pathspec_depth(&pathspec, path, len, max_prefix_len, ps_matched))
+               if (!match_pathspec(&pathspec, path, len,
+                                   max_prefix_len, ps_matched))
                        continue; /* uninterested */
                for (i = 0; i < 3; i++) {
                        if (!ui->mode[i])
index 65ec931..51184df 100644 (file)
@@ -171,7 +171,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
         * show_recursive() rolls its own matching code and is
         * generally ignorant of 'struct pathspec'. The magic mask
         * cannot be lifted until it is converted to use
-        * match_pathspec_depth() or tree_entry_interesting()
+        * match_pathspec() or tree_entry_interesting()
         */
        parse_pathspec(&pathspec, PATHSPEC_GLOB | PATHSPEC_ICASE,
                       PATHSPEC_PREFER_CWD,
diff --git a/dir.c b/dir.c
index b35b633..442a548 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -218,7 +218,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
         * The normal call pattern is:
         * 1. prefix = common_prefix_len(ps);
         * 2. prune something, or fill_directory
-        * 3. match_pathspec_depth()
+        * 3. match_pathspec()
         *
         * 'prefix' at #1 may be shorter than the command's prefix and
         * it's ok for #2 to match extra files. Those extras will be
@@ -282,10 +282,10 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
  * pathspec did not match any names, which could indicate that the
  * user mistyped the nth pathspec.
  */
-static int match_pathspec_depth_1(const struct pathspec *ps,
-                                 const char *name, int namelen,
-                                 int prefix, char *seen,
-                                 int exclude)
+static int do_match_pathspec(const struct pathspec *ps,
+                            const char *name, int namelen,
+                            int prefix, char *seen,
+                            int exclude)
 {
        int i, retval = 0;
 
@@ -350,15 +350,15 @@ static int match_pathspec_depth_1(const struct pathspec *ps,
        return retval;
 }
 
-int match_pathspec_depth(const struct pathspec *ps,
-                        const char *name, int namelen,
-                        int prefix, char *seen)
+int match_pathspec(const struct pathspec *ps,
+                  const char *name, int namelen,
+                  int prefix, char *seen)
 {
        int positive, negative;
-       positive = match_pathspec_depth_1(ps, name, namelen, prefix, seen, 0);
+       positive = do_match_pathspec(ps, name, namelen, prefix, seen, 0);
        if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive)
                return positive;
-       negative = match_pathspec_depth_1(ps, name, namelen, prefix, seen, 1);
+       negative = do_match_pathspec(ps, name, namelen, prefix, seen, 1);
        return negative ? 0 : positive;
 }
 
diff --git a/dir.h b/dir.h
index 65f54b6..c31ed9a 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -132,9 +132,9 @@ struct dir_struct {
 extern int simple_length(const char *match);
 extern int no_wildcard(const char *string);
 extern char *common_prefix(const struct pathspec *pathspec);
-extern int match_pathspec_depth(const struct pathspec *pathspec,
-                               const char *name, int namelen,
-                               int prefix, char *seen);
+extern int match_pathspec(const struct pathspec *pathspec,
+                         const char *name, int namelen,
+                         int prefix, char *seen);
 extern int within_depth(const char *name, int namelen, int depth, int max_depth);
 
 extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec);
@@ -209,14 +209,14 @@ static inline int ce_path_match(const struct cache_entry *ce,
                                const struct pathspec *pathspec,
                                char *seen)
 {
-       return match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, seen);
+       return match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen);
 }
 
 static inline int dir_path_match(const struct dir_entry *ent,
                                 const struct pathspec *pathspec,
                                 int prefix, char *seen)
 {
-       return match_pathspec_depth(pathspec, ent->name, ent->len, prefix, seen);
+       return match_pathspec(pathspec, ent->name, ent->len, prefix, seen);
 }
 
 #endif
index 1f2d21a..34a21c4 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -672,8 +672,8 @@ int rerere_forget(struct pathspec *pathspec)
        find_conflict(&conflict);
        for (i = 0; i < conflict.nr; i++) {
                struct string_list_item *it = &conflict.items[i];
-               if (!match_pathspec_depth(pathspec, it->string, strlen(it->string),
-                                         0, NULL))
+               if (!match_pathspec(pathspec, it->string,
+                                   strlen(it->string), 0, NULL))
                        continue;
                rerere_forget_one_path(it->string, &merge_rr);
        }
index a7c7ff5..39fc3f6 100755 (executable)
@@ -69,7 +69,7 @@ test_expect_success 'tree_entry_interesting matches :(icase)bar with empty prefi
        test_cmp expect actual
 '
 
-test_expect_success 'match_pathspec_depth matches :(icase)bar' '
+test_expect_success 'match_pathspec matches :(icase)bar' '
        cat <<-EOF >expect &&
        BAR
        bAr
@@ -79,7 +79,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar' '
        test_cmp expect actual
 '
 
-test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
+test_expect_success 'match_pathspec matches :(icase)bar with prefix' '
        cat <<-EOF >expect &&
        fOo/BAR
        fOo/bAr
@@ -89,7 +89,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
        test_cmp expect actual
 '
 
-test_expect_success 'match_pathspec_depth matches :(icase)bar with empty prefix' '
+test_expect_success 'match_pathspec matches :(icase)bar with empty prefix' '
        cat <<-EOF >expect &&
        bar
        fOo/BAR