From d9606e85cdf26b738786b5e5289bf8335656e95e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 23 Dec 2006 03:44:00 -0500 Subject: Use extended SHA1 syntax in merge-recursive conflicts. When we get a line-level conflict in merge-recursive and print out the two sides in the conflict hunk header and footer we should use the standard extended SHA1 syntax to specify the specific blob, as this allows the user to copy and paste the line right into 'git show' to view the complete version. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- merge-recursive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'merge-recursive.c') diff --git a/merge-recursive.c b/merge-recursive.c index ae7ae4cd2..abebb950a 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -649,8 +649,8 @@ static struct merge_file_info merge_file(struct diff_filespec *o, char *name1, *name2; int merge_status; - name1 = xstrdup(mkpath("%s/%s", branch1, a->path)); - name2 = xstrdup(mkpath("%s/%s", branch2, b->path)); + name1 = xstrdup(mkpath("%s:%s", branch1, a->path)); + name2 = xstrdup(mkpath("%s:%s", branch2, b->path)); fill_mm(o->sha1, &orig); fill_mm(a->sha1, &src1); -- cgit v1.2.1 From e0ec18192db8a5f80705a81dfaa1caa3e6c48c1a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 23 Dec 2006 03:44:47 -0500 Subject: Display 'theirs' branch name when possible in merge. Displaying the SHA1 of 'their' branch (the branch being merged into the current branch) is not nearly as friendly as just displaying the name of that branch, especially if that branch is already local to this repository. git-merge now sets the environment variable 'GITHEAD_%(sha1)=%(name)' for each argument it gets passed, making the actual input name that resolved to the commit '%(sha1)' easily available to the invoked merge strategy. git-merge-recursive makes use of these environment variables when they are available by using '%(name)' whenever it outputs the commit identification rather than '%(sha1)'. This is most obvious in the conflict hunks created by xdl_merge: $ git mege sideb~1 <<<<<<< HEAD:INSTALL Good! ======= Oops. >>>>>>> sideb~1:INSTALL [jc: adjusted a test script and a minor constness glitch.] Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- merge-recursive.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'merge-recursive.c') diff --git a/merge-recursive.c b/merge-recursive.c index abebb950a..ca4f19e34 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1263,6 +1263,18 @@ static struct commit *get_ref(const char *ref) return (struct commit *)object; } +static const char *better_branch_name(const char *branch) +{ + static char githead_env[8 + 40 + 1]; + char *name; + + if (strlen(branch) != 40) + return branch; + sprintf(githead_env, "GITHEAD_%s", branch); + name = getenv(githead_env); + return name ? name : branch; +} + int main(int argc, char *argv[]) { static const char *bases[2]; @@ -1293,11 +1305,14 @@ int main(int argc, char *argv[]) branch1 = argv[++i]; branch2 = argv[++i]; - printf("Merging %s with %s\n", branch1, branch2); h1 = get_ref(branch1); h2 = get_ref(branch2); + branch1 = better_branch_name(branch1); + branch2 = better_branch_name(branch2); + printf("Merging %s with %s\n", branch1, branch2); + if (bases_count == 1) { struct commit *ancestor = get_ref(bases[0]); clean = merge(h1, h2, branch1, branch2, 0, ancestor, &result); -- cgit v1.2.1