/*
* Recursive Merge algorithm stolen from git-merge-recursive.py by
* Fredrik Kuivinen.
* The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
*/
#include "cache.h"
#include "cache-tree.h"
#include "commit.h"
#include "blob.h"
#include "builtin.h"
#include "tree-walk.h"
#include "diff.h"
#include "diffcore.h"
#include "tag.h"
#include "unpack-trees.h"
#include "string-list.h"
#include "xdiff-interface.h"
#include "ll-merge.h"
#include "interpolate.h"
#include "attr.h"
#include "merge-recursive.h"
static int subtree_merge;
static struct tree *shift_tree_object(struct tree *one, struct tree *two)
{
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 (!hashcmp(two->object.sha1, shifted))
return two;
return lookup_tree(shifted);
}
/*
* A virtual commit has
* - (const char *)commit->util set to the name, and
* - *(int *)commit->object.sha1 set to the virtual id.
*/
static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
{
struct commit *commit = xcalloc(1, sizeof(struct commit));
static unsigned virtual_id = 1;
commit->tree = tree;
commit->util = (void*)comment;
*(int*)commit->object.sha1 = virtual_id++;
/* avoid warnings */
commit->object.parsed = 1;
return commit;
}
/*
* Since we use get_tree_entry(), which does not put the read object into
* the object pool, we cannot rely on a == b.
*/
static int sha_eq(const unsigned char *a, const unsigned char *b)
{
if (!a && !b)
return 2;
return a && b && hashcmp(a, b) == 0;
}
/*
* Since we want to write the index eventually, we cannot reuse the index
* for these (temporary) data.
*/
struct stage_data
{
struct
{
unsigned mode;
unsigned char sha[20];
} stages[4];
unsigned processed:1;
};
static struct string_list current_file_set = {NULL, 0, 0, 1};
static struct string_list current_directory_set = {NULL, 0, 0, 1};
static int call_depth = 0;
static int verbosity =
|