repository.c: replace hold_locked_index() with repo_hold_locked_index()
[gitweb.git] / merge-recursive.c
index 59811116b6ddb2a7f79cf904f31a43fb8d372ed9..8dba939d8f8393151a4ba2c1865c59f5c7a101fd 100644 (file)
@@ -1090,7 +1090,8 @@ static int merge_3way(struct merge_options *o,
        read_mmblob(&src2, &b->oid);
 
        merge_status = ll_merge(result_buf, a->path, &orig, base_name,
-                               &src1, name1, &src2, name2, &ll_opts);
+                               &src1, name1, &src2, name2,
+                               &the_index, &ll_opts);
 
        free(base_name);
        free(name1);
@@ -1121,7 +1122,7 @@ static int find_first_merges(struct object_array *result, const char *path,
        /* get all revisions that merge commit a */
        xsnprintf(merged_revision, sizeof(merged_revision), "^%s",
                  oid_to_hex(&a->object.oid));
-       init_revisions(&revs, NULL);
+       repo_init_revisions(the_repository, &revs, NULL);
        rev_opts.submodule = path;
        /* FIXME: can't handle linked worktrees in submodules yet */
        revs.single_worktree = path != NULL;
@@ -1709,6 +1710,27 @@ static int handle_rename_add(struct merge_options *o,
                                     ci->dst_entry1->stages[other_stage].mode);
 }
 
+static char *find_path_for_conflict(struct merge_options *o,
+                                   const char *path,
+                                   const char *branch1,
+                                   const char *branch2)
+{
+       char *new_path = NULL;
+       if (dir_in_way(path, !o->call_depth, 0)) {
+               new_path = unique_path(o, path, branch1);
+               output(o, 1, _("%s is a directory in %s adding "
+                              "as %s instead"),
+                      path, branch2, new_path);
+       } else if (would_lose_untracked(path)) {
+               new_path = unique_path(o, path, branch1);
+               output(o, 1, _("Refusing to lose untracked file"
+                              " at %s; adding as %s instead"),
+                      path, new_path);
+       }
+
+       return new_path;
+}
+
 static int handle_rename_rename_1to2(struct merge_options *o,
                                     struct rename_conflict_info *ci)
 {
@@ -1783,19 +1805,9 @@ static int handle_rename_rename_1to2(struct merge_options *o,
                                                  &add->oid, add->mode) < 0)
                                return -1;
                } else {
-                       char *new_path = NULL;
-                       if (dir_in_way(a->path, !o->call_depth, 0)) {
-                               new_path = unique_path(o, a->path, ci->branch1);
-                               output(o, 1, _("%s is a directory in %s adding "
-                                              "as %s instead"),
-                                      a->path, ci->branch2, new_path);
-                       } else if (would_lose_untracked(a->path)) {
-                               new_path = unique_path(o, a->path, ci->branch1);
-                               output(o, 1, _("Refusing to lose untracked file"
-                                              " at %s; adding as %s instead"),
-                                      a->path, new_path);
-                       }
-
+                       char *new_path = find_path_for_conflict(o, a->path,
+                                                               ci->branch1,
+                                                               ci->branch2);
                        if (update_file(o, 0, &mfi.oid, mfi.mode, new_path ? new_path : a->path))
                                return -1;
                        free(new_path);
@@ -1812,19 +1824,9 @@ static int handle_rename_rename_1to2(struct merge_options *o,
                                                  &mfi.oid, mfi.mode) < 0)
                                return -1;
                } else {
-                       char *new_path = NULL;
-                       if (dir_in_way(b->path, !o->call_depth, 0)) {
-                               new_path = unique_path(o, b->path, ci->branch2);
-                               output(o, 1, _("%s is a directory in %s adding "
-                                              "as %s instead"),
-                                      b->path, ci->branch1, new_path);
-                       } else if (would_lose_untracked(b->path)) {
-                               new_path = unique_path(o, b->path, ci->branch2);
-                               output(o, 1, _("Refusing to lose untracked file"
-                                              " at %s; adding as %s instead"),
-                                      b->path, new_path);
-                       }
-
+                       char *new_path = find_path_for_conflict(o, b->path,
+                                                               ci->branch2,
+                                                               ci->branch1);
                        if (update_file(o, 0, &mfi.oid, mfi.mode, new_path ? new_path : b->path))
                                return -1;
                        free(new_path);
@@ -1884,7 +1886,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *o,
        struct diff_queue_struct *ret;
        struct diff_options opts;
 
-       diff_setup(&opts);
+       repo_diff_setup(the_repository, &opts);
        opts.flags.recursive = 1;
        opts.flags.rename_empty = 0;
        opts.detect_rename = merge_detect_rename(o);
@@ -2311,7 +2313,7 @@ static struct dir_rename_entry *check_dir_renamed(const char *path,
 {
        char *temp = xstrdup(path);
        char *end;
-       struct dir_rename_entry *entry = NULL;;
+       struct dir_rename_entry *entry = NULL;
 
        while ((end = strrchr(temp, '/'))) {
                *end = '\0';
@@ -3641,7 +3643,7 @@ int merge_recursive_generic(struct merge_options *o,
                }
        }
 
-       hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
+       repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
        clean = merge_recursive(o, head_commit, next_commit, ca,
                                result);
        if (clean < 0) {