pull: Error on depth pull with missing head commit
authorDan Nicholson <dbn@endlessos.org>
Mon, 11 Jan 2021 19:40:38 +0000 (12:40 -0700)
committerDan Nicholson <dbn@endlessos.org>
Tue, 12 Jan 2021 21:19:01 +0000 (14:19 -0700)
commit20047ff1fea1b0d9193ee21d6df72d70b086090d
treeef662c7f0c50a5226a423c53ecdcf1fd812ce7cb
parentb4f06b47a38cea303f678e20d89943a2187b963f
pull: Error on depth pull with missing head commit

When pulling with depth, missing parent commits are ignored. However,
the check was applying to any commit, which means that it would succeed
even if the requested commit was missing. This might happen on a
corrupted remote repo or when using ref data from a stale summary.

To achieve this, the semantics of the `commit_to_depth` hash table is
changed slightly to only ever includes parent commits. This makes it
easy to detect when a parent commit is being referenced (although there
is a minor bug there when multiple refs are being pulled) while keeping
references to commits that need their `commitpartial` files cleaned up.
It also means that the table is only populated on depth pulls, which
saves some memory and processing in the common depth=0 case.

Fixes: #2265
src/libostree/ostree-repo-pull-private.h
src/libostree/ostree-repo-pull.c
tests/test-pull-depth.sh