]> arthur.barton.de Git - bup.git/commit - lib/bup/git.py
PackWriter: match git's pack names
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 22 Jul 2020 06:59:32 +0000 (08:59 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 15 May 2021 18:57:24 +0000 (13:57 -0500)
commitbb0e9cbf3900e65d2fddbe888e6cb21c59b308df
tree8d0effe53ae7d727aab124c6ff0f9ecb028da6ed
parente9be4dfbd56d62c924c6b71c4600c4381e1f5baa
PackWriter: match git's pack names

As reported by Jamie Wyrick, git appears to use the sha1 of
the entire pack file as the (default) name for it, not the
sha1(sorted-object-list) as the git-index-pack man page seems
to imply, since it says:

  Once the index has been created, the list of object names is
  sorted and the SHA-1 hash of that list is printed to stdout.
  If --stdin was also used then this is prefixed by either
  "pack\t", or "keep\t" if a new .keep file was successfully
  created. This is useful to remove a .keep file used as a lock
  to prevent the race with git repack mentioned above.

while also saying:

  If <pack-file> is not specified, the pack is written to
  objects/pack/ directory of the current Git repository with a
  default name determined from the pack content.

Originally, git-index-pack was used by bup, and when that was
changed, the naming convention was kept, presumably according
to this documentation; see commit 4cab9ab71fff ("Write idxs
directly rather than using git-index-pack.")

Change things to use the pack's entire content sha1, that we
calculate anyway, as the name.

This requires updating the 'gc' test to not compare by name
but by (index) content.

Also add a test that our behaviour matches git's.

Reported-by: Jamie Wyrick <terrifiedquack80@gmail.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
lib/bup/git.py
test/ext/test-gc
test/ext/test-misc