@matheusbsbs / matheus-bagliano / commits / 25e9325040
Fork 0

Fix git rebase --continue to work with touched files

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>

David D. Kilzer committed Jul 28, 2010 at 01:20 UTC 25e932504096ad5cba21978a0b9a13e2708bae87
2 files changed +44
git-rebase.sh
+1
@@ -208,6 +208,7 @@ do
208 test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
209 die "No rebase in progress?"
210
211 + git update-index --ignore-submodules --refresh &&
212 git diff-files --quiet --ignore-submodules || {
213 echo "You must edit all merge conflicts and then"
214 echo "mark them as resolved using git add"
t/t3418-rebase-continue.sh new
+43
@@ -0,0 +1,43 @@
1 +#!/bin/sh
2 +
3 +test_description='git rebase --continue tests'
4 +
5 +. ./test-lib.sh
6 +
7 +. "$TEST_DIRECTORY"/lib-rebase.sh
8 +
9 +set_fake_editor
10 +
11 +test_expect_success 'setup' '
12 + test_commit "commit-new-file-F1" F1 1 &&
13 + test_commit "commit-new-file-F2" F2 2 &&
14 +
15 + git checkout -b topic HEAD^ &&
16 + test_commit "commit-new-file-F2-on-topic-branch" F2 22 &&
17 +
18 + git checkout master
19 +'
20 +
21 +test_expect_success 'interactive rebase --continue works with touched file' '
22 + rm -fr .git/rebase-* &&
23 + git reset --hard &&
24 + git checkout master &&
25 +
26 + FAKE_LINES="edit 1" git rebase -i HEAD^ &&
27 + test-chmtime =-60 F1 &&
28 + git rebase --continue
29 +'
30 +
31 +test_expect_success 'non-interactive rebase --continue works with touched file' '
32 + rm -fr .git/rebase-* &&
33 + git reset --hard &&
34 + git checkout master &&
35 +
36 + test_must_fail git rebase --onto master master topic &&
37 + echo "Resolved" >F2 &&
38 + git add F2 &&
39 + test-chmtime =-60 F1 &&
40 + git rebase --continue
41 +'
42 +
43 +test_done