#include "cache-tree.h"
#include "commit.h"
#include "blob.h"
+#include "builtin.h"
#include "tree-walk.h"
#include "diff.h"
#include "diffcore.h"
#include "xdiff-interface.h"
#include "interpolate.h"
#include "attr.h"
+#include "merge-recursive.h"
static int subtree_merge;
return 0;
}
-static struct tree *git_write_tree(void)
+struct tree *write_tree_from_memory(void)
{
struct tree *result = NULL;
return clean_merge;
}
-static int merge_trees(struct tree *head,
- struct tree *merge,
- struct tree *common,
- const char *branch1,
- const char *branch2,
- struct tree **result)
+int merge_trees(struct tree *head,
+ struct tree *merge,
+ struct tree *common,
+ const char *branch1,
+ const char *branch2,
+ struct tree **result)
{
int code, clean;
clean = 1;
if (index_only)
- *result = git_write_tree();
+ *result = write_tree_from_memory();
return clean;
}
* Merge the commits h1 and h2, return the resulting virtual
* commit object and a flag indicating the cleanness of the merge.
*/
-static int merge(struct commit *h1,
- struct commit *h2,
- const char *branch1,
- const char *branch2,
- struct commit_list *ca,
- struct commit **result)
+int merge_recursive(struct commit *h1,
+ struct commit *h2,
+ const char *branch1,
+ const char *branch2,
+ struct commit_list *ca,
+ struct commit **result)
{
struct commit_list *iter;
struct commit *merged_common_ancestors;
* "conflicts" were already resolved.
*/
discard_cache();
- merge(merged_common_ancestors, iter->item,
- "Temporary merge branch 1",
- "Temporary merge branch 2",
- NULL,
- &merged_common_ancestors);
+ merge_recursive(merged_common_ancestors, iter->item,
+ "Temporary merge branch 1",
+ "Temporary merge branch 2",
+ NULL,
+ &merged_common_ancestors);
call_depth--;
if (!merged_common_ancestors)
return git_default_config(var, value);
}
-int main(int argc, char *argv[])
+int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
{
static const char *bases[20];
static unsigned bases_count = 0;
struct commit *ancestor = get_ref(bases[i]);
ca = commit_list_insert(ancestor, &ca);
}
- clean = merge(h1, h2, branch1, branch2, ca, &result);
+ clean = merge_recursive(h1, h2, branch1, branch2, ca, &result);
if (active_cache_changed &&
(write_cache(index_fd, active_cache, active_nr) ||
extern int cmd_merge_base(int argc, const char **argv, const char *prefix);
extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
+extern int cmd_merge_recursive(int argc, const char **argv, const char *prefix);
extern int cmd_mv(int argc, const char **argv, const char *prefix);
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
{ "merge-base", cmd_merge_base, RUN_SETUP },
{ "merge-file", cmd_merge_file },
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
+ { "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },