Skip to content

Commit 5684200

Browse files
pcloudsgitster
authored andcommitted
notes-merge.c: remove implicit dependency on the_index
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 96ab6e0 commit 5684200

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

builtin/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static int merge(int argc, const char **argv, const char *prefix)
808808
usage_with_options(git_notes_merge_usage, options);
809809
}
810810

811-
init_notes_merge_options(&o);
811+
init_notes_merge_options(the_repository, &o);
812812
o.verbosity = verbosity + NOTES_MERGE_VERBOSITY_DEFAULT;
813813

814814
if (do_abort)

notes-merge.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ struct notes_merge_pair {
1818
struct object_id obj, base, local, remote;
1919
};
2020

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)
2223
{
2324
memset(o, 0, sizeof(struct notes_merge_options));
2425
strbuf_init(&(o->commit_msg), 0);
2526
o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;
27+
o->repo = r;
2628
}
2729

2830
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,
127129
trace_printf("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n",
128130
oid_to_hex(base), oid_to_hex(remote));
129131

130-
repo_diff_setup(the_repository, &opt);
132+
repo_diff_setup(o->repo, &opt);
131133
opt.flags.recursive = 1;
132134
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
133135
diff_setup_done(&opt);
@@ -190,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,
190192
trace_printf("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n",
191193
len, oid_to_hex(base), oid_to_hex(local));
192194

193-
repo_diff_setup(the_repository, &opt);
195+
repo_diff_setup(o->repo, &opt);
194196
opt.flags.recursive = 1;
195197
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
196198
diff_setup_done(&opt);
@@ -350,7 +352,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
350352

351353
status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
352354
&local, o->local_ref, &remote, o->remote_ref,
353-
&the_index, NULL);
355+
o->repo->index, NULL);
354356

355357
free(base.ptr);
356358
free(local.ptr);
@@ -711,7 +713,7 @@ int notes_merge_commit(struct notes_merge_options *o,
711713
/* write file as blob, and add to partial_tree */
712714
if (stat(path.buf, &st))
713715
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))
715717
die("Failed to write blob object from '%s'", path.buf);
716718
if (add_note(partial_tree, &obj_oid, &blob_oid, NULL))
717719
die("Failed to add resolved note '%s' to notes tree",

notes-merge.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
struct commit;
88
struct object_id;
9+
struct repository;
910

1011
#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
1112

@@ -15,6 +16,7 @@ enum notes_merge_verbosity {
1516
};
1617

1718
struct notes_merge_options {
19+
struct repository *repo;
1820
const char *local_ref;
1921
const char *remote_ref;
2022
struct strbuf commit_msg;
@@ -23,7 +25,8 @@ struct notes_merge_options {
2325
unsigned has_worktree:1;
2426
};
2527

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);
2730

2831
/*
2932
* Merge notes from o->remote_ref into o->local_ref

0 commit comments

Comments
 (0)