jobd/gc.sh: check the "repack" "signature" before skipping gc
commita74b8e3dbfe9a0a52ea99fbd00c9ecb94fa30e49
authorKyle J. McKay <mackyle@gmail.com>
Tue, 30 Jun 2020 04:54:59 +0000 (29 21:54 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Tue, 30 Jun 2020 04:54:59 +0000 (29 21:54 -0700)
tree85bd99782276bdfad27ecdfcbb242741f891c970
parent13e895cac0e6b5fa17fa74c963f7f5c6dcd8242c
jobd/gc.sh: check the "repack" "signature" before skipping gc

Compute and check the third and final "signature" hash before
actually allowing gc to be skipped (because there's nothing to do).

This computation only takes place if the other two "signature"
hashes match and the repository is not considered "dirty".

Since it's not possible to perform the computation until after
`make_repack_dir` has been run, the check to skip is now postponed.

As a result, expiration of reflogs, worktrees and rerere information
will now continue to take place on a regular basis even when full
gc gets skipped (because there was nothing to do).  This corrects
a longstanding "feature" which only came into play if worktrees,
reflogs and or rerere information was in use via a non-Girocco
mechanism.

For optimization reasons, all refs are also packed before performing
the expiration tasks or checking to seek if gc can truly be skipped.
As a result the `packed-refs` file in the repository will always
get a fresh timestamp on it since Git is not smart enough to leave
it alone when `git pack-refs --all` is run and there are no refs
to pack regardless of whether or not gc ultimately gets skipped.

Since the computation of the "repack" "signature" hash involves a
bit more work than the other two "signature" hashes, optimize the
initial check of the other two "signature" hashes to not actually
do any computations and just disable skipping gc unless all three
previous "signature" hash values exist and are non-empty.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/gc.sh