]> git.ipfire.org Git - thirdparty/git.git/commitdiff
am, rebase--merge: do not overlook --skip'ed commits with post-rewrite
authorElijah Newren <newren@gmail.com>
Tue, 11 Dec 2018 16:11:35 +0000 (08:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Dec 2018 20:49:48 +0000 (12:49 -0800)
The post-rewrite hook is supposed to be invoked for each rewritten
commit.  The fact that a commit was selected and processed by the rebase
operation (even though when we hit an error a user said it had no more
useful changes), suggests we should write an entry for it.  In
particular, let's treat it as an empty commit trivially squashed into
its parent.

This brings the rebase--am and rebase--merge backends in sync with the
behavior of the interactive rebase backend.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
git-rebase--merge.sh
t/t5407-post-rewrite-hook.sh

index 8f27f3375b1e92f2ef026e0a1530ca8b6b3235bf..af9d03483839facca0e575c1f6ea10a0e8ba8222 100644 (file)
@@ -2000,6 +2000,15 @@ static void am_skip(struct am_state *state)
        if (clean_index(&head, &head))
                die(_("failed to clean index"));
 
+       if (state->rebasing) {
+               FILE *fp = xfopen(am_path(state, "rewritten"), "a");
+
+               assert(!is_null_oid(&state->orig_commit));
+               fprintf(fp, "%s ", oid_to_hex(&state->orig_commit));
+               fprintf(fp, "%s\n", oid_to_hex(&head));
+               fclose(fp);
+       }
+
        am_next(state);
        am_load(state);
        am_run(state, 0);
index aa2f2f08728edbbfd4beb28a882b744170b426ba..91250cbaed31fa27c482d129319c7e3fc9e63f39 100644 (file)
@@ -121,6 +121,8 @@ continue)
 skip)
        read_state
        git rerere clear
+       cmt="$(cat "$state_dir/cmt.$msgnum")"
+       echo "$cmt $(git rev-parse HEAD^0)" >> "$state_dir/rewritten"
        msgnum=$(($msgnum + 1))
        while test "$msgnum" -le "$end"
        do
index 6426ec89919236c5d798eeb56e06d252119097c5..a4a5903cbaee5c2a67963d8746d0252ba59bf163 100755 (executable)
@@ -78,6 +78,7 @@ test_expect_success 'git rebase --skip' '
        git rebase --continue &&
        echo rebase >expected.args &&
        cat >expected.data <<-EOF &&
+       $(git rev-parse C) $(git rev-parse HEAD^)
        $(git rev-parse D) $(git rev-parse HEAD)
        EOF
        verify_hook_input
@@ -91,6 +92,7 @@ test_expect_success 'git rebase --skip the last one' '
        echo rebase >expected.args &&
        cat >expected.data <<-EOF &&
        $(git rev-parse E) $(git rev-parse HEAD)
+       $(git rev-parse F) $(git rev-parse HEAD)
        EOF
        verify_hook_input
 '
@@ -120,6 +122,7 @@ test_expect_success 'git rebase -m --skip' '
        git rebase --continue &&
        echo rebase >expected.args &&
        cat >expected.data <<-EOF &&
+       $(git rev-parse C) $(git rev-parse HEAD^)
        $(git rev-parse D) $(git rev-parse HEAD)
        EOF
        verify_hook_input