Skip to content

Commit 23822a3

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
read-tree: --trivial
This adds an option --trivial to restrict 3-way 'read-tree -m -u' to happen only if there is no file-level merging required. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 500b97e commit 23822a3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

read-tree.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
static int merge = 0;
1414
static int update = 0;
1515
static int index_only = 0;
16+
static int nontrivial_merge = 0;
17+
static int trivial_merges_only = 0;
1618

1719
static int head_idx = -1;
1820
static int merge_size = 0;
@@ -275,6 +277,9 @@ static int unpack_trees(merge_fn_t fn)
275277
if (unpack_trees_rec(posns, len, "", fn, &indpos))
276278
return -1;
277279

280+
if (trivial_merges_only && nontrivial_merge)
281+
die("Merge requires file-level merging");
282+
278283
check_updates(active_cache, active_nr);
279284
return 0;
280285
}
@@ -460,6 +465,8 @@ static int threeway_merge(struct cache_entry **stages)
460465
verify_uptodate(index);
461466
}
462467

468+
nontrivial_merge = 1;
469+
463470
/* #2, #3, #4, #6, #7, #9, #11. */
464471
count = 0;
465472
if (!head_match || !remote_match) {
@@ -629,6 +636,11 @@ int main(int argc, char **argv)
629636
continue;
630637
}
631638

639+
if (!strcmp(arg, "--trivial")) {
640+
trivial_merges_only = 1;
641+
continue;
642+
}
643+
632644
/* "-m" stands for "merge", meaning we start in stage 1 */
633645
if (!strcmp(arg, "-m")) {
634646
if (stage || merge)

0 commit comments

Comments
 (0)