rebase -i continue: don't skip commits that only change submodules

When git-rebase--interactive stops due to a conflict and the only change to be committed is in a submodule, the test for whether there is anything to be committed ignores the staged submodule change. This leads rebase to skip creating the commit for the change. While unstaged submodule changes should be ignored to avoid needing to update submodules during a rebase, it is safe to remove the --ignore-submodules option to diff-index because --cached ensures that it is only checking the index. This was discussed in [1] and a test is included to ensure that unstaged changes are still ignored correctly. [1] http://thread.gmane.org/gmane.comp.version-control.git/188713 Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Keeping committed Apr 7, 2012 at 11:20 UTC a6754cda4362d129738d42d2683d07d433379e99
2 files changed +31 -1
git-rebase--interactive.sh
+1 -1
@@ -672,7 +672,7 @@ rearrange_squash () {
672 case "$action" in
673 continue)
674 # do we have anything to commit?
675 - if git diff-index --cached --quiet --ignore-submodules HEAD --
675 + if git diff-index --cached --quiet HEAD --
676 then
677 : Nothing to commit -- skip this
678 else
t/t3404-rebase-interactive.sh
+30
@@ -624,8 +624,38 @@ test_expect_success 'submodule rebase -i' '
624 FAKE_LINES="1 squash 2 3" git rebase -i A
625 '
626
627 +test_expect_success 'submodule conflict setup' '
628 + git tag submodule-base &&
629 + git checkout HEAD^ &&
630 + (
631 + cd sub && git checkout HEAD^ && echo 4 >elif &&
632 + git add elif && git commit -m "submodule conflict"
633 + ) &&
634 + git add sub &&
635 + test_tick &&
636 + git commit -m "Conflict in submodule" &&
637 + git tag submodule-topic
638 +'
639 +
640 +test_expect_success 'rebase -i continue with only submodule staged' '
641 + test_must_fail git rebase -i submodule-base &&
642 + git add sub &&
643 + git rebase --continue &&
644 + test $(git rev-parse submodule-base) != $(git rev-parse HEAD)
645 +'
646 +
647 +test_expect_success 'rebase -i continue with unstaged submodule' '
648 + git checkout submodule-topic &&
649 + git reset --hard &&
650 + test_must_fail git rebase -i submodule-base &&
651 + git reset &&
652 + git rebase --continue &&
653 + test $(git rev-parse submodule-base) = $(git rev-parse HEAD)
654 +'
655 +
656 test_expect_success 'avoid unnecessary reset' '
657 git checkout master &&
658 + git reset --hard &&
659 test-chmtime =123456789 file3 &&
660 git update-index --refresh &&
661 HEAD=$(git rev-parse HEAD) &&