cherry-pick, revert: add a label for ancestor
When writing conflict hunks in ‘diff3 -m’ format, also add a label to the common ancestor. Especially in a cherry-pick, it is not immediately obvious without such a label what the common ancestor represents. git rerere does not have trouble parsing the new output and its preimage ids are unchanged since it includes its own code for recreating conflict hunks. No other code in git parses conflict hunks. Requested-by: Stefan Monnier <monnier@iro.umontreal.ca> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Mar 20, 2010 at 19:46 UTC
bf975d379d79ab0eb9e8835af4abab4712e71dad
2 files changed
+6
-3
builtin/revert.c
+4
-1
@@ -281,7 +281,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
281
{
282
unsigned char head[20];
283
struct commit *base, *next, *parent;
284
- const char *next_label;
284
+ const char *base_label, *next_label;
285
int i, index_fd, clean;
286
struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
287
@@ -368,6 +368,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
368
369
if (action == REVERT) {
370
base = commit;
371
+ base_label = msg.label;
372
next = parent;
373
next_label = msg.parent_label;
374
add_to_msg("Revert \"");
@@ -382,6 +383,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
383
add_to_msg(".\n");
384
} else {
385
base = parent;
386
+ base_label = msg.parent_label;
387
next = commit;
388
next_label = msg.label;
389
set_author_ident_env(msg.message);
@@ -395,6 +397,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
397
398
read_cache();
399
init_merge_options(&o);
400
+ o.ancestor = base ? base_label : "(empty tree)";
401
o.branch1 = "HEAD";
402
o.branch2 = next ? next_label : "(empty tree)";
403
t/t3507-cherry-pick-conflict.sh
+2
-2
@@ -112,7 +112,7 @@ test_expect_success 'diff3 -m style' '
112
cat <<-EOF > expected &&
113
<<<<<<< HEAD
114
a
115
- |||||||
115
+ ||||||| parent of objid picked
116
b
117
=======
118
c
@@ -179,7 +179,7 @@ test_expect_success 'revert conflict, diff3 -m style' '
179
cat <<-EOF > expected &&
180
<<<<<<< HEAD
181
a
182
- |||||||
182
+ ||||||| objid picked
183
c
184
=======
185
b