Make cherry-pick use rerere for conflict resolution.
Cherry-picking can be helped by reusing previous confliction resolution by invoking rerere automatically. Signed-off-by: Abhijit Menon-Sen <ams@toroid.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Abhijit Menon-Sen committed
Aug 10, 2008 at 17:18 UTC
aa1a0111cc0e2a12c21ed05c88d8e9872fc166b2
2 files changed
+47
builtin-revert.c
+2
@@ -11,6 +11,7 @@
11
#include "cache-tree.h"
12
#include "diff.h"
13
#include "revision.h"
14
+#include "rerere.h"
15
16
/*
17
* This implements the builtins revert and cherry-pick.
@@ -395,6 +396,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
396
die ("Error wrapping up %s", defmsg);
397
fprintf(stderr, "Automatic %s failed.%s\n",
398
me, help_msg(commit->object.sha1));
399
+ rerere();
400
exit(1);
401
}
402
if (commit_lock_file(&msg_file) < 0)
t/t3504-cherry-pick-rerere.sh
new
+45
@@ -0,0 +1,45 @@
1
+#!/bin/sh
2
+
3
+test_description='cherry-pick should rerere for conflicts'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success setup '
8
+ echo foo >foo &&
9
+ git add foo && test_tick && git commit -q -m 1 &&
10
+ echo foo-master >foo &&
11
+ git add foo && test_tick && git commit -q -m 2 &&
12
+
13
+ git checkout -b dev HEAD^ &&
14
+ echo foo-dev >foo &&
15
+ git add foo && test_tick && git commit -q -m 3 &&
16
+ git config rerere.enabled true
17
+'
18
+
19
+test_expect_success 'conflicting merge' '
20
+ test_must_fail git merge master
21
+'
22
+
23
+test_expect_success 'fixup' '
24
+ echo foo-dev >foo &&
25
+ git add foo && test_tick && git commit -q -m 4 &&
26
+ git reset --hard HEAD^
27
+ echo foo-dev >expect
28
+'
29
+
30
+test_expect_success 'cherry-pick conflict' '
31
+ test_must_fail git cherry-pick master &&
32
+ test_cmp expect foo
33
+'
34
+
35
+test_expect_success 'reconfigure' '
36
+ git config rerere.enabled false
37
+ git reset --hard
38
+'
39
+
40
+test_expect_success 'cherry-pick conflict without rerere' '
41
+ test_must_fail git cherry-pick master &&
42
+ test_must_fail test_cmp expect foo
43
+'
44
+
45
+test_done