Skip to content

Commit 816147e

Browse files
newrengitster
authored andcommitted
merge-recursive: add a bunch of FIXME comments documenting known bugs
The plan is to just delete merge-recursive, but not until everyone is comfortable with merge-ort as a replacement. Given that I haven't switched all callers of merge-recursive over yet (e.g. git-am still uses merge-recursive), maybe there's some value documenting known bugs in the algorithm in case we end up keeping it or someone wants to dig it up in the future. Signed-off-by: Elijah Newren <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5291828 commit 816147e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

merge-recursive.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,11 @@ static int merge_3way(struct merge_options *opt,
10751075
read_mmblob(&src1, &a->oid);
10761076
read_mmblob(&src2, &b->oid);
10771077

1078+
/*
1079+
* FIXME: Using a->path for normalization rules in ll_merge could be
1080+
* wrong if we renamed from a->path to b->path. We should use the
1081+
* target path for where the file will be written.
1082+
*/
10781083
merge_status = ll_merge(result_buf, a->path, &orig, base,
10791084
&src1, name1, &src2, name2,
10801085
opt->repo->index, &ll_opts);
@@ -1154,6 +1159,8 @@ static void print_commit(struct commit *commit)
11541159
struct strbuf sb = STRBUF_INIT;
11551160
struct pretty_print_context ctx = {0};
11561161
ctx.date_mode.type = DATE_NORMAL;
1162+
/* FIXME: Merge this with output_commit_title() */
1163+
assert(!merge_remote_util(commit));
11571164
format_commit_message(commit, " %h: %m %s", &sb, &ctx);
11581165
fprintf(stderr, "%s\n", sb.buf);
11591166
strbuf_release(&sb);
@@ -1177,6 +1184,11 @@ static int merge_submodule(struct merge_options *opt,
11771184
int search = !opt->priv->call_depth;
11781185

11791186
/* store a in result in case we fail */
1187+
/* FIXME: This is the WRONG resolution for the recursive case when
1188+
* we need to be careful to avoid accidentally matching either side.
1189+
* Should probably use o instead there, much like we do for merging
1190+
* binaries.
1191+
*/
11801192
oidcpy(result, a);
11811193

11821194
/* we can not handle deletion conflicts */
@@ -1301,6 +1313,13 @@ static int merge_mode_and_contents(struct merge_options *opt,
13011313

13021314
if ((S_IFMT & a->mode) != (S_IFMT & b->mode)) {
13031315
result->clean = 0;
1316+
/*
1317+
* FIXME: This is a bad resolution for recursive case; for
1318+
* the recursive case we want something that is unlikely to
1319+
* accidentally match either side. Also, while it makes
1320+
* sense to prefer regular files over symlinks, it doesn't
1321+
* make sense to prefer regular files over submodules.
1322+
*/
13041323
if (S_ISREG(a->mode)) {
13051324
result->blob.mode = a->mode;
13061325
oidcpy(&result->blob.oid, &a->oid);
@@ -1349,6 +1368,7 @@ static int merge_mode_and_contents(struct merge_options *opt,
13491368
free(result_buf.ptr);
13501369
if (ret)
13511370
return ret;
1371+
/* FIXME: bug, what if modes didn't match? */
13521372
result->clean = (merge_status == 0);
13531373
} else if (S_ISGITLINK(a->mode)) {
13541374
result->clean = merge_submodule(opt, &result->blob.oid,
@@ -2664,6 +2684,14 @@ static int process_renames(struct merge_options *opt,
26642684
struct string_list b_by_dst = STRING_LIST_INIT_NODUP;
26652685
const struct rename *sre;
26662686

2687+
/*
2688+
* FIXME: As string-list.h notes, it's O(n^2) to build a sorted
2689+
* string_list one-by-one, but O(n log n) to build it unsorted and
2690+
* then sort it. Note that as we build the list, we do not need to
2691+
* check if the existing destination path is already in the list,
2692+
* because the structure of diffcore_rename guarantees we won't
2693+
* have duplicates.
2694+
*/
26672695
for (i = 0; i < a_renames->nr; i++) {
26682696
sre = a_renames->items[i].util;
26692697
string_list_insert(&a_by_dst, sre->pair->two->path)->util
@@ -3602,6 +3630,15 @@ static int merge_recursive_internal(struct merge_options *opt,
36023630
return err(opt, _("merge returned no commit"));
36033631
}
36043632

3633+
/*
3634+
* FIXME: Since merge_recursive_internal() is only ever called by
3635+
* places that ensure the index is loaded first
3636+
* (e.g. builtin/merge.c, rebase/sequencer, etc.), in the common
3637+
* case where the merge base was unique that means when we get here
3638+
* we immediately discard the index and re-read it, which is a
3639+
* complete waste of time. We should only be discarding and
3640+
* re-reading if we were forced to recurse.
3641+
*/
36053642
discard_index(opt->repo->index);
36063643
if (!opt->priv->call_depth)
36073644
repo_read_index(opt->repo);

0 commit comments

Comments
 (0)