[PATCH 2/6] rebase: honor --rerere-autoupdate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>

Rebase accepts '--rerere-autoupdate' as an option but only honors it
if '-m' is also given. Fix it for a non-interactive rebase by passing
on the option to 'git am' and 'git cherry-pick'. Rework the tests so
that they can be used for each rebase flavor and extend them.

Reported-by: Junio C Hamano <gitster@xxxxxxxxx>
Signed-off-by: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
---
 git-rebase--am.sh          |  3 +-
 t/t3418-rebase-continue.sh | 82 +++++++++++++++++++++++++++++++---------------
 2 files changed, 57 insertions(+), 28 deletions(-)

diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 375239341fbfe885e51a25e9e0dc2d4fee791345..319933e70a34f9da4ec93d063eb102eff33b6787 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -45,7 +45,7 @@ then
 	# itself well to recording empty patches.  fortunately, cherry-pick
 	# makes this easy
 	git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
-		--right-only "$revisions" \
+		$allow_rerere_autoupdate --right-only "$revisions" \
 		${restrict_revision+^$restrict_revision}
 	ret=$?
 else
@@ -82,6 +82,7 @@ else
 	fi
 
 	git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
+		$allow_rerere_autoupdate \
 		${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
 	ret=$?
 
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
index 4428b9086e8bcb383df801834d0de323f316f4fa..2b746f1559ad21a5ebf3bebd726c9a1b3d071c5a 100755
--- a/t/t3418-rebase-continue.sh
+++ b/t/t3418-rebase-continue.sh
@@ -40,25 +40,6 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
 	git rebase --continue
 '
 
-test_expect_success 'non-interactive rebase --continue with rerere enabled' '
-	test_config rerere.enabled true &&
-	test_when_finished "test_might_fail git rebase --abort" &&
-	git reset --hard commit-new-file-F2-on-topic-branch &&
-	git checkout master &&
-	rm -fr .git/rebase-* &&
-
-	test_must_fail git rebase --onto master master topic &&
-	echo "Resolved" >F2 &&
-	git add F2 &&
-	cp F2 F2.expected &&
-	git rebase --continue &&
-
-	git reset --hard commit-new-file-F2-on-topic-branch &&
-	git checkout master &&
-	test_must_fail git rebase --onto master master topic &&
-	test_cmp F2.expected F2
-'
-
 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
@@ -93,25 +74,72 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
 	test -f funny.was.run
 '
 
-test_expect_success 'rebase --continue remembers --rerere-autoupdate' '
+test_expect_success 'setup rerere database' '
 	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_config rerere.enabled true &&
 	test_must_fail git rebase -m master topic &&
 	echo "Resolved" >F2 &&
+	cp F2 expected-F2 &&
 	git add F2 &&
 	test_must_fail git rebase --continue &&
 	echo "Resolved" >F3 &&
+	cp F3 expected-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
+	git reset --hard topic@{1}
 '
 
+prepare () {
+	rm -fr .git/rebase-* &&
+	git reset --hard commit-new-file-F3-on-topic-branch &&
+	git checkout master &&
+	test_config rerere.enabled true
+}
+
+test_rerere_autoupdate () {
+	action=$1 &&
+	test_expect_success "rebase $action --continue remembers --rerere-autoupdate" '
+		prepare &&
+		test_must_fail git rebase $action --rerere-autoupdate master topic &&
+		test_cmp expected-F2 F2 &&
+		git diff-files --quiet &&
+		test_must_fail git rebase --continue &&
+		test_cmp expected-F3 F3 &&
+		git diff-files --quiet &&
+		git rebase --continue
+	'
+
+	test_expect_success "rebase $action --continue honors rerere.autoUpdate" '
+		prepare &&
+		test_config rerere.autoupdate true &&
+		test_must_fail git rebase $action master topic &&
+		test_cmp expected-F2 F2 &&
+		git diff-files --quiet &&
+		test_must_fail git rebase --continue &&
+		test_cmp expected-F3 F3 &&
+		git diff-files --quiet &&
+		git rebase --continue
+	'
+
+	test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" '
+		prepare &&
+		test_config rerere.autoupdate true &&
+		test_must_fail git rebase $action --no-rerere-autoupdate master topic &&
+		test_cmp expected-F2 F2 &&
+		test_must_fail git diff-files --quiet &&
+		git add F2 &&
+		test_must_fail git rebase --continue &&
+		test_cmp expected-F3 F3 &&
+		test_must_fail git diff-files --quiet &&
+		git add F3 &&
+		git rebase --continue
+	'
+}
+
+test_rerere_autoupdate
+test_rerere_autoupdate -m
+
 test_done
-- 
2.13.3




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux