summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-21 04:28:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-01-21 04:28:50 (GMT)
commitfcb2a7e4a3c7899a3432f5804889fa3ea5779220 (patch)
tree0f0785d427c23c7b8dbaae1afcdbd370ea3b639c /merge-recursive.c
parente98f80f50bf9b78aab8cea6184fd708259d0c3b3 (diff)
parent566c511195adc0ce88559853f2f00933e241d862 (diff)
downloadgit-fcb2a7e4a3c7899a3432f5804889fa3ea5779220.zip
git-fcb2a7e4a3c7899a3432f5804889fa3ea5779220.tar.gz
git-fcb2a7e4a3c7899a3432f5804889fa3ea5779220.tar.bz2
Merge branch 'ap/merge-backend-opts'
* ap/merge-backend-opts: Document that merge strategies can now take their own options Extend merge-subtree tests to test -Xsubtree=dir. Make "subtree" part more orthogonal to the rest of merge-recursive. pull: Fix parsing of -X<option> Teach git-pull to pass -X<option> to git-merge git merge -X<option> git-merge-file --ours, --theirs Conflicts: git-compat-util.h
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index dd4fbd0..1239647 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -21,15 +21,17 @@
#include "merge-recursive.h"
#include "dir.h"
-static struct tree *shift_tree_object(struct tree *one, struct tree *two)
+static struct tree *shift_tree_object(struct tree *one, struct tree *two,
+ const char *subtree_shift)
{
unsigned char shifted[20];
- /*
- * NEEDSWORK: this limits the recursion depth to hardcoded
- * value '2' to avoid excessive overhead.
- */
- shift_tree(one->object.sha1, two->object.sha1, shifted, 2);
+ if (!*subtree_shift) {
+ shift_tree(one->object.sha1, two->object.sha1, shifted, 0);
+ } else {
+ shift_tree_by(one->object.sha1, two->object.sha1, shifted,
+ subtree_shift);
+ }
if (!hashcmp(two->object.sha1, shifted))
return two;
return lookup_tree(shifted);
@@ -625,6 +627,23 @@ static int merge_3way(struct merge_options *o,
mmfile_t orig, src1, src2;
char *name1, *name2;
int merge_status;
+ int favor;
+
+ if (o->call_depth)
+ favor = 0;
+ else {
+ switch (o->recursive_variant) {
+ case MERGE_RECURSIVE_OURS:
+ favor = XDL_MERGE_FAVOR_OURS;
+ break;
+ case MERGE_RECURSIVE_THEIRS:
+ favor = XDL_MERGE_FAVOR_THEIRS;
+ break;
+ default:
+ favor = 0;
+ break;
+ }
+ }
if (strcmp(a->path, b->path)) {
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
@@ -640,7 +659,7 @@ static int merge_3way(struct merge_options *o,
merge_status = ll_merge(result_buf, a->path, &orig,
&src1, name1, &src2, name2,
- o->call_depth);
+ (!!o->call_depth) | (favor << 1));
free(name1);
free(name2);
@@ -1201,9 +1220,9 @@ int merge_trees(struct merge_options *o,
{
int code, clean;
- if (o->subtree_merge) {
- merge = shift_tree_object(head, merge);
- common = shift_tree_object(head, common);
+ if (o->subtree_shift) {
+ merge = shift_tree_object(head, merge, o->subtree_shift);
+ common = shift_tree_object(head, common, o->subtree_shift);
}
if (sha_eq(common->object.sha1, merge->object.sha1)) {