]> git.ipfire.org Git - thirdparty/git.git/commit
midx: fix `*.rev` cleanups with `--object-dir`
authorTaylor Blau <me@ttaylorr.com>
Tue, 31 Aug 2021 20:51:55 +0000 (16:51 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Sep 2021 17:58:43 +0000 (10:58 -0700)
commit426c00e4541367bcd96e542f971d8995e3bb1d54
tree8f8ea263e626de90aec04c51e5201ef62f969f9f
parent73ff4ad086d1a205194e23344bb86ee3b3da0674
midx: fix `*.rev` cleanups with `--object-dir`

If using --object-dir to point into an object directory which belongs to
a different repository than the one in the current working directory,
such as:

  git init repo
  git -C repo ... # add some objects
  cd alternate
  git multi-pack-index --object-dir ../repo/.git/objects write

the binary will segfault trying to access the object-dir via the repo it
found, but that's not fully initialized. Worse, if we later call
clear_midx_files_ext(), we will use `the_repository` and remove files
out of the wrong object directory.

Fix this by using the given object_dir (or the object directory of
`the_repository` if `--object-dir` wasn't given) to properly to clean up
the *.rev files, avoiding the crash.

Original-patch-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c
t/t5319-multi-pack-index.sh