From: Sun Chao <[email protected]>
When a packed ref is deleted, the whole packed-refs file is
rewrite and omit the ref that no longer exists. However if
another gc command is running and call `pack-refs --all`
simultaneously, there is a change that a ref just updated
will lost the newly commits.
There are two valid methods to avoid losting commit of ref:
- force `update-ref -d` to update the snapshot before
rewrite packed-refs.
- do not pack a recently updated ref, where *recently*
could be set by *pack.looserefsexpire* option.
I prefer **do not pack a recently updated ref**, here is the
reasons:
1. It could avoid losting the newly commit of a ref which I
described upon.
2. Sometime, the git server will do `pack-refs --all` and
`update-ref` the same time, and the two commands have
chances to trying lock the same ref such as master, if
this happends one command will fail with such error:
**cannot lock ref 'refs/heads/master'**
This could happen if a ref is updated frequently, and
avoid pack the ref which is update recently could avoid
this error most of the time.
Sun Chao (1):
pack-refs: pack expired loose refs to packed_refs
builtin/pack-refs.c | 13 ++++++++++++-
refs.c | 4 ++--
refs.h | 2 +-
refs/files-backend.c | 18 +++++++++++++++++-
refs/packed-backend.c | 2 +-
refs/refs-internal.h | 2 +-
t/helper/test-ref-store.c | 2 +-
7 files changed, 35 insertions(+), 8 deletions(-)
--
2.22.0.214.g8dca754b1e