]> git.ipfire.org Git - thirdparty/git.git/commitdiff
replay: support empty commit ranges
authorPatrick Steinhardt <ps@pks.im>
Tue, 13 Jan 2026 09:54:35 +0000 (10:54 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Jan 2026 13:41:16 +0000 (05:41 -0800)
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>
replay.c

index ae13b59abced70de33a5859384d9876a2825ade7..6680d50bd7cfcde4338002f08b9e94bcb0fae741 100644 (file)
--- a/replay.c
+++ b/replay.c
@@ -266,7 +266,9 @@ int replay_revisions(struct rev_info *revs,
        struct commit *commit;
        struct commit *onto = NULL;
        struct merge_options merge_opt;
-       struct merge_result result;
+       struct merge_result result = {
+               .clean = 1,
+       };
        char *advance;
        int ret;
 
@@ -282,7 +284,6 @@ int replay_revisions(struct rev_info *revs,
        }
 
        init_basic_merge_options(&merge_opt, revs->repo);
-       memset(&result, 0, sizeof(result));
        merge_opt.show_rename_progress = 0;
        last_commit = onto;
        replayed_commits = kh_init_oid_map();