git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood@talktalk.net>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH 5/6] cherry-pick/revert: remember --rerere-autoupdate
Date: Wed,  2 Aug 2017 11:44:19 +0100	[thread overview]
Message-ID: <20170802104420.12809-6-phillip.wood@talktalk.net> (raw)
In-Reply-To: <20170802104420.12809-1-phillip.wood@talktalk.net>

From: Phillip Wood <phillip.wood@dunelm.org.uk>

When continuing after conflicts, cherry-pick forgot if the user had specified
'--rerere-autoupdate'.

Redo the cherry-pick rerere tests to check --rerere-autoupdate works
as expected.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 sequencer.c                   | 10 +++++++-
 t/t3504-cherry-pick-rerere.sh | 60 ++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 7dc0670d902291b8054072d32cc0c8979c13598c..e0e66b987b27072da4aea6304a565ab708be91e4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1439,7 +1439,11 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
 	else if (!strcmp(key, "options.strategy-option")) {
 		ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
 		opts->xopts[opts->xopts_nr++] = xstrdup(value);
-	} else
+	} else if (!strcmp(key, "options.allow-rerere-auto"))
+		opts->allow_rerere_auto =
+			git_config_bool_or_int(key, value, &error_flag) ?
+				RERERE_AUTOUPDATE : RERERE_NOAUTOUPDATE;
+	else
 		return error(_("invalid key: %s"), key);
 
 	if (!error_flag)
@@ -1752,6 +1756,10 @@ static int save_opts(struct replay_opts *opts)
 							"options.strategy-option",
 							opts->xopts[i], "^$", 0);
 	}
+	if (opts->allow_rerere_auto)
+		res |= git_config_set_in_file_gently(opts_file, "options.allow-rerere-auto",
+						     opts->allow_rerere_auto == RERERE_AUTOUPDATE ?
+						     "true" : "false");
 	return res;
 }
 
diff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh
index 33f902b1b0d8eb651e0e6857f8f5b86ef633ef4a..af316cb40b7b16c95881eb8483eea4f6191c7cfa 100755
--- a/t/t3504-cherry-pick-rerere.sh
+++ b/t/t3504-cherry-pick-rerere.sh
@@ -7,9 +7,11 @@ test_description='cherry-pick should rerere for conflicts'
 test_expect_success setup '
 	test_commit foo &&
 	test_commit foo-master foo &&
+	test_commit bar-master bar &&
 
 	git checkout -b dev foo &&
 	test_commit foo-dev foo &&
+	test_commit bar-dev bar &&
 	git config rerere.enabled true
 '
 
@@ -19,22 +21,66 @@ test_expect_success 'conflicting merge' '
 
 test_expect_success 'fixup' '
 	echo foo-resolved >foo &&
+	echo bar-resolved >bar &&
 	git commit -am resolved &&
-	cp foo expect &&
+	cp foo foo-expect &&
+	cp bar bar-expect &&
 	git reset --hard HEAD^
 '
 
-test_expect_success 'cherry-pick conflict' '
-	test_must_fail git cherry-pick master &&
-	test_cmp expect foo
+test_expect_success 'cherry-pick conflict with --rerere-autoupdate' '
+	test_must_fail git cherry-pick --rerere-autoupdate foo..bar-master &&
+	test_cmp foo-expect foo &&
+	git diff-files --quiet &&
+	test_must_fail git cherry-pick --continue &&
+	test_cmp bar-expect bar &&
+	git diff-files --quiet &&
+	git cherry-pick --continue &&
+	git reset --hard bar-dev
 '
 
-test_expect_success 'reconfigure' '
-	git config rerere.enabled false &&
-	git reset --hard
+test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' '
+	test_config rerere.autoUpdate true &&
+	test_must_fail git cherry-pick foo..bar-master &&
+	test_cmp foo-expect foo &&
+	git diff-files --quiet &&
+	test_must_fail git cherry-pick --continue &&
+	test_cmp bar-expect bar &&
+	git diff-files --quiet &&
+	git cherry-pick --continue &&
+	git reset --hard bar-dev
+'
+
+test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' '
+	test_config rerere.autoUpdate true &&
+	test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-master &&
+	test_cmp foo-expect foo &&
+	test_must_fail git diff-files --quiet &&
+	git add foo &&
+	test_must_fail git cherry-pick --continue &&
+	test_cmp bar-expect bar &&
+	test_must_fail git diff-files --quiet &&
+	git add bar &&
+	git cherry-pick --continue &&
+	git reset --hard bar-dev
+'
+
+test_expect_success 'cherry-pick --rerere-autoupdate more than once' '
+	test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-master &&
+	test_cmp foo-expect foo &&
+	git diff-files --quiet &&
+	git cherry-pick --abort &&
+	test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-master &&
+	test_cmp foo-expect foo &&
+	git diff-files --quiet &&
+	git cherry-pick --abort &&
+	test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-master &&
+	test_must_fail git diff-files --quiet &&
+	git cherry-pick --abort
 '
 
 test_expect_success 'cherry-pick conflict without rerere' '
+	test_config rerere.enabled false &&
 	test_must_fail git cherry-pick master &&
 	test_must_fail test_cmp expect foo
 '
-- 
2.13.3


  parent reply	other threads:[~2017-08-02 10:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 10:44 [PATCH 0/6] am/cherry-pick/rebase/revert --rerere-autoupdate fixes Phillip Wood
2017-08-02 10:44 ` [PATCH 1/6] am: remember --rerere-autoupdate setting Phillip Wood
2017-08-02 10:44 ` [PATCH 2/6] rebase: honor --rerere-autoupdate Phillip Wood
2017-08-02 10:44 ` [PATCH 3/6] rebase -i: " Phillip Wood
2017-08-02 10:44 ` [PATCH 4/6] t3504: use test_commit Phillip Wood
2017-08-02 10:44 ` Phillip Wood [this message]
2017-08-02 10:44 ` [PATCH 6/6] cherry-pick/revert: reject --rerere-autoupdate when continuing Phillip Wood
2017-08-02 21:57   ` Junio C Hamano
2017-08-02 22:29     ` Junio C Hamano
2017-08-03 10:15       ` Phillip Wood
2017-08-03 17:19         ` Junio C Hamano
2017-08-07 10:17           ` Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170802104420.12809-6-phillip.wood@talktalk.net \
    --to=phillip.wood@talktalk.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).