summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d9606e8)
raw | patch | inline | side by side (parent: d9606e8)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 23 Dec 2006 08:44:47 +0000 (03:44 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 23 Dec 2006 09:29:37 +0000 (01:29 -0800) |
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 <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
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 <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-merge.sh | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
t/t6024-recursive-merge.sh | patch | blob | history |
diff --git a/git-merge.sh b/git-merge.sh
index aec215e725826fb18a4d3d75408aa44acdd3e5de..7dd0a112368a8b3672a98fdfcdb5290146cefeba 100755 (executable)
--- a/git-merge.sh
+++ b/git-merge.sh
remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) ||
die "$remote - not something we can merge"
remoteheads="${remoteheads}$remotehead "
+ eval GITHEAD_$remotehead='"$remote"'
+ export GITHEAD_$remotehead
done
set x $remoteheads ; shift
diff --git a/merge-recursive.c b/merge-recursive.c
index abebb950ab15225bc93678e51951088444fc5ed4..ca4f19e34d4216fed7c8110ba8f75585c69f92c7 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
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];
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);
index 964010e764a1f6340ae4a5cd300ef67cd6babfc4..69b18f7d8160d0acb2bf222a9478674cfc21634f 100644 (file)
test_expect_failure "combined merge conflicts" "git merge -m final G"
cat > expect << EOF
-<<<<<<< HEAD/a1
+<<<<<<< HEAD:a1
F
=======
G
->>>>>>> 26f86b677eb03d4d956dbe108b29cb77061c1e73/a1
+>>>>>>> G:a1
EOF
test_expect_success "result contains a conflict" "diff -u expect a1"
git ls-files --stage > out
cat > expect << EOF
-100644 f16f906ab60483c100d1241dfc39868de9ec9fcb 1 a1
+100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1 a1
100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
EOF