aboutsummaryrefslogtreecommitdiff
path: root/pathspec.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-05-11 15:04:27 -0700
committerJunio C Hamano <gitster@pobox.com>2017-05-12 14:23:46 +0900
commit08de9151a8a67f29a3a5a36931298237d78ca736 (patch)
treee592ee783330d7e4f73315706f56a9cf46a15857 /pathspec.c
parent2249d4dbc197d45da5407cbc80b2461e49bb8785 (diff)
downloadgit-08de9151a8a67f29a3a5a36931298237d78ca736.tar.gz
git-08de9151a8a67f29a3a5a36931298237d78ca736.tar.xz
pathspec: convert find_pathspecs_matching_against_index to take an index
Convert find_pathspecs_matching_against_index to take an index parameter. In addition mark pathspec.c with NO_THE_INDEX_COMPATIBILITY_MACROS now that it doesn't use any cache macros or reference 'the_index'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pathspec.c')
-rw-r--r--pathspec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/pathspec.c b/pathspec.c
index 1e5df2316..828405021 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -1,3 +1,4 @@
+#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "dir.h"
#include "pathspec.h"
@@ -17,6 +18,7 @@
* to use find_pathspecs_matching_against_index() instead.
*/
void add_pathspec_matches_against_index(const struct pathspec *pathspec,
+ const struct index_state *istate,
char *seen)
{
int num_unmatched = 0, i;
@@ -32,8 +34,8 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
num_unmatched++;
if (!num_unmatched)
return;
- for (i = 0; i < active_nr; i++) {
- const struct cache_entry *ce = active_cache[i];
+ for (i = 0; i < istate->cache_nr; i++) {
+ const struct cache_entry *ce = istate->cache[i];
ce_path_match(ce, pathspec, seen);
}
}
@@ -46,10 +48,11 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
* nature of the "closest" (i.e. most specific) matches which each of the
* given pathspecs achieves against all items in the index.
*/
-char *find_pathspecs_matching_against_index(const struct pathspec *pathspec)
+char *find_pathspecs_matching_against_index(const struct pathspec *pathspec,
+ const struct index_state *istate)
{
char *seen = xcalloc(pathspec->nr, 1);
- add_pathspec_matches_against_index(pathspec, seen);
+ add_pathspec_matches_against_index(pathspec, istate, seen);
return seen;
}