提交 9066f4ef 编写于 作者: J Junio C Hamano

Merge branch 'sp/merge' (early part)

* 'sp/merge' (early part):
  Use merge-recursive in git-am -3.
  Allow merging bare trees in merge-recursive.
  Move better_branch_name above get_ref in merge-recursive.
......@@ -88,10 +88,12 @@ It does not apply to blobs recorded in its index."
# This is not so wrong. Depending on which base we picked,
# orig_tree may be wildly different from ours, but his_tree
# has the same set of wildly different changes in parts the
# patch did not touch, so resolve ends up canceling them,
# patch did not touch, so recursive ends up canceling them,
# saying that we reverted all those changes.
git-merge-resolve $orig_tree -- HEAD $his_tree || {
eval GITHEAD_$his_tree='"$SUBJECT"'
export GITHEAD_$his_tree
git-merge-recursive $orig_tree -- HEAD $his_tree || {
if test -d "$GIT_DIR/rr-cache"
then
git-rerere
......@@ -99,6 +101,7 @@ It does not apply to blobs recorded in its index."
echo Failed to merge in the changes.
exit 1
}
unset GITHEAD_$his_tree
}
prec=4
......
......@@ -1248,6 +1248,18 @@ static int merge(struct commit *h1,
return clean;
}
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;
}
static struct commit *get_ref(const char *ref)
{
unsigned char sha1[20];
......@@ -1256,6 +1268,9 @@ static struct commit *get_ref(const char *ref)
if (get_sha1(ref, sha1))
die("Could not resolve ref '%s'", ref);
object = deref_tag(parse_object(sha1), ref, strlen(ref));
if (object->type == OBJ_TREE)
return make_virtual_commit((struct tree*)object,
better_branch_name(ref));
if (object->type != OBJ_COMMIT)
return NULL;
if (parse_commit((struct commit *)object))
......@@ -1263,18 +1278,6 @@ 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];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册