]> git.ipfire.org Git - thirdparty/git.git/commit
commit: add short-circuit to paint_down_to_common()
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 1 May 2018 12:47:19 +0000 (12:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 May 2018 03:36:34 +0000 (12:36 +0900)
commitd7c1ec3efd0092ee665085cba4e8a2bcef95143b
tree8e4ccc4f744dc062cbe1b0f86b937d6ead36c69d
parentf9b8908b85247ef60001a683c281af0080e9ee77
commit: add short-circuit to paint_down_to_common()

When running 'git branch --contains', the in_merge_bases_many()
method calls paint_down_to_common() to discover if a specific
commit is reachable from a set of branches. Commits with lower
generation number are not needed to correctly answer the
containment query of in_merge_bases_many().

Add a new parameter, min_generation, to paint_down_to_common() that
prevents walking commits with generation number strictly less than
min_generation. If 0 is given, then there is no functional change.

For in_merge_bases_many(), we can pass commit->generation as the
cutoff, and this saves time during 'git branch --contains' queries
that would otherwise walk "around" the commit we are inspecting.

For a copy of the Linux repository, where HEAD is checked out at
v4.13~100, we get the following performance improvement for
'git branch --contains' over the previous commit:

Before: 0.21s
After:  0.13s
Rel %: -38%

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c