Skip to content

Commit

Permalink
Fix git rebase --continue to work with touched files
Browse files Browse the repository at this point in the history
When performing a non-interactive rebase, sometimes
"git rebase --continue" will fail if an unmodified file is
touched in the working directory:

    You must edit all merge conflicts and then
    mark them as resolved using git add

This is caused by "git diff-files" reporting a difference
between the index and the filesystem:

    :100644 100644 d00491...... 000000...... M	file

The fix is to run "git update-index --refresh" before
"git diff-files" as is done in git-rebase--interactive.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David D. Kilzer authored and Junio C Hamano committed Jul 28, 2010
1 parent 5bc0e24 commit 25e9325
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ do
test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
die "No rebase in progress?"

git update-index --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules || {
echo "You must edit all merge conflicts and then"
echo "mark them as resolved using git add"
Expand Down
43 changes: 43 additions & 0 deletions t/t3418-rebase-continue.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

test_description='git rebase --continue tests'

. ./test-lib.sh

. "$TEST_DIRECTORY"/lib-rebase.sh

set_fake_editor

test_expect_success 'setup' '
test_commit "commit-new-file-F1" F1 1 &&
test_commit "commit-new-file-F2" F2 2 &&
git checkout -b topic HEAD^ &&
test_commit "commit-new-file-F2-on-topic-branch" F2 22 &&
git checkout master
'

test_expect_success 'interactive rebase --continue works with touched file' '
rm -fr .git/rebase-* &&
git reset --hard &&
git checkout master &&
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
test-chmtime =-60 F1 &&
git rebase --continue
'

test_expect_success 'non-interactive rebase --continue works with touched file' '
rm -fr .git/rebase-* &&
git reset --hard &&
git checkout master &&
test_must_fail git rebase --onto master master topic &&
echo "Resolved" >F2 &&
git add F2 &&
test-chmtime =-60 F1 &&
git rebase --continue
'

test_done

0 comments on commit 25e9325

Please sign in to comment.