Skip to content

Commit a6754cd

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b1bcfbe commit a6754cd

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

git-rebase--interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ rearrange_squash () {
672672
case "$action" in
673673
continue)
674674
# do we have anything to commit?
675-
if git diff-index --cached --quiet --ignore-submodules HEAD --
675+
if git diff-index --cached --quiet HEAD --
676676
then
677677
: Nothing to commit -- skip this
678678
else

t/t3404-rebase-interactive.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,38 @@ test_expect_success 'submodule rebase -i' '
624624
FAKE_LINES="1 squash 2 3" git rebase -i A
625625
'
626626

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+
627656
test_expect_success 'avoid unnecessary reset' '
628657
git checkout master &&
658+
git reset --hard &&
629659
test-chmtime =123456789 file3 &&
630660
git update-index --refresh &&
631661
HEAD=$(git rev-parse HEAD) &&

0 commit comments

Comments
 (0)