mirror of
https://github.com/git/git
synced 2024-10-28 19:25:47 +00:00
Merge branch 'sb/merge-friendly'
* sb/merge-friendly: Display 'theirs' branch name when possible in merge. Use extended SHA1 syntax in merge-recursive conflicts.
This commit is contained in:
commit
e036c90a91
3 changed files with 23 additions and 6 deletions
|
@ -221,6 +221,8 @@ do
|
||||||
remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) ||
|
remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) ||
|
||||||
die "$remote - not something we can merge"
|
die "$remote - not something we can merge"
|
||||||
remoteheads="${remoteheads}$remotehead "
|
remoteheads="${remoteheads}$remotehead "
|
||||||
|
eval GITHEAD_$remotehead='"$remote"'
|
||||||
|
export GITHEAD_$remotehead
|
||||||
done
|
done
|
||||||
set x $remoteheads ; shift
|
set x $remoteheads ; shift
|
||||||
|
|
||||||
|
|
|
@ -649,8 +649,8 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
|
||||||
char *name1, *name2;
|
char *name1, *name2;
|
||||||
int merge_status;
|
int merge_status;
|
||||||
|
|
||||||
name1 = xstrdup(mkpath("%s/%s", branch1, a->path));
|
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
|
||||||
name2 = xstrdup(mkpath("%s/%s", branch2, b->path));
|
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
|
||||||
|
|
||||||
fill_mm(o->sha1, &orig);
|
fill_mm(o->sha1, &orig);
|
||||||
fill_mm(a->sha1, &src1);
|
fill_mm(a->sha1, &src1);
|
||||||
|
@ -1263,6 +1263,18 @@ static struct commit *get_ref(const char *ref)
|
||||||
return (struct commit *)object;
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
static const char *bases[2];
|
static const char *bases[2];
|
||||||
|
@ -1293,11 +1305,14 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
branch1 = argv[++i];
|
branch1 = argv[++i];
|
||||||
branch2 = argv[++i];
|
branch2 = argv[++i];
|
||||||
printf("Merging %s with %s\n", branch1, branch2);
|
|
||||||
|
|
||||||
h1 = get_ref(branch1);
|
h1 = get_ref(branch1);
|
||||||
h2 = get_ref(branch2);
|
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) {
|
if (bases_count == 1) {
|
||||||
struct commit *ancestor = get_ref(bases[0]);
|
struct commit *ancestor = get_ref(bases[0]);
|
||||||
clean = merge(h1, h2, branch1, branch2, 0, ancestor, &result);
|
clean = merge(h1, h2, branch1, branch2, 0, ancestor, &result);
|
||||||
|
|
|
@ -59,18 +59,18 @@ GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F
|
||||||
test_expect_failure "combined merge conflicts" "git merge -m final G"
|
test_expect_failure "combined merge conflicts" "git merge -m final G"
|
||||||
|
|
||||||
cat > expect << EOF
|
cat > expect << EOF
|
||||||
<<<<<<< HEAD/a1
|
<<<<<<< HEAD:a1
|
||||||
F
|
F
|
||||||
=======
|
=======
|
||||||
G
|
G
|
||||||
>>>>>>> 26f86b677eb03d4d956dbe108b29cb77061c1e73/a1
|
>>>>>>> G:a1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success "result contains a conflict" "diff -u expect a1"
|
test_expect_success "result contains a conflict" "diff -u expect a1"
|
||||||
|
|
||||||
git ls-files --stage > out
|
git ls-files --stage > out
|
||||||
cat > expect << EOF
|
cat > expect << EOF
|
||||||
100644 f16f906ab60483c100d1241dfc39868de9ec9fcb 1 a1
|
100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1 a1
|
||||||
100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
|
100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
|
||||||
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
|
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue