Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 854b095

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebb3289 commit 854b095

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

builtin/clean.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
961961
die_errno("Cannot lstat '%s'", ent->name);
962962

963963
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);
966966

967967
if (S_ISDIR(st.st_mode)) {
968968
if (remove_directories || (matches == MATCHED_EXACTLY)) {

builtin/ls-files.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
139139
if (len >= ce_namelen(ce))
140140
die("git ls-files: internal error - cache entry not superset of prefix");
141141

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))
143144
return;
144145

145146
if (tag && *tag && show_valid_bit &&
@@ -195,7 +196,8 @@ static void show_ru_info(void)
195196
len = strlen(path);
196197
if (len < max_prefix_len)
197198
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))
199201
continue; /* uninterested */
200202
for (i = 0; i < 3; i++) {
201203
if (!ui->mode[i])

builtin/ls-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
171171
* show_recursive() rolls its own matching code and is
172172
* generally ignorant of 'struct pathspec'. The magic mask
173173
* cannot be lifted until it is converted to use
174-
* match_pathspec_depth() or tree_entry_interesting()
174+
* match_pathspec() or tree_entry_interesting()
175175
*/
176176
parse_pathspec(&pathspec, PATHSPEC_GLOB | PATHSPEC_ICASE,
177177
PATHSPEC_PREFER_CWD,

dir.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
218218
* The normal call pattern is:
219219
* 1. prefix = common_prefix_len(ps);
220220
* 2. prune something, or fill_directory
221-
* 3. match_pathspec_depth()
221+
* 3. match_pathspec()
222222
*
223223
* 'prefix' at #1 may be shorter than the command's prefix and
224224
* 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,
282282
* pathspec did not match any names, which could indicate that the
283283
* user mistyped the nth pathspec.
284284
*/
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)
289289
{
290290
int i, retval = 0;
291291

@@ -350,15 +350,15 @@ static int match_pathspec_depth_1(const struct pathspec *ps,
350350
return retval;
351351
}
352352

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)
356356
{
357357
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);
359359
if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive)
360360
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);
362362
return negative ? 0 : positive;
363363
}
364364

dir.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ struct dir_struct {
132132
extern int simple_length(const char *match);
133133
extern int no_wildcard(const char *string);
134134
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);
138138
extern int within_depth(const char *name, int namelen, int depth, int max_depth);
139139

140140
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,
209209
const struct pathspec *pathspec,
210210
char *seen)
211211
{
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);
213213
}
214214

215215
static inline int dir_path_match(const struct dir_entry *ent,
216216
const struct pathspec *pathspec,
217217
int prefix, char *seen)
218218
{
219-
return match_pathspec_depth(pathspec, ent->name, ent->len, prefix, seen);
219+
return match_pathspec(pathspec, ent->name, ent->len, prefix, seen);
220220
}
221221

222222
#endif

rerere.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,8 @@ int rerere_forget(struct pathspec *pathspec)
672672
find_conflict(&conflict);
673673
for (i = 0; i < conflict.nr; i++) {
674674
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))
677677
continue;
678678
rerere_forget_one_path(it->string, &merge_rr);
679679
}

t/t6131-pathspec-icase.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test_expect_success 'tree_entry_interesting matches :(icase)bar with empty prefi
6969
test_cmp expect actual
7070
'
7171

72-
test_expect_success 'match_pathspec_depth matches :(icase)bar' '
72+
test_expect_success 'match_pathspec matches :(icase)bar' '
7373
cat <<-EOF >expect &&
7474
BAR
7575
bAr
@@ -79,7 +79,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar' '
7979
test_cmp expect actual
8080
'
8181

82-
test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
82+
test_expect_success 'match_pathspec matches :(icase)bar with prefix' '
8383
cat <<-EOF >expect &&
8484
fOo/BAR
8585
fOo/bAr
@@ -89,7 +89,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
8989
test_cmp expect actual
9090
'
9191

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' '
9393
cat <<-EOF >expect &&
9494
bar
9595
fOo/BAR

0 commit comments

Comments
 (0)