Skip to content

Commit 8d8cb4b

Browse files
phillipwoodgitster
authored andcommitted
cherry-pick/revert: remember --rerere-autoupdate
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6f0e577 commit 8d8cb4b

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

sequencer.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,11 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
14391439
else if (!strcmp(key, "options.strategy-option")) {
14401440
ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
14411441
opts->xopts[opts->xopts_nr++] = xstrdup(value);
1442-
} else
1442+
} else if (!strcmp(key, "options.allow-rerere-auto"))
1443+
opts->allow_rerere_auto =
1444+
git_config_bool_or_int(key, value, &error_flag) ?
1445+
RERERE_AUTOUPDATE : RERERE_NOAUTOUPDATE;
1446+
else
14431447
return error(_("invalid key: %s"), key);
14441448

14451449
if (!error_flag)
@@ -1752,6 +1756,10 @@ static int save_opts(struct replay_opts *opts)
17521756
"options.strategy-option",
17531757
opts->xopts[i], "^$", 0);
17541758
}
1759+
if (opts->allow_rerere_auto)
1760+
res |= git_config_set_in_file_gently(opts_file, "options.allow-rerere-auto",
1761+
opts->allow_rerere_auto == RERERE_AUTOUPDATE ?
1762+
"true" : "false");
17551763
return res;
17561764
}
17571765

t/t3504-cherry-pick-rerere.sh

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ test_description='cherry-pick should rerere for conflicts'
77
test_expect_success setup '
88
test_commit foo &&
99
test_commit foo-master foo &&
10+
test_commit bar-master bar &&
1011
1112
git checkout -b dev foo &&
1213
test_commit foo-dev foo &&
14+
test_commit bar-dev bar &&
1315
git config rerere.enabled true
1416
'
1517

@@ -19,22 +21,66 @@ test_expect_success 'conflicting merge' '
1921

2022
test_expect_success 'fixup' '
2123
echo foo-resolved >foo &&
24+
echo bar-resolved >bar &&
2225
git commit -am resolved &&
23-
cp foo expect &&
26+
cp foo foo-expect &&
27+
cp bar bar-expect &&
2428
git reset --hard HEAD^
2529
'
2630

27-
test_expect_success 'cherry-pick conflict' '
28-
test_must_fail git cherry-pick master &&
29-
test_cmp expect foo
31+
test_expect_success 'cherry-pick conflict with --rerere-autoupdate' '
32+
test_must_fail git cherry-pick --rerere-autoupdate foo..bar-master &&
33+
test_cmp foo-expect foo &&
34+
git diff-files --quiet &&
35+
test_must_fail git cherry-pick --continue &&
36+
test_cmp bar-expect bar &&
37+
git diff-files --quiet &&
38+
git cherry-pick --continue &&
39+
git reset --hard bar-dev
40+
'
41+
42+
test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' '
43+
test_config rerere.autoUpdate true &&
44+
test_must_fail git cherry-pick foo..bar-master &&
45+
test_cmp foo-expect foo &&
46+
git diff-files --quiet &&
47+
test_must_fail git cherry-pick --continue &&
48+
test_cmp bar-expect bar &&
49+
git diff-files --quiet &&
50+
git cherry-pick --continue &&
51+
git reset --hard bar-dev
52+
'
53+
54+
test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' '
55+
test_config rerere.autoUpdate true &&
56+
test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-master &&
57+
test_cmp foo-expect foo &&
58+
test_must_fail git diff-files --quiet &&
59+
git add foo &&
60+
test_must_fail git cherry-pick --continue &&
61+
test_cmp bar-expect bar &&
62+
test_must_fail git diff-files --quiet &&
63+
git add bar &&
64+
git cherry-pick --continue &&
65+
git reset --hard bar-dev
3066
'
3167

32-
test_expect_success 'reconfigure' '
33-
git config rerere.enabled false &&
34-
git reset --hard
68+
test_expect_success 'cherry-pick --rerere-autoupdate more than once' '
69+
test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-master &&
70+
test_cmp foo-expect foo &&
71+
git diff-files --quiet &&
72+
git cherry-pick --abort &&
73+
test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-master &&
74+
test_cmp foo-expect foo &&
75+
git diff-files --quiet &&
76+
git cherry-pick --abort &&
77+
test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-master &&
78+
test_must_fail git diff-files --quiet &&
79+
git cherry-pick --abort
3580
'
3681

3782
test_expect_success 'cherry-pick conflict without rerere' '
83+
test_config rerere.enabled false &&
3884
test_must_fail git cherry-pick master &&
3985
test_must_fail test_cmp expect foo
4086
'

0 commit comments

Comments
 (0)