diff options
author | Junio C Hamano <junkio@cox.net> | 2007-01-01 14:40:37 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-01 14:40:37 -0800 |
commit | 9066f4ef2fe27b7636094c06d2361820cd31e03e (patch) | |
tree | 9860bdef973ddba13bb9b5d3719ca41f95d7b115 | |
parent | 6f0b4ac0d730c99ab1c2962168675b920febb187 (diff) | |
parent | 579c9bb1986005282e049c6ad8f594a1ffc35fba (diff) | |
download | git-9066f4ef2fe27b7636094c06d2361820cd31e03e.tar.gz git-9066f4ef2fe27b7636094c06d2361820cd31e03e.tar.xz |
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.
-rwxr-xr-x | git-am.sh | 7 | ||||
-rw-r--r-- | merge-recursive.c | 27 |
2 files changed, 20 insertions, 14 deletions
@@ -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 diff --git a/merge-recursive.c b/merge-recursive.c index ca4f19e34..bac16f577 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -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]; |