Skip to content

Commit 5425771

Browse files
pks-tgitster
authored andcommitted
replay: support empty commit ranges
In a subsequent commit we're about to introduce a new user of the replay subsystem. With that new user, the range of commits that we'll want to replay will be identified implicitly via a single commit, and will include all descendants of that commit to any branch. If that commit has no descendants (because it's the tip of some branch), then the range of revisions that we're asked to replay becomes empty. This case does not make sense with git-replay(1), but with the new command it will. This case is not currently supported by `replay_revisions()` though because we zero-initialize `struct merge_result`. This includes its `.clean` member, which indicates whether the merge ran into a conflict or not. But given that we don't have any revision to replay, we won't ever perform any merge at all, and consequently that member will never be set to `1`. We thus later think that there's been a merge conflict and return an error from `replay_commits()`. Address this issue by initializing the `.clean` member to `1`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 410e378 commit 5425771

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

replay.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ int replay_revisions(struct rev_info *revs,
266266
struct commit *commit;
267267
struct commit *onto = NULL;
268268
struct merge_options merge_opt;
269-
struct merge_result result;
269+
struct merge_result result = {
270+
.clean = 1,
271+
};
270272
char *advance;
271273
int ret;
272274

@@ -282,7 +284,6 @@ int replay_revisions(struct rev_info *revs,
282284
}
283285

284286
init_basic_merge_options(&merge_opt, revs->repo);
285-
memset(&result, 0, sizeof(result));
286287
merge_opt.show_rename_progress = 0;
287288
last_commit = onto;
288289
replayed_commits = kh_init_oid_map();

0 commit comments

Comments
 (0)