merge: check config before loading commits
commit7adf526670c5c050ddc22ddcf2fdc7bd654f8fc5
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 1 May 2018 12:47:23 +0000 (1 12:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 May 2018 03:36:34 +0000 (22 12:36 +0900)
tree59cef4876425b9958663eb1aec08859ed80ab873
parent04bc8d1ecc30bae9589f3d77a0a89f3dca28a024
merge: check config before loading commits

Now that we use generation numbers from the commit-graph, we must
ensure that all commits that exist in the commit-graph are loaded
from that file instead of from the object database. Since the
commit-graph file is only checked if core.commitGraph is true, we
must check the default config before we load any commits.

In the merge builtin, the config was checked after loading the HEAD
commit. This was due to the use of the global 'branch' when checking
merge-specific config settings.

Move the config load to be between the initialization of 'branch' and
the commit lookup.

Without this change, a fast-forward merge would hit a BUG("bad
generation skip") statement in commit.c during paint_down_to_common().
This is because the HEAD commit would be loaded with "infinite"
generation but then reached by commits with "finite" generation
numbers.

Add a test to t5318-commit-graph.sh that exercises this code path to
prevent a regression.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge.c
t/t5318-commit-graph.sh