Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'cw/rebase-i-root'

Finishing touches to the "rebase -i --root" (new feature for
1.7.12).

* cw/rebase-i-root:
  rebase -i: handle fixup of root commit correctly
  • Loading branch information...
commit 7b9f29c40f52084c4e3abf7d2a4212c15aa63ae6 2 parents b00445b + 2147f84
Junio C Hamano gitster authored

Showing 2 changed files with 21 additions and 12 deletions. Show diff stats Hide diff stats

  1. +13 12 git-rebase--interactive.sh
  2. +8 0 t/t3404-rebase-interactive.sh
25 git-rebase--interactive.sh
@@ -493,25 +493,28 @@ do_next () {
493 493 author_script_content=$(get_author_ident_from_commit HEAD)
494 494 echo "$author_script_content" > "$author_script"
495 495 eval "$author_script_content"
496   - output git reset --soft HEAD^
497   - pick_one -n $sha1 || die_failed_squash $sha1 "$rest"
  496 + if ! pick_one -n $sha1
  497 + then
  498 + git rev-parse --verify HEAD >"$amend"
  499 + die_failed_squash $sha1 "$rest"
  500 + fi
498 501 case "$(peek_next_command)" in
499 502 squash|s|fixup|f)
500 503 # This is an intermediate commit; its message will only be
501 504 # used in case of trouble. So use the long version:
502   - do_with_author output git commit --no-verify -F "$squash_msg" ||
  505 + do_with_author output git commit --amend --no-verify -F "$squash_msg" ||
503 506 die_failed_squash $sha1 "$rest"
504 507 ;;
505 508 *)
506 509 # This is the final command of this squash/fixup group
507 510 if test -f "$fixup_msg"
508 511 then
509   - do_with_author git commit --no-verify -F "$fixup_msg" ||
  512 + do_with_author git commit --amend --no-verify -F "$fixup_msg" ||
510 513 die_failed_squash $sha1 "$rest"
511 514 else
512 515 cp "$squash_msg" "$GIT_DIR"/SQUASH_MSG || exit
513 516 rm -f "$GIT_DIR"/MERGE_MSG
514   - do_with_author git commit --no-verify -e ||
  517 + do_with_author git commit --amend --no-verify -F "$GIT_DIR"/SQUASH_MSG -e ||
515 518 die_failed_squash $sha1 "$rest"
516 519 fi
517 520 rm -f "$squash_msg" "$fixup_msg"
@@ -748,7 +751,6 @@ In both case, once you're done, continue with:
748 751 fi
749 752 . "$author_script" ||
750 753 die "Error trying to find the author identity to amend commit"
751   - current_head=
752 754 if test -f "$amend"
753 755 then
754 756 current_head=$(git rev-parse --verify HEAD)
@@ -756,13 +758,12 @@ In both case, once you're done, continue with:
756 758 die "\
757 759 You have uncommitted changes in your working tree. Please, commit them
758 760 first and then run 'git rebase --continue' again."
759   - git reset --soft HEAD^ ||
760   - die "Cannot rewind the HEAD"
  761 + do_with_author git commit --amend --no-verify -F "$msg" -e ||
  762 + die "Could not commit staged changes."
  763 + else
  764 + do_with_author git commit --no-verify -F "$msg" -e ||
  765 + die "Could not commit staged changes."
761 766 fi
762   - do_with_author git commit --no-verify -F "$msg" -e || {
763   - test -n "$current_head" && git reset --soft $current_head
764   - die "Could not commit staged changes."
765   - }
766 767 fi
767 768
768 769 record_in_rewritten "$(cat "$state_dir"/stopped-sha)"
8 t/t3404-rebase-interactive.sh
@@ -903,4 +903,12 @@ test_expect_success 'rebase -i --root temporary sentinel commit' '
903 903 git rebase --abort
904 904 '
905 905
  906 +test_expect_success 'rebase -i --root fixup root commit' '
  907 + git checkout B &&
  908 + FAKE_LINES="1 fixup 2" git rebase -i --root &&
  909 + test A = $(git cat-file commit HEAD | sed -ne \$p) &&
  910 + test B = $(git show HEAD:file1) &&
  911 + test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
  912 +'
  913 +
906 914 test_done

0 comments on commit 7b9f29c

Please sign in to comment.
Something went wrong with that request. Please try again.