Skip to content

Commit

Permalink
cherry-pick, revert: add a label for ancestor
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Mar 21, 2010
1 parent d685654 commit bf975d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion builtin/revert.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
{
unsigned char head[20];
struct commit *base, *next, *parent;
const char *next_label;
const char *base_label, *next_label;
int i, index_fd, clean;
struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };

Expand Down Expand Up @@ -368,6 +368,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)

if (action == REVERT) {
base = commit;
base_label = msg.label;
next = parent;
next_label = msg.parent_label;
add_to_msg("Revert \"");
Expand All @@ -382,6 +383,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
add_to_msg(".\n");
} else {
base = parent;
base_label = msg.parent_label;
next = commit;
next_label = msg.label;
set_author_ident_env(msg.message);
Expand All @@ -395,6 +397,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)

read_cache();
init_merge_options(&o);
o.ancestor = base ? base_label : "(empty tree)";
o.branch1 = "HEAD";
o.branch2 = next ? next_label : "(empty tree)";

Expand Down
4 changes: 2 additions & 2 deletions t/t3507-cherry-pick-conflict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ test_expect_success 'diff3 -m style' '
cat <<-EOF > expected &&
<<<<<<< HEAD
a
|||||||
||||||| parent of objid picked
b
=======
c
Expand Down Expand Up @@ -179,7 +179,7 @@ test_expect_success 'revert conflict, diff3 -m style' '
cat <<-EOF > expected &&
<<<<<<< HEAD
a
|||||||
||||||| objid picked
c
=======
b
Expand Down

0 comments on commit bf975d3

Please sign in to comment.