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
This commit is contained in:
Junio C Hamano
2010-01-20 20:28:50 -08:00
21 changed files with 392 additions and 54 deletions

View File

@ -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)) {