diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-07-14 15:36:00 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-15 10:56:09 -0700 |
commit | 84b8b5d1fa244bc591291a3cf18bf0fa9976ad17 (patch) | |
tree | 67f5a9e9a0c5cb67fcd3694055403fcd4936b2be /builtin/add.c | |
parent | 9a0872744315da67db3c81eb9270751e31fcc8f5 (diff) | |
download | git-84b8b5d1fa244bc591291a3cf18bf0fa9976ad17.tar.gz |
remove match_pathspec() in favor of match_pathspec_depth()
match_pathspec_depth was created to replace match_pathspec (see
61cf282 (pathspec: add match_pathspec_depth() - 2010-12-15). It took
more than two years, but the replacement finally happens :-)
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 'builtin/add.c')
-rw-r--r-- | builtin/add.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/builtin/add.c b/builtin/add.c index a47aeb4662..0b80fa8956 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -195,23 +195,21 @@ int add_files_to_cache(const char *prefix, } #define WARN_IMPLICIT_DOT (1u << 0) -static char *prune_directory(struct dir_struct *dir, const char **pathspec, +static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, int prefix, unsigned flag) { char *seen; - int i, specs; + int i; struct dir_entry **src, **dst; - for (specs = 0; pathspec[specs]; specs++) - /* nothing */; - seen = xcalloc(specs, 1); + seen = xcalloc(pathspec->nr, 1); src = dst = dir->entries; i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; - if (match_pathspec(pathspec, entry->name, entry->len, - prefix, seen)) + if (match_pathspec_depth(pathspec, entry->name, entry->len, + prefix, seen)) *dst++ = entry; else if (flag & WARN_IMPLICIT_DOT) /* @@ -225,7 +223,7 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec, warn_pathless_add(); } dir->nr = dst - dir->entries; - add_pathspec_matches_against_index(pathspec, seen, specs); + add_pathspec_matches_against_index(pathspec, seen); return seen; } @@ -523,7 +521,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) /* This picks up the paths that are not tracked */ baselen = fill_directory(&dir, implicit_dot ? &empty_pathspec : &pathspec); if (pathspec.nr) - seen = prune_directory(&dir, pathspec.raw, baselen, + seen = prune_directory(&dir, &pathspec, baselen, implicit_dot ? WARN_IMPLICIT_DOT : 0); } @@ -538,23 +536,23 @@ int cmd_add(int argc, const char **argv, const char *prefix) int i; if (!seen) - seen = find_pathspecs_matching_against_index(pathspec.raw); + seen = find_pathspecs_matching_against_index(&pathspec); /* * file_exists() assumes exact match */ GUARD_PATHSPEC(&pathspec, PATHSPEC_FROMTOP); - for (i = 0; pathspec.raw[i]; i++) { - if (!seen[i] && pathspec.raw[i][0] - && !file_exists(pathspec.raw[i])) { + for (i = 0; i < pathspec.nr; i++) { + const char *path = pathspec.items[i].match; + if (!seen[i] && !file_exists(path)) { if (ignore_missing) { int dtype = DT_UNKNOWN; - if (is_excluded(&dir, pathspec.raw[i], &dtype)) - dir_add_ignored(&dir, pathspec.raw[i], strlen(pathspec.raw[i])); + if (is_excluded(&dir, path, &dtype)) + dir_add_ignored(&dir, path, pathspec.items[i].len); } else die(_("pathspec '%s' did not match any files"), - pathspec.raw[i]); + pathspec.items[i].original); } } free(seen); |