From 25e932504096ad5cba21978a0b9a13e2708bae87 Mon Sep 17 00:00:00 2001 From: "David D. Kilzer" Date: Wed, 28 Jul 2010 01:20:16 -0700 Subject: 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 Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3418-rebase-continue.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 t/t3418-rebase-continue.sh (limited to 't/t3418-rebase-continue.sh') diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh new file mode 100755 index 0000000000..3b0d27350e --- /dev/null +++ b/t/t3418-rebase-continue.sh @@ -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 -- cgit v1.2.3 From 95135b06fe5f44f1efaeac729021a350b52652e5 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 6 Feb 2011 13:43:36 -0500 Subject: rebase: stricter check of standalone sub command The sub commands '--continue', '--skip' or '--abort' may only be used standalone according to the documentation. Other options following the sub command are currently not accepted, but options preceeding them are. For example, 'git rebase --continue -v' is not accepted, while 'git rebase -v --continue' is. Tighten up the check and allow no other options when one of these sub commands are used. Only check that it is standalone for non-interactive rebase for now. Once the command line processing for interactive rebase has been replaced by the command line processing in git-rebase.sh, this check will also apply to interactive rebase. Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- t/t3418-rebase-continue.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't/t3418-rebase-continue.sh') diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 3b0d27350e..1d90191e54 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file' git rebase --continue ' +test_expect_success 'rebase --continue can not be used with other options' ' + test_must_fail git rebase -v --continue && + test_must_fail git rebase --continue -v +' + test_done -- cgit v1.2.3 From 80ff47957b3a8ae057178a7b1113d171404e938f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 6 Feb 2011 13:43:55 -0500 Subject: rebase: remember strategy and strategy options When a rebase is resumed, interactive rebase remembers any merge strategy passed when the rebase was initated. Make non-interactive rebase remember any merge strategy as well. Also make non-interactive rebase remember any merge strategy options. To be able to resume a rebase that was initiated with an older version of git (older than this commit), make sure not to expect the saved option files to exist. Test case idea taken from Junio's 71fc224 (t3402: test "rebase -s -X", 2010-11-11). Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- t/t3418-rebase-continue.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 't/t3418-rebase-continue.sh') diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 1d90191e54..5469546c32 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -45,4 +45,33 @@ test_expect_success 'rebase --continue can not be used with other options' ' test_must_fail git rebase --continue -v ' +test_expect_success 'rebase --continue remembers merge strategy and options' ' + rm -fr .git/rebase-* && + git reset --hard commit-new-file-F2-on-topic-branch && + test_commit "commit-new-file-F3-on-topic-branch" F3 32 && + test_when_finished "rm -fr test-bin funny.was.run" && + mkdir test-bin && + cat >test-bin/git-merge-funny <<-EOF + #!$SHELL_PATH + case "\$1" in --opt) ;; *) exit 2 ;; esac + shift && + >funny.was.run && + exec git merge-recursive "\$@" + EOF + chmod +x test-bin/git-merge-funny && + ( + PATH=./test-bin:$PATH + test_must_fail git rebase -s funny -Xopt master topic + ) && + test -f funny.was.run && + rm funny.was.run && + echo "Resolved" >F2 && + git add F2 && + ( + PATH=./test-bin:$PATH + git rebase --continue + ) && + test -f funny.was.run +' + test_done -- cgit v1.2.3 From b3e4847e50cf0ab3da4ad9664a5e4382e778ebd5 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 6 Feb 2011 13:43:56 -0500 Subject: rebase -m: remember allow_rerere_autoupdate option If '--[no-]allow_rerere_autoupdate' is passed when 'git rebase -m' is called and a merge conflict occurs, the flag will be forgotten for the rest of the rebase process. Make rebase remember it by saving the value. Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- t/t3418-rebase-continue.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 't/t3418-rebase-continue.sh') diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 5469546c32..1e855cdae5 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -74,4 +74,25 @@ test_expect_success 'rebase --continue remembers merge strategy and options' ' test -f funny.was.run ' +test_expect_success 'rebase --continue remembers --rerere-autoupdate' ' + rm -fr .git/rebase-* && + git reset --hard commit-new-file-F3-on-topic-branch && + git checkout master + test_commit "commit-new-file-F3" F3 3 && + git config rerere.enabled true && + test_must_fail git rebase -m master topic && + echo "Resolved" >F2 && + git add F2 && + test_must_fail git rebase --continue && + echo "Resolved" >F3 && + git add F3 && + git rebase --continue && + git reset --hard topic@{1} && + test_must_fail git rebase -m --rerere-autoupdate master && + test "$(cat F2)" = "Resolved" && + test_must_fail git rebase --continue && + test "$(cat F3)" = "Resolved" && + git rebase --continue +' + test_done -- cgit v1.2.3