summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-11-18 16:47:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-19 01:50:33 (GMT)
commite092073d643b17c82d72cf692fbfaea9c9796f11 (patch)
tree303e6f2f58bf1817a9b0f9365761e86c5bc1053a /tree.c
parent0e94dab5be2fd17cfba634f8a29ba5461d2cbd9e (diff)
downloadgit-e092073d643b17c82d72cf692fbfaea9c9796f11.zip
git-e092073d643b17c82d72cf692fbfaea9c9796f11.tar.gz
git-e092073d643b17c82d72cf692fbfaea9c9796f11.tar.bz2
tree.c: make read_tree*() take 'struct repository *'
These functions call tree_entry_interesting() which will soon require a 'struct index_state *' to be passed in. Instead of just changing the function signature to take an index, update to take a repo instead because these functions do need object database access. 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 'tree.c')
-rw-r--r--tree.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/tree.c b/tree.c
index 215d3fd..ecd8c8a 100644
--- a/tree.c
+++ b/tree.c
@@ -60,7 +60,8 @@ static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base
ADD_CACHE_JUST_APPEND);
}
-static int read_tree_1(struct tree *tree, struct strbuf *base,
+static int read_tree_1(struct repository *r,
+ struct tree *tree, struct strbuf *base,
int stage, const struct pathspec *pathspec,
read_tree_fn_t fn, void *context)
{
@@ -99,7 +100,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
else if (S_ISGITLINK(entry.mode)) {
struct commit *commit;
- commit = lookup_commit(the_repository, entry.oid);
+ commit = lookup_commit(r, entry.oid);
if (!commit)
die("Commit %s in submodule path %s%s not found",
oid_to_hex(entry.oid),
@@ -118,7 +119,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
len = tree_entry_len(&entry);
strbuf_add(base, entry.path, len);
strbuf_addch(base, '/');
- retval = read_tree_1(lookup_tree(the_repository, &oid),
+ retval = read_tree_1(r, lookup_tree(r, &oid),
base, stage, pathspec,
fn, context);
strbuf_setlen(base, oldlen);
@@ -128,7 +129,8 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
return 0;
}
-int read_tree_recursive(struct tree *tree,
+int read_tree_recursive(struct repository *r,
+ struct tree *tree,
const char *base, int baselen,
int stage, const struct pathspec *pathspec,
read_tree_fn_t fn, void *context)
@@ -137,7 +139,7 @@ int read_tree_recursive(struct tree *tree,
int ret;
strbuf_add(&sb, base, baselen);
- ret = read_tree_1(tree, &sb, stage, pathspec, fn, context);
+ ret = read_tree_1(r, tree, &sb, stage, pathspec, fn, context);
strbuf_release(&sb);
return ret;
}
@@ -152,8 +154,8 @@ static int cmp_cache_name_compare(const void *a_, const void *b_)
ce2->name, ce2->ce_namelen, ce_stage(ce2));
}
-int read_tree(struct tree *tree, int stage, struct pathspec *match,
- struct index_state *istate)
+int read_tree(struct repository *r, struct tree *tree, int stage,
+ struct pathspec *match, struct index_state *istate)
{
read_tree_fn_t fn = NULL;
int i, err;
@@ -181,7 +183,7 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,
if (!fn)
fn = read_one_entry_quick;
- err = read_tree_recursive(tree, "", 0, stage, match, fn, istate);
+ err = read_tree_recursive(r, tree, "", 0, stage, match, fn, istate);
if (fn == read_one_entry || err)
return err;