When try to do deref_without_lazy_fetch_extended(), "oi_flags" will be missed by lookup_commit_in_graph(), then repo_has_object_file() may start a new round objects fetching. So let's add "flags" to lookup_commit_in_graph() and use repo_has_object_file_with_flags() to pass the flags. Signed-off-by: Han Xin <hanxin.hx@xxxxxxxxxxxxx> --- builtin/fetch.c | 4 +++- commit-graph.c | 5 +++-- commit-graph.h | 3 ++- fetch-pack.c | 4 ++-- revision.c | 2 +- upload-pack.c | 5 +++-- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index ac29c2b1ae..44285d5318 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1179,7 +1179,9 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, * annotated tags. */ if (!starts_with(rm->name, "refs/tags/")) - commit = lookup_commit_in_graph(the_repository, &rm->old_oid); + commit = lookup_commit_in_graph( + the_repository, &rm->old_oid, + 0); if (!commit) { commit = lookup_commit_reference_gently(the_repository, &rm->old_oid, diff --git a/commit-graph.c b/commit-graph.c index 92d4503336..b09f454bb5 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -889,7 +889,8 @@ static int find_commit_pos_in_graph(struct commit *item, struct commit_graph *g, } } -struct commit *lookup_commit_in_graph(struct repository *repo, const struct object_id *id) +struct commit *lookup_commit_in_graph(struct repository *repo, + const struct object_id *id, int flags) { struct commit *commit; uint32_t pos; @@ -898,7 +899,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje return NULL; if (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos)) return NULL; - if (!repo_has_object_file(repo, id)) + if (!repo_has_object_file_with_flags(repo, id, flags)) return NULL; commit = lookup_commit(repo, id); diff --git a/commit-graph.h b/commit-graph.h index 2e3ac35237..747a67c0ee 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -46,7 +46,8 @@ int parse_commit_in_graph(struct repository *r, struct commit *item); * that we don't return commits whose object has been pruned. Otherwise, this * function returns `NULL`. */ -struct commit *lookup_commit_in_graph(struct repository *repo, const struct object_id *id); +struct commit *lookup_commit_in_graph(struct repository *repo, + const struct object_id *id, int flags); /* * It is possible that we loaded commit contents from the commit buffer, diff --git a/fetch-pack.c b/fetch-pack.c index cb6647d657..4a62fb182e 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -123,7 +123,7 @@ static struct commit *deref_without_lazy_fetch_extended(const struct object_id * struct object_info info = { .typep = type }; struct commit *commit; - commit = lookup_commit_in_graph(the_repository, oid); + commit = lookup_commit_in_graph(the_repository, oid, 0); if (commit) return commit; @@ -714,7 +714,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator, for (ref = *refs; ref; ref = ref->next) { struct commit *commit; - commit = lookup_commit_in_graph(the_repository, &ref->old_oid); + commit = lookup_commit_in_graph(the_repository, &ref->old_oid, 0); if (!commit) { struct object *o; diff --git a/revision.c b/revision.c index 211352795c..df5db51f98 100644 --- a/revision.c +++ b/revision.c @@ -379,7 +379,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name, * look up the object ID in those graphs. Like this, we can avoid * parsing commit data from disk. */ - commit = lookup_commit_in_graph(revs->repo, oid); + commit = lookup_commit_in_graph(revs->repo, oid, 0); if (commit) object = &commit->object; else diff --git a/upload-pack.c b/upload-pack.c index 3a851b3606..0fa9c3cf3f 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1407,7 +1407,7 @@ static int parse_want(struct packet_writer *writer, const char *line, die("git upload-pack: protocol error, " "expected to get oid, not '%s'", line); - commit = lookup_commit_in_graph(the_repository, &oid); + commit = lookup_commit_in_graph(the_repository, &oid, 0); if (commit) o = &commit->object; else @@ -1455,7 +1455,8 @@ static int parse_want_ref(struct packet_writer *writer, const char *line, item->util = oiddup(&oid); if (!starts_with(refname_nons, "refs/tags/")) { - struct commit *commit = lookup_commit_in_graph(the_repository, &oid); + struct commit *commit = + lookup_commit_in_graph(the_repository, &oid, 0); if (commit) o = &commit->object; } -- 2.36.1