]> git.ipfire.org Git - thirdparty/git.git/commitdiff
notes-merge.c: remove implicit dependency on the_index
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 10 Nov 2018 05:48:53 +0000 (06:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Nov 2018 05:50:05 +0000 (14:50 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/notes.c
notes-merge.c
notes-merge.h

index c05cd004abcbdcd1e4c3d140f3cf4251c416df36..15a6c78855b4eeb704f1f90d1d0e881656e81a2c 100644 (file)
@@ -808,7 +808,7 @@ static int merge(int argc, const char **argv, const char *prefix)
                usage_with_options(git_notes_merge_usage, options);
        }
 
-       init_notes_merge_options(&o);
+       init_notes_merge_options(the_repository, &o);
        o.verbosity = verbosity + NOTES_MERGE_VERBOSITY_DEFAULT;
 
        if (do_abort)
index bd05d50b051288cb466de5afed52993a1edf3b1d..0c22f09b28690307aeac27474dcde1e039533722 100644 (file)
@@ -18,11 +18,13 @@ struct notes_merge_pair {
        struct object_id obj, base, local, remote;
 };
 
-void init_notes_merge_options(struct notes_merge_options *o)
+void init_notes_merge_options(struct repository *r,
+                             struct notes_merge_options *o)
 {
        memset(o, 0, sizeof(struct notes_merge_options));
        strbuf_init(&(o->commit_msg), 0);
        o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;
+       o->repo = r;
 }
 
 static int path_to_oid(const char *path, struct object_id *oid)
@@ -127,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
        trace_printf("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n",
               oid_to_hex(base), oid_to_hex(remote));
 
-       repo_diff_setup(the_repository, &opt);
+       repo_diff_setup(o->repo, &opt);
        opt.flags.recursive = 1;
        opt.output_format = DIFF_FORMAT_NO_OUTPUT;
        diff_setup_done(&opt);
@@ -190,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,
        trace_printf("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n",
               len, oid_to_hex(base), oid_to_hex(local));
 
-       repo_diff_setup(the_repository, &opt);
+       repo_diff_setup(o->repo, &opt);
        opt.flags.recursive = 1;
        opt.output_format = DIFF_FORMAT_NO_OUTPUT;
        diff_setup_done(&opt);
@@ -350,7 +352,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
 
        status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
                          &local, o->local_ref, &remote, o->remote_ref,
-                         &the_index, NULL);
+                         o->repo->index, NULL);
 
        free(base.ptr);
        free(local.ptr);
@@ -711,7 +713,7 @@ int notes_merge_commit(struct notes_merge_options *o,
                /* write file as blob, and add to partial_tree */
                if (stat(path.buf, &st))
                        die_errno("Failed to stat '%s'", path.buf);
-               if (index_path(&the_index, &blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
+               if (index_path(o->repo->index, &blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
                        die("Failed to write blob object from '%s'", path.buf);
                if (add_note(partial_tree, &obj_oid, &blob_oid, NULL))
                        die("Failed to add resolved note '%s' to notes tree",
index 6c74e9385b83ce317d6ca91f328c7790d0753e2c..99f9c709c536ac19c677e97348e9924c2764d217 100644 (file)
@@ -6,6 +6,7 @@
 
 struct commit;
 struct object_id;
+struct repository;
 
 #define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
 
@@ -15,6 +16,7 @@ enum notes_merge_verbosity {
 };
 
 struct notes_merge_options {
+       struct repository *repo;
        const char *local_ref;
        const char *remote_ref;
        struct strbuf commit_msg;
@@ -23,7 +25,8 @@ struct notes_merge_options {
        unsigned has_worktree:1;
 };
 
-void init_notes_merge_options(struct notes_merge_options *o);
+void init_notes_merge_options(struct repository *r,
+                             struct notes_merge_options *o);
 
 /*
  * Merge notes from o->remote_ref into o->local_ref