Skip to content

Commit ea3f7e5

Browse files
michaelforneygitster
authored andcommitted
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 <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit ea3f7e5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

commit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ static inline int parse_commit_no_graph(struct commit *commit)
9797

9898
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
9999
#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)
101100
#define parse_commit(item) repo_parse_commit(the_repository, item)
102101
#endif
103102

revision.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static struct commit *handle_commit(struct rev_info *revs,
435435
if (object->type == OBJ_COMMIT) {
436436
struct commit *commit = (struct commit *)object;
437437

438-
if (parse_commit(commit) < 0)
438+
if (repo_parse_commit(revs->repo, commit) < 0)
439439
die("unable to parse commit %s", name);
440440
if (flags & UNINTERESTING) {
441441
mark_parents_uninteresting(commit);
@@ -851,7 +851,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
851851
ts->treesame[0] = 1;
852852
}
853853
}
854-
if (parse_commit(p) < 0)
854+
if (repo_parse_commit(revs->repo, p) < 0)
855855
die("cannot simplify commit %s (because of %s)",
856856
oid_to_hex(&commit->object.oid),
857857
oid_to_hex(&p->object.oid));
@@ -884,7 +884,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
884884
* IOW, we pretend this parent is a
885885
* "root" commit.
886886
*/
887-
if (parse_commit(p) < 0)
887+
if (repo_parse_commit(revs->repo, p) < 0)
888888
die("cannot simplify commit %s (invalid %s)",
889889
oid_to_hex(&commit->object.oid),
890890
oid_to_hex(&p->object.oid));
@@ -948,7 +948,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
948948
parent = parent->next;
949949
if (p)
950950
p->object.flags |= UNINTERESTING;
951-
if (parse_commit_gently(p, 1) < 0)
951+
if (repo_parse_commit_gently(revs->repo, p, 1) < 0)
952952
continue;
953953
if (p->parents)
954954
mark_parents_uninteresting(p);
@@ -979,7 +979,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
979979
struct commit *p = parent->item;
980980
int gently = revs->ignore_missing_links ||
981981
revs->exclude_promisor_objects;
982-
if (parse_commit_gently(p, gently) < 0) {
982+
if (repo_parse_commit_gently(revs->repo, p, gently) < 0) {
983983
if (revs->exclude_promisor_objects &&
984984
is_promisor_object(&p->object.oid)) {
985985
if (revs->first_parent_only)
@@ -3130,7 +3130,7 @@ static void explore_walk_step(struct rev_info *revs)
31303130
if (!c)
31313131
return;
31323132

3133-
if (parse_commit_gently(c, 1) < 0)
3133+
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
31343134
return;
31353135

31363136
if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
@@ -3168,7 +3168,7 @@ static void indegree_walk_step(struct rev_info *revs)
31683168
if (!c)
31693169
return;
31703170

3171-
if (parse_commit_gently(c, 1) < 0)
3171+
if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
31723172
return;
31733173

31743174
explore_to_depth(revs, c->generation);
@@ -3249,7 +3249,7 @@ static void init_topo_walk(struct rev_info *revs)
32493249
for (list = revs->commits; list; list = list->next) {
32503250
struct commit *c = list->item;
32513251

3252-
if (parse_commit_gently(c, 1))
3252+
if (repo_parse_commit_gently(revs->repo, c, 1))
32533253
continue;
32543254

32553255
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)
33113311
if (parent->object.flags & UNINTERESTING)
33123312
continue;
33133313

3314-
if (parse_commit_gently(parent, 1) < 0)
3314+
if (repo_parse_commit_gently(revs->repo, parent, 1) < 0)
33153315
continue;
33163316

33173317
if (parent->generation < info->min_generation) {

0 commit comments

Comments
 (0)