]> git.ipfire.org Git - thirdparty/git.git/commit
rebase -i: demonstrate obscure loose object cache bug
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 13 Mar 2019 10:16:31 +0000 (03:16 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Mar 2019 03:46:29 +0000 (12:46 +0900)
commit26527ed86ec373b1063016a4df46d90a36f9c089
tree9b0ff089794baa25067a125e2393fd84bd10302a
parente902e9bcae2010bc42648c80ab6adc6c5a16a4a5
rebase -i: demonstrate obscure loose object cache bug

We specifically support `exec` commands in `git rebase -i`'s todo lists
to rewrite the very same todo list. Of course, we need to validate that
todo list when re-reading it.

It is also totally legitimate to extend the todo list by `pick` lines
using short names of commits that were created only after the rebase
started.

And this is where the loose object cache interferes with this feature:
if *some* loose object was read whose hash shares the same first two
digits with a commit that was not yet created when that loose object was
created, then we fail to find that new commit by its short name in
`get_oid()`, and the interactive rebase fails with an obscure error
message like:

error: invalid line 1: pick 6568fef
error: please fix this using 'git rebase --edit-todo'.

Let's first demonstrate that this is actually a bug in a new regression
test, in a separate commit so that other developers who do not believe
me can cherry-pick it to confirm the problem.

This new regression test generates two commits whose hashes share the
first two hex digits (so that their corresponding loose objects live in
the same subdirectory of .git/objects/, and are therefore supposed to be
in the same loose object cache bin).

It then picks the first, to make sure that the loose object cache is
initialized and cached that object directory, then generates the second
commit and picks it, too. Since the commit was generated in a different
process than the sequencer that wants to pick it, the loose object cache
had no chance of being updated in the meantime.

Technically, we would need only one `exec` command in this regression
test case, but for ease of implementation, it uses a pseudo-recursive
call to the same script.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3429-rebase-edit-todo.sh