@matheusbsbs / matheus-bagliano / commits / ea3f7e598c
Fork 0

revision: use repository from rev_info when parsing commits

This is needed when repo_init_revisions() is called with a repository that is not the_repository to ensure appropriate repository is used in repo_parse_commit_internal(). If the wrong repository is used, a fatal error is the commit-graph machinery occurs: fatal: invalid commit position. commit-graph is likely corrupt Since revision.c was the only user of the parse_commit_gently compatibility define, remove it from commit.h. Signed-off-by: Michael Forney <mforney@mforney.org> Acked-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Forney committed Jun 23, 2020 at 13:56 UTC ea3f7e598c8f1171f0bd02da777dc526cdb8424d
2 files changed +9 -10
commit.h
-1
@@ -97,7 +97,6 @@ static inline int parse_commit_no_graph(struct commit *commit)
97
98 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
99 #define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)
100 -#define parse_commit_gently(item, quiet) repo_parse_commit_gently(the_repository, item, quiet)
100 #define parse_commit(item) repo_parse_commit(the_repository, item)
101 #endif
102
revision.c
+9 -9
@@ -435,7 +435,7 @@ static struct commit *handle_commit(struct rev_info *revs,
435 if (object->type == OBJ_COMMIT) {
436 struct commit *commit = (struct commit *)object;
437
438 - if (parse_commit(commit) < 0)
438 + if (repo_parse_commit(revs->repo, commit) < 0)
439 die("unable to parse commit %s", name);
440 if (flags & UNINTERESTING) {
441 mark_parents_uninteresting(commit);
@@ -851,7 +851,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
851 ts->treesame[0] = 1;
852 }
853 }
854 - if (parse_commit(p) < 0)
854 + if (repo_parse_commit(revs->repo, p) < 0)
855 die("cannot simplify commit %s (because of %s)",
856 oid_to_hex(&commit->object.oid),
857 oid_to_hex(&p->object.oid));
@@ -884,7 +884,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
884 * IOW, we pretend this parent is a
885 * "root" commit.
886 */
887 - if (parse_commit(p) < 0)
887 + if (repo_parse_commit(revs->repo, p) < 0)
888 die("cannot simplify commit %s (invalid %s)",
889 oid_to_hex(&commit->object.oid),
890 oid_to_hex(&p->object.oid));
@@ -948,7 +948,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
948 parent = parent->next;
949 if (p)
950 p->object.flags |= UNINTERESTING;
951 - if (parse_commit_gently(p, 1) < 0)
951 + if (repo_parse_commit_gently(revs->repo, p, 1) < 0)
952 continue;
953 if (p->parents)
954 mark_parents_uninteresting(p);
@@ -979,7 +979,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
979 struct commit *p = parent->item;
980 int gently = revs->ignore_missing_links ||
981 revs->exclude_promisor_objects;
982 - if (parse_commit_gently(p, gently) < 0) {
982 + if (repo_parse_commit_gently(revs->repo, p, gently) < 0) {
983 if (revs->exclude_promisor_objects &&
984 is_promisor_object(&p->object.oid)) {
985 if (revs->first_parent_only)
@@ -3130,7 +3130,7 @@ static void explore_walk_step(struct rev_info *revs)
3130 if (!c)
3131 return;
3132
3133 - if (parse_commit_gently(c, 1) < 0)
3133 + if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
3134 return;
3135
3136 if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
@@ -3168,7 +3168,7 @@ static void indegree_walk_step(struct rev_info *revs)
3168 if (!c)
3169 return;
3170
3171 - if (parse_commit_gently(c, 1) < 0)
3171 + if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
3172 return;
3173
3174 explore_to_depth(revs, c->generation);
@@ -3249,7 +3249,7 @@ static void init_topo_walk(struct rev_info *revs)
3249 for (list = revs->commits; list; list = list->next) {
3250 struct commit *c = list->item;
3251
3252 - if (parse_commit_gently(c, 1))
3252 + if (repo_parse_commit_gently(revs->repo, c, 1))
3253 continue;
3254
3255 test_flag_and_insert(&info->explore_queue, c, TOPO_WALK_EXPLORED);
@@ -3311,7 +3311,7 @@ static void expand_topo_walk(struct rev_info *revs, struct commit *commit)
3311 if (parent->object.flags & UNINTERESTING)
3312 continue;
3313
3314 - if (parse_commit_gently(parent, 1) < 0)
3314 + if (repo_parse_commit_gently(revs->repo, parent, 1) < 0)
3315 continue;
3316
3317 if (parent->generation < info->min_generation) {