notes-merge.c: remove implicit dependency on the_index
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Nov 10, 2018 at 06:48 UTC
5684200fe3572cf70b7260d1f835d801ff6dd14e
3 files changed
+12
-7
builtin/notes.c
+1
-1
@@ -808,7 +808,7 @@ static int merge(int argc, const char **argv, const char *prefix)
808
usage_with_options(git_notes_merge_usage, options);
809
}
810
811
- init_notes_merge_options(&o);
811
+ init_notes_merge_options(the_repository, &o);
812
o.verbosity = verbosity + NOTES_MERGE_VERBOSITY_DEFAULT;
813
814
if (do_abort)
notes-merge.c
+7
-5
@@ -18,11 +18,13 @@ struct notes_merge_pair {
18
struct object_id obj, base, local, remote;
19
};
20
21
-void init_notes_merge_options(struct notes_merge_options *o)
21
+void init_notes_merge_options(struct repository *r,
22
+ struct notes_merge_options *o)
23
{
24
memset(o, 0, sizeof(struct notes_merge_options));
25
strbuf_init(&(o->commit_msg), 0);
26
o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;
27
+ o->repo = r;
28
}
29
30
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,
129
trace_printf("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n",
130
oid_to_hex(base), oid_to_hex(remote));
131
130
- repo_diff_setup(the_repository, &opt);
132
+ repo_diff_setup(o->repo, &opt);
133
opt.flags.recursive = 1;
134
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
135
diff_setup_done(&opt);
@@ -190,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,
192
trace_printf("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n",
193
len, oid_to_hex(base), oid_to_hex(local));
194
193
- repo_diff_setup(the_repository, &opt);
195
+ repo_diff_setup(o->repo, &opt);
196
opt.flags.recursive = 1;
197
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
198
diff_setup_done(&opt);
@@ -350,7 +352,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
352
353
status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
354
&local, o->local_ref, &remote, o->remote_ref,
353
- &the_index, NULL);
355
+ o->repo->index, NULL);
356
357
free(base.ptr);
358
free(local.ptr);
@@ -711,7 +713,7 @@ int notes_merge_commit(struct notes_merge_options *o,
713
/* write file as blob, and add to partial_tree */
714
if (stat(path.buf, &st))
715
die_errno("Failed to stat '%s'", path.buf);
714
- if (index_path(&the_index, &blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
716
+ if (index_path(o->repo->index, &blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
717
die("Failed to write blob object from '%s'", path.buf);
718
if (add_note(partial_tree, &obj_oid, &blob_oid, NULL))
719
die("Failed to add resolved note '%s' to notes tree",
notes-merge.h
+4
-1
@@ -6,6 +6,7 @@
6
7
struct commit;
8
struct object_id;
9
+struct repository;
10
11
#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
12
@@ -15,6 +16,7 @@ enum notes_merge_verbosity {
16
};
17
18
struct notes_merge_options {
19
+ struct repository *repo;
20
const char *local_ref;
21
const char *remote_ref;
22
struct strbuf commit_msg;
@@ -23,7 +25,8 @@ struct notes_merge_options {
25
unsigned has_worktree:1;
26
};
27
26
-void init_notes_merge_options(struct notes_merge_options *o);
28
+void init_notes_merge_options(struct repository *r,
29
+ struct notes_merge_options *o);
30
31
/*
32
* Merge notes from o->remote_ref into o->local_ref