Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-08-20 21:33:53 +0300
committerJunio C Hamano <gitster@pobox.com>2018-08-20 21:33:53 +0300
commitdc0f6f9e1d56059fff1e8c539a1c0e4bc5658714 (patch)
treea2f09658870423d62e82d0bab113bde15375fd35 /dir.c
parentace1f99cc8cf0a688f36c094552f90a398eb137f (diff)
parentecbbc0a53b0393c3b835440b397dedfa9d28ec01 (diff)
Merge branch 'nd/no-the-index'
The more library-ish parts of the codebase learned to work on the in-core index-state instance that is passed in by their callers, instead of always working on the singleton "the_index" instance. * nd/no-the-index: (24 commits) blame.c: remove implicit dependency on the_index apply.c: remove implicit dependency on the_index apply.c: make init_apply_state() take a struct repository apply.c: pass struct apply_state to more functions resolve-undo.c: use the right index instead of the_index archive-*.c: use the right repository archive.c: avoid access to the_index grep: use the right index instead of the_index attr: remove index from git_attr_set_direction() entry.c: use the right index instead of the_index submodule.c: use the right index instead of the_index pathspec.c: use the right index instead of the_index unpack-trees: avoid the_index in verify_absent() unpack-trees: convert clear_ce_flags* to avoid the_index unpack-trees: don't shadow global var the_index unpack-trees: add a note about path invalidation unpack-trees: remove 'extern' on function declaration ls-files: correct index argument to get_convert_attr_ascii() preload-index.c: use the right index instead of the_index dir.c: remove an implicit dependency on the_index in pathspec code ...
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/dir.c b/dir.c
index 32f5f72759..aceb0d4869 100644
--- a/dir.c
+++ b/dir.c
@@ -276,12 +276,13 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
#define DO_MATCH_DIRECTORY (1<<1)
#define DO_MATCH_SUBMODULE (1<<2)
-static int match_attrs(const char *name, int namelen,
+static int match_attrs(const struct index_state *istate,
+ const char *name, int namelen,
const struct pathspec_item *item)
{
int i;
- git_check_attr(name, item->attr_check);
+ git_check_attr(istate, name, item->attr_check);
for (i = 0; i < item->attr_match_nr; i++) {
const char *value;
int matched;
@@ -318,7 +319,8 @@ static int match_attrs(const char *name, int namelen,
*
* It returns 0 when there is no match.
*/
-static int match_pathspec_item(const struct pathspec_item *item, int prefix,
+static int match_pathspec_item(const struct index_state *istate,
+ const struct pathspec_item *item, int prefix,
const char *name, int namelen, unsigned flags)
{
/* name/namelen has prefix cut off by caller */
@@ -358,7 +360,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
strncmp(item->match, name - prefix, item->prefix))
return 0;
- if (item->attr_match_nr && !match_attrs(name, namelen, item))
+ if (item->attr_match_nr && !match_attrs(istate, name, namelen, item))
return 0;
/* If the match was just the prefix, we matched */
@@ -426,7 +428,8 @@ 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 do_match_pathspec(const struct pathspec *ps,
+static int do_match_pathspec(const struct index_state *istate,
+ const struct pathspec *ps,
const char *name, int namelen,
int prefix, char *seen,
unsigned flags)
@@ -472,7 +475,7 @@ static int do_match_pathspec(const struct pathspec *ps,
*/
if (seen && ps->items[i].magic & PATHSPEC_EXCLUDE)
seen[i] = MATCHED_FNMATCH;
- how = match_pathspec_item(ps->items+i, prefix, name,
+ how = match_pathspec_item(istate, ps->items+i, prefix, name,
namelen, flags);
if (ps->recursive &&
(ps->magic & PATHSPEC_MAXDEPTH) &&
@@ -496,17 +499,18 @@ static int do_match_pathspec(const struct pathspec *ps,
return retval;
}
-int match_pathspec(const struct pathspec *ps,
+int match_pathspec(const struct index_state *istate,
+ const struct pathspec *ps,
const char *name, int namelen,
int prefix, char *seen, int is_dir)
{
int positive, negative;
unsigned flags = is_dir ? DO_MATCH_DIRECTORY : 0;
- positive = do_match_pathspec(ps, name, namelen,
+ positive = do_match_pathspec(istate, ps, name, namelen,
prefix, seen, flags);
if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive)
return positive;
- negative = do_match_pathspec(ps, name, namelen,
+ negative = do_match_pathspec(istate, ps, name, namelen,
prefix, seen,
flags | DO_MATCH_EXCLUDE);
return negative ? 0 : positive;
@@ -515,11 +519,12 @@ int match_pathspec(const struct pathspec *ps,
/**
* Check if a submodule is a superset of the pathspec
*/
-int submodule_path_match(const struct pathspec *ps,
+int submodule_path_match(const struct index_state *istate,
+ const struct pathspec *ps,
const char *submodule_name,
char *seen)
{
- int matched = do_match_pathspec(ps, submodule_name,
+ int matched = do_match_pathspec(istate, ps, submodule_name,
strlen(submodule_name),
0, seen,
DO_MATCH_DIRECTORY |