return -1;
}
-static struct tree *shift_tree_object(struct tree *one, struct tree *two,
+static struct tree *shift_tree_object(struct repository *repo,
+ struct tree *one, struct tree *two,
const char *subtree_shift)
{
struct object_id shifted;
}
if (oideq(&two->object.oid, &shifted))
return two;
- return lookup_tree(the_repository, &shifted);
+ return lookup_tree(repo, &shifted);
}
-static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
+static struct commit *make_virtual_commit(struct repository *repo,
+ struct tree *tree,
+ const char *comment)
{
- struct commit *commit = alloc_commit_node(the_repository);
+ struct commit *commit = alloc_commit_node(repo);
set_merge_remote_desc(commit, comment, (struct object *)commit);
commit->maybe_tree = tree;
return NULL;
}
- result = lookup_tree(the_repository, &istate->cache_tree->oid);
+ result = lookup_tree(o->repo, &istate->cache_tree->oid);
return result;
}
{
struct pathspec match_all;
memset(&match_all, 0, sizeof(match_all));
- read_tree_recursive(tree, "", 0, 0, &match_all, save_files_dirs, o);
+ read_tree_recursive(the_repository, tree, "", 0, 0,
+ &match_all, save_files_dirs, o);
}
static int get_tree_entry_if_blob(const struct object_id *tree,
return 0;
}
- if (!(commit_base = lookup_commit_reference(the_repository, base)) ||
- !(commit_a = lookup_commit_reference(the_repository, a)) ||
- !(commit_b = lookup_commit_reference(the_repository, b))) {
+ if (!(commit_base = lookup_commit_reference(o->repo, base)) ||
+ !(commit_a = lookup_commit_reference(o->repo, a)) ||
+ !(commit_b = lookup_commit_reference(o->repo, b))) {
output(o, 1, _("Failed to merge submodule %s (commits not present)"), path);
return 0;
}
static int handle_rename_via_dir(struct merge_options *o,
struct diff_filepair *pair,
- const char *rename_branch,
- const char *other_branch)
+ const char *rename_branch)
{
/*
* Handle file adds that need to be renamed due to directory rename
remove_hashmap_entries(dir_re_merge, &remove_from_merge);
}
-static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs,
- struct tree *tree)
+static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs)
{
struct hashmap *dir_renames;
struct hashmap_iter iter;
struct tree *o_tree,
struct tree *a_tree,
struct tree *b_tree,
- struct string_list *entries,
- int *clean)
+ struct string_list *entries)
{
struct string_list_item *item;
int stage = (tree == a_tree ? 2 : 3);
apply_directory_rename_modifications(o, pair, new_path,
re, tree, o_tree,
a_tree, b_tree,
- entries,
- clean_merge);
+ entries);
}
hashmap_iter_init(&collisions, &iter);
merge_pairs = get_diffpairs(o, common, merge);
if (o->detect_directory_renames) {
- dir_re_head = get_directory_renames(head_pairs, head);
- dir_re_merge = get_directory_renames(merge_pairs, merge);
+ dir_re_head = get_directory_renames(head_pairs);
+ dir_re_merge = get_directory_renames(merge_pairs);
handle_directory_level_conflicts(o,
dir_re_head, head,
clean_merge = 1;
if (handle_rename_via_dir(o,
conflict_info->pair1,
- conflict_info->branch1,
- conflict_info->branch2))
+ conflict_info->branch1))
clean_merge = -1;
break;
case RENAME_ADD:
int code, clean;
struct strbuf sb = STRBUF_INIT;
- if (!o->call_depth && index_has_changes(istate, head, &sb)) {
+ if (!o->call_depth && repo_index_has_changes(o->repo, head, &sb)) {
err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"),
sb.buf);
return -1;
}
if (o->subtree_shift) {
- merge = shift_tree_object(head, merge, o->subtree_shift);
- common = shift_tree_object(head, common, o->subtree_shift);
+ merge = shift_tree_object(o->repo, head, merge, o->subtree_shift);
+ common = shift_tree_object(o->repo, head, common, o->subtree_shift);
}
if (oid_eq(&common->object.oid, &merge->object.oid)) {
/* if there is no common ancestor, use an empty tree */
struct tree *tree;
- tree = lookup_tree(the_repository, the_repository->hash_algo->empty_tree);
- merged_common_ancestors = make_virtual_commit(tree, "ancestor");
+ tree = lookup_tree(o->repo, o->repo->hash_algo->empty_tree);
+ merged_common_ancestors = make_virtual_commit(o->repo, tree, "ancestor");
}
for (iter = ca; iter; iter = iter->next) {
}
if (o->call_depth) {
- *result = make_virtual_commit(mrtree, "merged tree");
+ *result = make_virtual_commit(o->repo, mrtree, "merged tree");
commit_list_insert(h1, &(*result)->parents);
commit_list_insert(h2, &(*result)->parents->next);
}
return clean;
}
-static struct commit *get_ref(const struct object_id *oid, const char *name)
+static struct commit *get_ref(struct repository *repo, const struct object_id *oid,
+ const char *name)
{
struct object *object;
- object = deref_tag(the_repository, parse_object(the_repository, oid),
- name,
- strlen(name));
+ object = deref_tag(repo, parse_object(repo, oid),
+ name, strlen(name));
if (!object)
return NULL;
if (object->type == OBJ_TREE)
- return make_virtual_commit((struct tree*)object, name);
+ return make_virtual_commit(repo, (struct tree*)object, name);
if (object->type != OBJ_COMMIT)
return NULL;
if (parse_commit((struct commit *)object))
{
int clean;
struct lock_file lock = LOCK_INIT;
- struct commit *head_commit = get_ref(head, o->branch1);
- struct commit *next_commit = get_ref(merge, o->branch2);
+ struct commit *head_commit = get_ref(o->repo, head, o->branch1);
+ struct commit *next_commit = get_ref(o->repo, merge, o->branch2);
struct commit_list *ca = NULL;
if (base_list) {
int i;
for (i = 0; i < num_base_list; ++i) {
struct commit *base;
- if (!(base = get_ref(base_list[i], oid_to_hex(base_list[i]))))
+ if (!(base = get_ref(o->repo, base_list[i], oid_to_hex(base_list[i]))))
return err(o, _("Could not parse object '%s'"),
oid_to_hex(base_list[i]));
commit_list_insert(base, &ca);