apply: allow rerere() to work on --3way results
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 10, 2012 at 13:56 UTC
f2633ebd766b7f5817ae0ec69060170bb9b1501f
2 files changed
+28
builtin/apply.c
+3
@@ -18,6 +18,7 @@
18
#include "parse-options.h"
19
#include "xdiff-interface.h"
20
#include "ll-merge.h"
21
+#include "rerere.h"
22
23
/*
24
* --check turns on checking that the working tree matches the
@@ -4026,6 +4027,8 @@ static int write_out_results(struct patch *list)
4027
for_each_string_list_item(item, &cpath)
4028
fprintf(stderr, "U %s\n", item->string);
4029
string_list_clear(&cpath, 0);
4030
+
4031
+ rerere(0);
4032
}
4033
4034
return errs;
t/t4108-apply-threeway.sh
+25
@@ -75,4 +75,29 @@ test_expect_success 'apply with --3way' '
75
test_cmp expect.diff actual.diff
76
'
77
78
+test_expect_success 'apply with --3way with rerere enabled' '
79
+ git config rerere.enabled true &&
80
+
81
+ # Merging side should be similar to applying this patch
82
+ git diff ...side >P.diff &&
83
+
84
+ # The corresponding conflicted merge
85
+ git reset --hard &&
86
+ git checkout master^0 &&
87
+ test_must_fail git merge --no-commit side &&
88
+
89
+ # Manually resolve and record the resolution
90
+ create_file 1 two 3 4 five six 7 >one &&
91
+ git rerere &&
92
+ cat one >expect &&
93
+
94
+ # should fail to apply
95
+ git reset --hard &&
96
+ git checkout master^0 &&
97
+ test_must_fail git apply --index --3way P.diff &&
98
+
99
+ # but rerere should have replayed the recorded resolution
100
+ test_cmp expect one
101
+'
102
+
103
test_done