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>
This commit is contained in:
parent
ebb32893ba
commit
854b09592c
@ -961,7 +961,7 @@ 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,
|
||||
matches = match_pathspec(&pathspec, ent->name,
|
||||
len, 0, NULL);
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
|
@ -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])
|
||||
|
@ -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,
|
||||
|
10
dir.c
10
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,7 +282,7 @@ 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,
|
||||
static int do_match_pathspec(const struct pathspec *ps,
|
||||
const char *name, int namelen,
|
||||
int prefix, char *seen,
|
||||
int exclude)
|
||||
@ -350,15 +350,15 @@ static int match_pathspec_depth_1(const struct pathspec *ps,
|
||||
return retval;
|
||||
}
|
||||
|
||||
int match_pathspec_depth(const struct pathspec *ps,
|
||||
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;
|
||||
}
|
||||
|
||||
|
6
dir.h
6
dir.h
@ -132,7 +132,7 @@ 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,
|
||||
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);
|
||||
@ -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
|
||||
|
4
rerere.c
4
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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user