Skip to content

Commit b27a79d

Browse files
committed
Merge branch 'kb/full-history-compute-treesame-carefully-2'
Major update to the revision traversal logic to improve culling of irrelevant parents while traversing a mergy history. * kb/full-history-compute-treesame-carefully-2: revision.c: make default history consider bottom commits revision.c: don't show all merges for --parents revision.c: discount side branches when computing TREESAME revision.c: add BOTTOM flag for commits simplify-merges: drop merge from irrelevant side branch simplify-merges: never remove all TREESAME parents t6012: update test for tweaked full-history traversal revision.c: Make --full-history consider more merges Documentation: avoid "uninteresting" rev-list-options.txt: correct TREESAME for P t6111: add parents to tests t6111: allow checking the parents as well t6111: new TREESAME test set t6019: test file dropped in -s ours merge decorate.c: compact table when growing
2 parents 91d34bc + 141efdb commit b27a79d

File tree

7 files changed

+750
-91
lines changed

7 files changed

+750
-91
lines changed

Documentation/rev-list-options.txt

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ See also linkgit:git-reflog[1].
271271

272272
--boundary::
273273

274-
Output uninteresting commits at the boundary, which are usually
275-
not shown.
274+
Output excluded boundary commits. Boundary commits are
275+
prefixed with `-`.
276276

277277
--
278278

@@ -342,13 +342,13 @@ In the following, we will always refer to the same example history to
342342
illustrate the differences between simplification settings. We assume
343343
that you are filtering for a file `foo` in this commit graph:
344344
-----------------------------------------------------------------------
345-
.-A---M---N---O---P
346-
/ / / / /
347-
I B C D E
348-
\ / / / /
349-
`-------------'
345+
.-A---M---N---O---P---Q
346+
/ / / / / /
347+
I B C D E Y
348+
\ / / / / /
349+
`-------------' X
350350
-----------------------------------------------------------------------
351-
The horizontal line of history A---P is taken to be the first parent of
351+
The horizontal line of history A---Q is taken to be the first parent of
352352
each merge. The commits are:
353353

354354
* `I` is the initial commit, in which `foo` exists with contents
@@ -367,8 +367,11 @@ each merge. The commits are:
367367
`N` and `D` to "foobarbaz"; i.e., it is not TREESAME to any parent.
368368

369369
* `E` changes `quux` to "xyzzy", and its merge `P` combines the
370-
strings to "quux xyzzy". Despite appearing interesting, `P` is
371-
TREESAME to all parents.
370+
strings to "quux xyzzy". `P` is TREESAME to `O`, but not to `E`.
371+
372+
* `X` is an indpendent root commit that added a new file `side`, and `Y`
373+
modified it. `Y` is TREESAME to `X`. Its merge `Q` added `side` to `P`, and
374+
`Q` is TREESAME to `P`, but not to `Y`.
372375

373376
'rev-list' walks backwards through history, including or excluding
374377
commits based on whether '\--full-history' and/or parent rewriting
@@ -410,10 +413,10 @@ parent lines.
410413
the example, we get
411414
+
412415
-----------------------------------------------------------------------
413-
I A B N D O
416+
I A B N D O P Q
414417
-----------------------------------------------------------------------
415418
+
416-
`P` and `M` were excluded because they are TREESAME to a parent. `E`,
419+
`M` was excluded because it is TREESAME to both parents. `E`,
417420
`C` and `B` were all walked, but only `B` was !TREESAME, so the others
418421
do not appear.
419422
+
@@ -431,7 +434,7 @@ Along each parent, prune away commits that are not included
431434
themselves. This results in
432435
+
433436
-----------------------------------------------------------------------
434-
.-A---M---N---O---P
437+
.-A---M---N---O---P---Q
435438
/ / / / /
436439
I B / D /
437440
\ / / / /
@@ -441,7 +444,7 @@ themselves. This results in
441444
Compare to '\--full-history' without rewriting above. Note that `E`
442445
was pruned away because it is TREESAME, but the parent list of P was
443446
rewritten to contain `E`'s parent `I`. The same happened for `C` and
444-
`N`. Note also that `P` was included despite being TREESAME.
447+
`N`, and `X`, `Y` and `Q`.
445448

446449
In addition to the above settings, you can change whether TREESAME
447450
affects inclusion:
@@ -471,8 +474,9 @@ history according to the following rules:
471474
* Set `C'` to `C`.
472475
+
473476
* Replace each parent `P` of `C'` with its simplification `P'`. In
474-
the process, drop parents that are ancestors of other parents, and
475-
remove duplicates.
477+
the process, drop parents that are ancestors of other parents or that are
478+
root commits TREESAME to an empty tree, and remove duplicates, but take care
479+
to never drop all parents that we are TREESAME to.
476480
+
477481
* If after this parent rewriting, `C'` is a root or merge commit (has
478482
zero or >1 parents), a boundary commit, or !TREESAME, it remains.
@@ -490,14 +494,18 @@ The effect of this is best shown by way of comparing to
490494
`---------'
491495
-----------------------------------------------------------------------
492496
+
493-
Note the major differences in `N` and `P` over '--full-history':
497+
Note the major differences in `N`, `P` and `Q` over '--full-history':
494498
+
495499
--
496500
* `N`'s parent list had `I` removed, because it is an ancestor of the
497501
other parent `M`. Still, `N` remained because it is !TREESAME.
498502
+
499503
* `P`'s parent list similarly had `I` removed. `P` was then
500504
removed completely, because it had one parent and is TREESAME.
505+
+
506+
* `Q`'s parent list had `Y` simplified to `X`. `X` was then removed, because it
507+
was a TREESAME root. `Q` was then removed completely, because it had one
508+
parent and is TREESAME.
501509
--
502510

503511
Finally, there is a fifth simplification mode available:

decorate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void grow_decoration(struct decoration *n)
4949
const struct object *base = old_hash[i].base;
5050
void *decoration = old_hash[i].decoration;
5151

52-
if (!base)
52+
if (!decoration)
5353
continue;
5454
insert_decoration(n, base, decoration);
5555
}

0 commit comments

Comments
 (0)