Skip to content

Commit 0acb62f

Browse files
trastgitster
authored andcommitted
rebase -i: make post-rewrite work for 'edit'
The post-rewrite support, in the form of the call to 'record_in_rewritten', was hidden in the arm where we have to record a new commit for the user. This meant that it was never invoked in the case where the user has already amended the commit by herself. [The test is designed to exercise both arms of the 'if' in question.] Furthermore, recording the stopped-sha (the SHA1 of the commit before the editing) suffered from a cut&paste error from die_with_patch and used the wrong variable, hence it never recorded anything. Noticed by Junio. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent faf7526 commit 0acb62f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

git-rebase--interactive.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ do_next () {
484484
mark_action_done
485485
pick_one $sha1 ||
486486
die_with_patch $sha1 "Could not apply $sha1... $rest"
487-
echo "$1" > "$DOTEST"/stopped-sha
487+
echo "$sha1" > "$DOTEST"/stopped-sha
488488
make_patch $sha1
489489
git rev-parse --verify HEAD > "$AMEND"
490490
warn "Stopped at $sha1... $rest"
@@ -732,9 +732,10 @@ first and then run 'git rebase --continue' again."
732732
test -n "$amend" && git reset --soft $amend
733733
die "Could not commit staged changes."
734734
}
735-
record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
736735
fi
737736

737+
record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
738+
738739
require_clean_work_tree
739740
do_rest
740741
;;

t/t5407-post-rewrite-hook.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,20 @@ EOF
180180
verify_hook_input
181181
'
182182

183+
test_expect_success 'git rebase -i (double edit)' '
184+
git reset --hard D &&
185+
clear_hook_input &&
186+
FAKE_LINES="edit 1 edit 2" git rebase -i B &&
187+
git rebase --continue &&
188+
echo something > foo &&
189+
git add foo &&
190+
git rebase --continue &&
191+
echo rebase >expected.args &&
192+
cat >expected.data <<EOF &&
193+
$(git rev-parse C) $(git rev-parse HEAD^)
194+
$(git rev-parse D) $(git rev-parse HEAD)
195+
EOF
196+
verify_hook_input
197+
'
198+
183199
test_done

0 commit comments

Comments
 (0)