merge-recursive.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
Jan 12, 2019 at 09:13 UTC
0d6caa2d08e39bf97e0cffb8ba2b4d39a73bf763
7 files changed
+91
-75
builtin/am.c
+1
-1
@@ -1545,7 +1545,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
1545
* changes.
1546
*/
1547
1548
- init_merge_options(&o);
1548
+ init_merge_options(&o, the_repository);
1549
1550
o.branch1 = "HEAD";
1551
their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
builtin/checkout.c
+1
-1
@@ -670,7 +670,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
670
* a pain; plumb in an option to set
671
* o.renormalize?
672
*/
673
- init_merge_options(&o);
673
+ init_merge_options(&o, the_repository);
674
o.verbosity = 0;
675
work = write_tree_from_memory(&o);
676
builtin/merge-recursive.c
+1
-1
@@ -28,7 +28,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
28
struct merge_options o;
29
struct commit *result;
30
31
- init_merge_options(&o);
31
+ init_merge_options(&o, the_repository);
32
if (argv[0] && ends_with(argv[0], "-subtree"))
33
o.subtree_shift = "";
34
builtin/merge.c
+1
-1
@@ -702,7 +702,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
702
return 2;
703
}
704
705
- init_merge_options(&o);
705
+ init_merge_options(&o, the_repository);
706
if (!strcmp(strategy, "subtree"))
707
o.subtree_shift = "";
708
merge-recursive.c
+80
-68
@@ -343,22 +343,24 @@ static int add_cacheinfo(struct merge_options *o,
343
unsigned int mode, const struct object_id *oid,
344
const char *path, int stage, int refresh, int options)
345
{
346
+ struct index_state *istate = o->repo->index;
347
struct cache_entry *ce;
348
int ret;
349
349
- ce = make_cache_entry(&the_index, mode, oid ? oid : &null_oid, path, stage, 0);
350
+ ce = make_cache_entry(istate, mode, oid ? oid : &null_oid, path, stage, 0);
351
if (!ce)
352
return err(o, _("add_cacheinfo failed for path '%s'; merge aborting."), path);
353
353
- ret = add_cache_entry(ce, options);
354
+ ret = add_index_entry(istate, ce, options);
355
if (refresh) {
356
struct cache_entry *nce;
357
357
- nce = refresh_cache_entry(&the_index, ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
358
+ nce = refresh_cache_entry(istate, ce,
359
+ CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
360
if (!nce)
361
return err(o, _("add_cacheinfo failed to refresh for path '%s'; merge aborting."), path);
362
if (nce != ce)
361
- ret = add_cache_entry(nce, options);
363
+ ret = add_index_entry(istate, nce, options);
364
}
365
return ret;
366
}
@@ -386,7 +388,7 @@ static int unpack_trees_start(struct merge_options *o,
388
o->unpack_opts.merge = 1;
389
o->unpack_opts.head_idx = 2;
390
o->unpack_opts.fn = threeway_merge;
389
- o->unpack_opts.src_index = &the_index;
391
+ o->unpack_opts.src_index = o->repo->index;
392
o->unpack_opts.dst_index = &tmp_index;
393
o->unpack_opts.aggressive = !merge_detect_rename(o);
394
setup_unpack_trees_porcelain(&o->unpack_opts, "merge");
@@ -396,16 +398,16 @@ static int unpack_trees_start(struct merge_options *o,
398
init_tree_desc_from_tree(t+2, merge);
399
400
rc = unpack_trees(3, t, &o->unpack_opts);
399
- cache_tree_free(&active_cache_tree);
401
+ cache_tree_free(&o->repo->index->cache_tree);
402
403
/*
402
- * Update the_index to match the new results, AFTER saving a copy
404
+ * Update o->repo->index to match the new results, AFTER saving a copy
405
* in o->orig_index. Update src_index to point to the saved copy.
406
* (verify_uptodate() checks src_index, and the original index is
407
* the one that had the necessary modification timestamps.)
408
*/
407
- o->orig_index = the_index;
408
- the_index = tmp_index;
409
+ o->orig_index = *o->repo->index;
410
+ *o->repo->index = tmp_index;
411
o->unpack_opts.src_index = &o->orig_index;
412
413
return rc;
@@ -420,12 +422,13 @@ static void unpack_trees_finish(struct merge_options *o)
422
struct tree *write_tree_from_memory(struct merge_options *o)
423
{
424
struct tree *result = NULL;
425
+ struct index_state *istate = o->repo->index;
426
424
- if (unmerged_cache()) {
427
+ if (unmerged_index(istate)) {
428
int i;
429
fprintf(stderr, "BUG: There are unmerged index entries:\n");
427
- for (i = 0; i < active_nr; i++) {
428
- const struct cache_entry *ce = active_cache[i];
430
+ for (i = 0; i < istate->cache_nr; i++) {
431
+ const struct cache_entry *ce = istate->cache[i];
432
if (ce_stage(ce))
433
fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce),
434
(int)ce_namelen(ce), ce->name);
@@ -433,16 +436,16 @@ struct tree *write_tree_from_memory(struct merge_options *o)
436
BUG("unmerged index entries in merge-recursive.c");
437
}
438
436
- if (!active_cache_tree)
437
- active_cache_tree = cache_tree();
439
+ if (!istate->cache_tree)
440
+ istate->cache_tree = cache_tree();
441
439
- if (!cache_tree_fully_valid(active_cache_tree) &&
440
- cache_tree_update(&the_index, 0) < 0) {
442
+ if (!cache_tree_fully_valid(istate->cache_tree) &&
443
+ cache_tree_update(istate, 0) < 0) {
444
err(o, _("error building trees"));
445
return NULL;
446
}
447
445
- result = lookup_tree(the_repository, &active_cache_tree->oid);
448
+ result = lookup_tree(the_repository, &istate->cache_tree->oid);
449
450
return result;
451
}
@@ -512,17 +515,17 @@ static struct stage_data *insert_stage_data(const char *path,
515
* Create a dictionary mapping file names to stage_data objects. The
516
* dictionary contains one entry for every path with a non-zero stage entry.
517
*/
515
-static struct string_list *get_unmerged(void)
518
+static struct string_list *get_unmerged(struct index_state *istate)
519
{
520
struct string_list *unmerged = xcalloc(1, sizeof(struct string_list));
521
int i;
522
523
unmerged->strdup_strings = 1;
524
522
- for (i = 0; i < active_nr; i++) {
525
+ for (i = 0; i < istate->cache_nr; i++) {
526
struct string_list_item *item;
527
struct stage_data *e;
525
- const struct cache_entry *ce = active_cache[i];
528
+ const struct cache_entry *ce = istate->cache[i];
529
if (!ce_stage(ce))
530
continue;
531
@@ -682,7 +685,7 @@ static int update_stages(struct merge_options *opt, const char *path,
685
int clear = 1;
686
int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
687
if (clear)
685
- if (remove_file_from_cache(path))
688
+ if (remove_file_from_index(opt->repo->index, path))
689
return -1;
690
if (o)
691
if (add_cacheinfo(opt, o->mode, &o->oid, path, 1, 0, options))
@@ -717,13 +720,14 @@ static int remove_file(struct merge_options *o, int clean,
720
int update_working_directory = !o->call_depth && !no_wd;
721
722
if (update_cache) {
720
- if (remove_file_from_cache(path))
723
+ if (remove_file_from_index(o->repo->index, path))
724
return -1;
725
}
726
if (update_working_directory) {
727
if (ignore_case) {
728
struct cache_entry *ce;
726
- ce = cache_file_exists(path, strlen(path), ignore_case);
729
+ ce = index_file_exists(o->repo->index, path, strlen(path),
730
+ ignore_case);
731
if (ce && ce_stage(ce) == 0 && strcmp(path, ce->name))
732
return 0;
733
}
@@ -773,7 +777,8 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
777
* check the working directory. If empty_ok is non-zero, also return
778
* 0 in the case where the working-tree dir exists but is empty.
779
*/
776
-static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
780
+static int dir_in_way(struct index_state *istate, const char *path,
781
+ int check_working_copy, int empty_ok)
782
{
783
int pos;
784
struct strbuf dirpath = STRBUF_INIT;
@@ -782,12 +787,12 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
787
strbuf_addstr(&dirpath, path);
788
strbuf_addch(&dirpath, '/');
789
785
- pos = cache_name_pos(dirpath.buf, dirpath.len);
790
+ pos = index_name_pos(istate, dirpath.buf, dirpath.len);
791
792
if (pos < 0)
793
pos = -1 - pos;
789
- if (pos < active_nr &&
790
- !strncmp(dirpath.buf, active_cache[pos]->name, dirpath.len)) {
794
+ if (pos < istate->cache_nr &&
795
+ !strncmp(dirpath.buf, istate->cache[pos]->name, dirpath.len)) {
796
strbuf_release(&dirpath);
797
return 1;
798
}
@@ -830,8 +835,10 @@ static int was_tracked(struct merge_options *o, const char *path)
835
return 0;
836
}
837
833
-static int would_lose_untracked(const char *path)
838
+static int would_lose_untracked(struct merge_options *o, const char *path)
839
{
840
+ struct index_state *istate = o->repo->index;
841
+
842
/*
843
* This may look like it can be simplified to:
844
* return !was_tracked(o, path) && file_exists(path)
@@ -849,19 +856,19 @@ static int would_lose_untracked(const char *path)
856
* update_file()/would_lose_untracked(); see every comment in this
857
* file which mentions "update_stages".
858
*/
852
- int pos = cache_name_pos(path, strlen(path));
859
+ int pos = index_name_pos(istate, path, strlen(path));
860
861
if (pos < 0)
862
pos = -1 - pos;
856
- while (pos < active_nr &&
857
- !strcmp(path, active_cache[pos]->name)) {
863
+ while (pos < istate->cache_nr &&
864
+ !strcmp(path, istate->cache[pos]->name)) {
865
/*
866
* If stage #0, it is definitely tracked.
867
* If it has stage #2 then it was tracked
868
* before this merge started. All other
869
* cases the path was not tracked.
870
*/
864
- switch (ce_stage(active_cache[pos])) {
871
+ switch (ce_stage(istate->cache[pos])) {
872
case 0:
873
case 2:
874
return 0;
@@ -921,7 +928,7 @@ static int make_room_for_path(struct merge_options *o, const char *path)
928
* Do not unlink a file in the work tree if we are not
929
* tracking it.
930
*/
924
- if (would_lose_untracked(path))
931
+ if (would_lose_untracked(o, path))
932
return err(o, _("refusing to lose untracked file at '%s'"),
933
path);
934
@@ -971,7 +978,7 @@ static int update_file_flags(struct merge_options *o,
978
}
979
if (S_ISREG(mode)) {
980
struct strbuf strbuf = STRBUF_INIT;
974
- if (convert_to_working_tree(&the_index, path, buf, size, &strbuf)) {
981
+ if (convert_to_working_tree(o->repo->index, path, buf, size, &strbuf)) {
982
free(buf);
983
size = strbuf.len;
984
buf = strbuf_detach(&strbuf, NULL);
@@ -1091,7 +1098,7 @@ static int merge_3way(struct merge_options *o,
1098
1099
merge_status = ll_merge(result_buf, a->path, &orig, base_name,
1100
&src1, name1, &src2, name2,
1094
- &the_index, &ll_opts);
1101
+ o->repo->index, &ll_opts);
1102
1103
free(base_name);
1104
free(name1);
@@ -1102,7 +1109,8 @@ static int merge_3way(struct merge_options *o,
1109
return merge_status;
1110
}
1111
1105
-static int find_first_merges(struct object_array *result, const char *path,
1112
+static int find_first_merges(struct repository *repo,
1113
+ struct object_array *result, const char *path,
1114
struct commit *a, struct commit *b)
1115
{
1116
int i, j;
@@ -1122,7 +1130,7 @@ static int find_first_merges(struct object_array *result, const char *path,
1130
/* get all revisions that merge commit a */
1131
xsnprintf(merged_revision, sizeof(merged_revision), "^%s",
1132
oid_to_hex(&a->object.oid));
1125
- repo_init_revisions(the_repository, &revs, NULL);
1133
+ repo_init_revisions(repo, &revs, NULL);
1134
rev_opts.submodule = path;
1135
/* FIXME: can't handle linked worktrees in submodules yet */
1136
revs.single_worktree = path != NULL;
@@ -1252,7 +1260,8 @@ static int merge_submodule(struct merge_options *o,
1260
return 0;
1261
1262
/* find commit which merges them */
1255
- parent_count = find_first_merges(&merges, path, commit_a, commit_b);
1263
+ parent_count = find_first_merges(o->repo, &merges, path,
1264
+ commit_a, commit_b);
1265
switch (parent_count) {
1266
case 0:
1267
output(o, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
@@ -1400,7 +1409,7 @@ static int handle_rename_via_dir(struct merge_options *o,
1409
*/
1410
const struct diff_filespec *dest = pair->two;
1411
1403
- if (!o->call_depth && would_lose_untracked(dest->path)) {
1412
+ if (!o->call_depth && would_lose_untracked(o, dest->path)) {
1413
char *alt_path = unique_path(o, dest->path, rename_branch);
1414
1415
output(o, 1, _("Error: Refusing to lose untracked file at %s; "
@@ -1438,8 +1447,8 @@ static int handle_change_delete(struct merge_options *o,
1447
const char *update_path = path;
1448
int ret = 0;
1449
1441
- if (dir_in_way(path, !o->call_depth, 0) ||
1442
- (!o->call_depth && would_lose_untracked(path))) {
1450
+ if (dir_in_way(o->repo->index, path, !o->call_depth, 0) ||
1451
+ (!o->call_depth && would_lose_untracked(o, path))) {
1452
update_path = alt_path = unique_path(o, path, change_branch);
1453
}
1454
@@ -1449,7 +1458,7 @@ static int handle_change_delete(struct merge_options *o,
1458
* correct; since there is no true "middle point" between
1459
* them, simply reuse the base version for virtual merge base.
1460
*/
1452
- ret = remove_file_from_cache(path);
1461
+ ret = remove_file_from_index(o->repo->index, path);
1462
if (!ret)
1463
ret = update_file(o, 0, o_oid, o_mode, update_path);
1464
} else {
@@ -1525,7 +1534,7 @@ static int handle_rename_delete(struct merge_options *o,
1534
return -1;
1535
1536
if (o->call_depth)
1528
- return remove_file_from_cache(dest->path);
1537
+ return remove_file_from_index(o->repo->index, dest->path);
1538
else
1539
return update_stages(o, dest->path, NULL,
1540
rename_branch == o->branch1 ? dest : NULL,
@@ -1606,10 +1615,10 @@ static int handle_file_collision(struct merge_options *o,
1615
/* Remove rename sources if rename/add or rename/rename(2to1) */
1616
if (prev_path1)
1617
remove_file(o, 1, prev_path1,
1609
- o->call_depth || would_lose_untracked(prev_path1));
1618
+ o->call_depth || would_lose_untracked(o, prev_path1));
1619
if (prev_path2)
1620
remove_file(o, 1, prev_path2,
1612
- o->call_depth || would_lose_untracked(prev_path2));
1621
+ o->call_depth || would_lose_untracked(o, prev_path2));
1622
1623
/*
1624
* Remove the collision path, if it wouldn't cause dirty contents
@@ -1620,7 +1629,7 @@ static int handle_file_collision(struct merge_options *o,
1629
output(o, 1, _("Refusing to lose dirty file at %s"),
1630
collide_path);
1631
update_path = alt_path = unique_path(o, collide_path, "merged");
1623
- } else if (would_lose_untracked(collide_path)) {
1632
+ } else if (would_lose_untracked(o, collide_path)) {
1633
/*
1634
* Only way we get here is if both renames were from
1635
* a directory rename AND user had an untracked file
@@ -1716,12 +1725,12 @@ static char *find_path_for_conflict(struct merge_options *o,
1725
const char *branch2)
1726
{
1727
char *new_path = NULL;
1719
- if (dir_in_way(path, !o->call_depth, 0)) {
1728
+ if (dir_in_way(o->repo->index, path, !o->call_depth, 0)) {
1729
new_path = unique_path(o, path, branch1);
1730
output(o, 1, _("%s is a directory in %s adding "
1731
"as %s instead"),
1732
path, branch2, new_path);
1724
- } else if (would_lose_untracked(path)) {
1733
+ } else if (would_lose_untracked(o, path)) {
1734
new_path = unique_path(o, path, branch1);
1735
output(o, 1, _("Refusing to lose untracked file"
1736
" at %s; adding as %s instead"),
@@ -1782,14 +1791,14 @@ static int handle_rename_rename_1to2(struct merge_options *o,
1791
return -1;
1792
}
1793
else
1785
- remove_file_from_cache(a->path);
1794
+ remove_file_from_index(o->repo->index, a->path);
1795
add = filespec_from_entry(&other, ci->dst_entry2, 3 ^ 1);
1796
if (add) {
1797
if (update_file(o, 0, &add->oid, add->mode, b->path))
1798
return -1;
1799
}
1800
else
1792
- remove_file_from_cache(b->path);
1801
+ remove_file_from_index(o->repo->index, b->path);
1802
} else {
1803
/*
1804
* For each destination path, we need to see if there is a
@@ -1886,7 +1895,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *o,
1895
struct diff_queue_struct *ret;
1896
struct diff_options opts;
1897
1889
- repo_diff_setup(the_repository, &opts);
1898
+ repo_diff_setup(o->repo, &opts);
1899
opts.flags.recursive = 1;
1900
opts.flags.rename_empty = 0;
1901
opts.detect_rename = merge_detect_rename(o);
@@ -3041,8 +3050,8 @@ static int blob_unchanged(struct merge_options *opt,
3050
* performed. Comparison can be skipped if both files are
3051
* unchanged since their sha1s have already been compared.
3052
*/
3044
- if (renormalize_buffer(&the_index, path, o.buf, o.len, &o) |
3045
- renormalize_buffer(&the_index, path, a.buf, a.len, &a))
3053
+ if (renormalize_buffer(opt->repo->index, path, o.buf, o.len, &o) |
3054
+ renormalize_buffer(opt->repo->index, path, a.buf, a.len, &a))
3055
ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
3056
3057
error_return:
@@ -3123,7 +3132,7 @@ static int handle_content_merge(struct merge_options *o,
3132
a.path = (char *)path1;
3133
b.path = (char *)path2;
3134
3126
- if (dir_in_way(path, !o->call_depth,
3135
+ if (dir_in_way(o->repo->index, path, !o->call_depth,
3136
S_ISGITLINK(pair1->two->mode)))
3137
df_conflict_remains = 1;
3138
}
@@ -3157,8 +3166,8 @@ static int handle_content_merge(struct merge_options *o,
3166
pos = index_name_pos(&o->orig_index, path, strlen(path));
3167
ce = o->orig_index.cache[pos];
3168
if (ce_skip_worktree(ce)) {
3160
- pos = index_name_pos(&the_index, path, strlen(path));
3161
- ce = the_index.cache[pos];
3169
+ pos = index_name_pos(o->repo->index, path, strlen(path));
3170
+ ce = o->repo->index->cache[pos];
3171
ce->ce_flags |= CE_SKIP_WORKTREE;
3172
}
3173
return mfi.clean;
@@ -3177,7 +3186,7 @@ static int handle_content_merge(struct merge_options *o,
3186
if (df_conflict_remains || is_dirty) {
3187
char *new_path;
3188
if (o->call_depth) {
3180
- remove_file_from_cache(path);
3189
+ remove_file_from_index(o->repo->index, path);
3190
} else {
3191
if (!mfi.clean) {
3192
if (update_stages(o, path, &one, &a, &b))
@@ -3337,7 +3346,7 @@ static int process_entry(struct merge_options *o,
3346
oid = b_oid;
3347
conf = _("directory/file");
3348
}
3340
- if (dir_in_way(path,
3349
+ if (dir_in_way(o->repo->index, path,
3350
!o->call_depth && !S_ISGITLINK(a_mode),
3351
0)) {
3352
char *new_path = unique_path(o, path, add_branch);
@@ -3348,7 +3357,7 @@ static int process_entry(struct merge_options *o,
3357
if (update_file(o, 0, oid, mode, new_path))
3358
clean_merge = -1;
3359
else if (o->call_depth)
3351
- remove_file_from_cache(path);
3360
+ remove_file_from_index(o->repo->index, path);
3361
free(new_path);
3362
} else {
3363
output(o, 2, _("Adding %s"), path);
@@ -3396,10 +3405,11 @@ int merge_trees(struct merge_options *o,
3405
struct tree *common,
3406
struct tree **result)
3407
{
3408
+ struct index_state *istate = o->repo->index;
3409
int code, clean;
3410
struct strbuf sb = STRBUF_INIT;
3411
3402
- if (!o->call_depth && index_has_changes(&the_index, head, &sb)) {
3412
+ if (!o->call_depth && index_has_changes(istate, head, &sb)) {
3413
err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"),
3414
sb.buf);
3415
return -1;
@@ -3427,7 +3437,7 @@ int merge_trees(struct merge_options *o,
3437
return -1;
3438
}
3439
3430
- if (unmerged_cache()) {
3440
+ if (unmerged_index(istate)) {
3441
struct string_list *entries;
3442
struct rename_info re_info;
3443
int i;
@@ -3442,7 +3452,7 @@ int merge_trees(struct merge_options *o,
3452
get_files_dirs(o, head);
3453
get_files_dirs(o, merge);
3454
3445
- entries = get_unmerged();
3455
+ entries = get_unmerged(o->repo->index);
3456
clean = detect_and_process_renames(o, common, head, merge,
3457
entries, &re_info);
3458
record_df_conflict_files(o, entries);
@@ -3558,7 +3568,7 @@ int merge_recursive(struct merge_options *o,
3568
* overwritten it: the committed "conflicts" were
3569
* already resolved.
3570
*/
3561
- discard_cache();
3571
+ discard_index(o->repo->index);
3572
saved_b1 = o->branch1;
3573
saved_b2 = o->branch2;
3574
o->branch1 = "Temporary merge branch 1";
@@ -3574,9 +3584,9 @@ int merge_recursive(struct merge_options *o,
3584
return err(o, _("merge returned no commit"));
3585
}
3586
3577
- discard_cache();
3587
+ discard_index(o->repo->index);
3588
if (!o->call_depth)
3579
- repo_read_index(the_repository);
3589
+ repo_read_index(o->repo);
3590
3591
o->ancestor = "merged common ancestors";
3592
clean = merge_trees(o, get_commit_tree(h1), get_commit_tree(h2),
@@ -3643,7 +3653,7 @@ int merge_recursive_generic(struct merge_options *o,
3653
}
3654
}
3655
3646
- repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
3656
+ repo_hold_locked_index(o->repo, &lock, LOCK_DIE_ON_ERROR);
3657
clean = merge_recursive(o, head_commit, next_commit, ca,
3658
result);
3659
if (clean < 0) {
@@ -3651,7 +3661,7 @@ int merge_recursive_generic(struct merge_options *o,
3661
return clean;
3662
}
3663
3654
- if (write_locked_index(&the_index, &lock,
3664
+ if (write_locked_index(o->repo->index, &lock,
3665
COMMIT_LOCK | SKIP_IF_UNCHANGED))
3666
return err(o, _("Unable to write index."));
3667
@@ -3675,10 +3685,12 @@ static void merge_recursive_config(struct merge_options *o)
3685
git_config(git_xmerge_config, NULL);
3686
}
3687
3678
-void init_merge_options(struct merge_options *o)
3688
+void init_merge_options(struct merge_options *o,
3689
+ struct repository *repo)
3690
{
3691
const char *merge_verbosity;
3692
memset(o, 0, sizeof(struct merge_options));
3693
+ o->repo = repo;
3694
o->verbosity = 2;
3695
o->buffer_output = 1;
3696
o->diff_rename_limit = -1;
merge-recursive.h
+5
-1
@@ -6,6 +6,8 @@
6
7
struct commit;
8
9
+struct repository;
10
+
11
struct merge_options {
12
const char *ancestor;
13
const char *branch1;
@@ -34,6 +36,7 @@ struct merge_options {
36
struct string_list df_conflict_file_set;
37
struct unpack_trees_options unpack_opts;
38
struct index_state orig_index;
39
+ struct repository *repo;
40
};
41
42
/*
@@ -92,7 +95,8 @@ int merge_recursive_generic(struct merge_options *o,
95
const struct object_id **ca,
96
struct commit **result);
97
95
-void init_merge_options(struct merge_options *o);
98
+void init_merge_options(struct merge_options *o,
99
+ struct repository *repo);
100
struct tree *write_tree_from_memory(struct merge_options *o);
101
102
int parse_merge_opt(struct merge_options *out, const char *s);
sequencer.c
+2
-2
@@ -545,7 +545,7 @@ static int do_recursive_merge(struct repository *r,
545
546
repo_read_index(r);
547
548
- init_merge_options(&o);
548
+ init_merge_options(&o, r);
549
o.ancestor = base ? base_label : "(empty tree)";
550
o.branch1 = "HEAD";
551
o.branch2 = next ? next_label : "(empty tree)";
@@ -3300,7 +3300,7 @@ static int do_merge(struct repository *r,
3300
free_commit_list(bases);
3301
3302
repo_read_index(r);
3303
- init_merge_options(&o);
3303
+ init_merge_options(&o, r);
3304
o.branch1 = "HEAD";
3305
o.branch2 = ref_name.buf;
3306
o.buffer_output = 2;