@matheusbsbs / matheus-bagliano / commits / 0acb62f202
Fork 0

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 <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Mar 28, 2010 at 21:36 UTC 0acb62f202617cc58b6b4039dc9c7ad955ef0c88
2 files changed +19 -2
git-rebase--interactive.sh
+3 -2
@@ -484,7 +484,7 @@ do_next () {
484 mark_action_done
485 pick_one $sha1 ||
486 die_with_patch $sha1 "Could not apply $sha1... $rest"
487 - echo "$1" > "$DOTEST"/stopped-sha
487 + echo "$sha1" > "$DOTEST"/stopped-sha
488 make_patch $sha1
489 git rev-parse --verify HEAD > "$AMEND"
490 warn "Stopped at $sha1... $rest"
@@ -732,9 +732,10 @@ first and then run 'git rebase --continue' again."
732 test -n "$amend" && git reset --soft $amend
733 die "Could not commit staged changes."
734 }
735 - record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
735 fi
736
737 + record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
738 +
739 require_clean_work_tree
740 do_rest
741 ;;
t/t5407-post-rewrite-hook.sh
+16
@@ -180,4 +180,20 @@ EOF
180 verify_hook_input
181 '
182
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 +
199 test_done