pathspec: rename match_pathspec_depth() to match_pathspec()

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>

Nguyễn Thái Ngọc Duy committed Jan 24, 2014 at 20:40 UTC 854b09592ce9a497f56f35d973c4abe43af84cd1
7 files changed +27 -25
builtin/clean.c
+2 -2
@@ -961,8 +961,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
961 die_errno("Cannot lstat '%s'", ent->name);
962
963 if (pathspec.nr)
964 - matches = match_pathspec_depth(&pathspec, ent->name,
965 - len, 0, NULL);
964 + matches = match_pathspec(&pathspec, ent->name,
965 + len, 0, NULL);
966
967 if (S_ISDIR(st.st_mode)) {
968 if (remove_directories || (matches == MATCHED_EXACTLY)) {
builtin/ls-files.c
+4 -2
@@ -139,7 +139,8 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
139 if (len >= ce_namelen(ce))
140 die("git ls-files: internal error - cache entry not superset of prefix");
141
142 - if (!match_pathspec_depth(&pathspec, ce->name, ce_namelen(ce), len, ps_matched))
142 + if (!match_pathspec(&pathspec, ce->name, ce_namelen(ce),
143 + len, ps_matched))
144 return;
145
146 if (tag && *tag && show_valid_bit &&
@@ -195,7 +196,8 @@ static void show_ru_info(void)
196 len = strlen(path);
197 if (len < max_prefix_len)
198 continue; /* outside of the prefix */
198 - if (!match_pathspec_depth(&pathspec, path, len, max_prefix_len, ps_matched))
199 + if (!match_pathspec(&pathspec, path, len,
200 + max_prefix_len, ps_matched))
201 continue; /* uninterested */
202 for (i = 0; i < 3; i++) {
203 if (!ui->mode[i])
builtin/ls-tree.c
+1 -1
@@ -171,7 +171,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
171 * show_recursive() rolls its own matching code and is
172 * generally ignorant of 'struct pathspec'. The magic mask
173 * cannot be lifted until it is converted to use
174 - * match_pathspec_depth() or tree_entry_interesting()
174 + * match_pathspec() or tree_entry_interesting()
175 */
176 parse_pathspec(&pathspec, PATHSPEC_GLOB | PATHSPEC_ICASE,
177 PATHSPEC_PREFER_CWD,
dir.c
+10 -10
@@ -218,7 +218,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
218 * The normal call pattern is:
219 * 1. prefix = common_prefix_len(ps);
220 * 2. prune something, or fill_directory
221 - * 3. match_pathspec_depth()
221 + * 3. match_pathspec()
222 *
223 * 'prefix' at #1 may be shorter than the command's prefix and
224 * 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,
282 * pathspec did not match any names, which could indicate that the
283 * user mistyped the nth pathspec.
284 */
285 -static int match_pathspec_depth_1(const struct pathspec *ps,
286 - const char *name, int namelen,
287 - int prefix, char *seen,
288 - int exclude)
285 +static int do_match_pathspec(const struct pathspec *ps,
286 + const char *name, int namelen,
287 + int prefix, char *seen,
288 + int exclude)
289 {
290 int i, retval = 0;
291
@@ -350,15 +350,15 @@ static int match_pathspec_depth_1(const struct pathspec *ps,
350 return retval;
351 }
352
353 -int match_pathspec_depth(const struct pathspec *ps,
354 - const char *name, int namelen,
355 - int prefix, char *seen)
353 +int match_pathspec(const struct pathspec *ps,
354 + const char *name, int namelen,
355 + int prefix, char *seen)
356 {
357 int positive, negative;
358 - positive = match_pathspec_depth_1(ps, name, namelen, prefix, seen, 0);
358 + positive = do_match_pathspec(ps, name, namelen, prefix, seen, 0);
359 if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive)
360 return positive;
361 - negative = match_pathspec_depth_1(ps, name, namelen, prefix, seen, 1);
361 + negative = do_match_pathspec(ps, name, namelen, prefix, seen, 1);
362 return negative ? 0 : positive;
363 }
364
dir.h
+5 -5
@@ -132,9 +132,9 @@ struct dir_struct {
132 extern int simple_length(const char *match);
133 extern int no_wildcard(const char *string);
134 extern char *common_prefix(const struct pathspec *pathspec);
135 -extern int match_pathspec_depth(const struct pathspec *pathspec,
136 - const char *name, int namelen,
137 - int prefix, char *seen);
135 +extern int match_pathspec(const struct pathspec *pathspec,
136 + const char *name, int namelen,
137 + int prefix, char *seen);
138 extern int within_depth(const char *name, int namelen, int depth, int max_depth);
139
140 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,
209 const struct pathspec *pathspec,
210 char *seen)
211 {
212 - return match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, seen);
212 + return match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen);
213 }
214
215 static inline int dir_path_match(const struct dir_entry *ent,
216 const struct pathspec *pathspec,
217 int prefix, char *seen)
218 {
219 - return match_pathspec_depth(pathspec, ent->name, ent->len, prefix, seen);
219 + return match_pathspec(pathspec, ent->name, ent->len, prefix, seen);
220 }
221
222 #endif
rerere.c
+2 -2
@@ -672,8 +672,8 @@ int rerere_forget(struct pathspec *pathspec)
672 find_conflict(&conflict);
673 for (i = 0; i < conflict.nr; i++) {
674 struct string_list_item *it = &conflict.items[i];
675 - if (!match_pathspec_depth(pathspec, it->string, strlen(it->string),
676 - 0, NULL))
675 + if (!match_pathspec(pathspec, it->string,
676 + strlen(it->string), 0, NULL))
677 continue;
678 rerere_forget_one_path(it->string, &merge_rr);
679 }
t/t6131-pathspec-icase.sh
+3 -3
@@ -69,7 +69,7 @@ test_expect_success 'tree_entry_interesting matches :(icase)bar with empty prefi
69 test_cmp expect actual
70 '
71
72 -test_expect_success 'match_pathspec_depth matches :(icase)bar' '
72 +test_expect_success 'match_pathspec matches :(icase)bar' '
73 cat <<-EOF >expect &&
74 BAR
75 bAr
@@ -79,7 +79,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar' '
79 test_cmp expect actual
80 '
81
82 -test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
82 +test_expect_success 'match_pathspec matches :(icase)bar with prefix' '
83 cat <<-EOF >expect &&
84 fOo/BAR
85 fOo/bAr
@@ -89,7 +89,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
89 test_cmp expect actual
90 '
91
92 -test_expect_success 'match_pathspec_depth matches :(icase)bar with empty prefix' '
92 +test_expect_success 'match_pathspec matches :(icase)bar with empty prefix' '
93 cat <<-EOF >expect &&
94 bar
95 fOo/BAR