1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 06:47:52 +01:00
git/refs
Michael Haggerty 198b808e20 packed_ref_store: handle a packed-refs file that is a symlink
One of the tricks that `contrib/workdir/git-new-workdir` plays is to
making `packed-refs` in the new workdir a symlink to the `packed-refs`
file in the original repository. Before
42dfa7ecef ("commit_packed_refs(): use a staging file separate from
the lockfile", 2017-06-23), a lockfile was used as the staging file,
and because the `LOCK_NO_DEREF` was not used, the pointed-to file was
locked and modified.

But after that commit, the staging file was created using a tempfile,
with the end result that rewriting the `packed-refs` file in the
workdir overwrote the symlink rather than the original `packed-refs`
file.

Change `commit_packed_refs()` to use `get_locked_file_path()` to find
the path of the file that it should overwrite. Since that path was
properly resolved when the lockfile was created, this restores the
pre-42dfa7ecef behavior.

Also add a test case to document this use case and prevent a
regression like this from recurring.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-07-27 10:19:56 -07:00
..
files-backend.c repack_without_refs(): don't lock or unlock the packed refs 2017-07-03 10:01:56 -07:00
iterator.c prefix_ref_iterator: don't trim too much 2017-05-23 14:29:52 +09:00
packed-backend.c packed_ref_store: handle a packed-refs file that is a symlink 2017-07-27 10:19:56 -07:00
packed-backend.h packed_refs_unlock(), packed_refs_is_locked(): new functions 2017-06-23 13:27:33 -07:00
ref-cache.c cache_ref_iterator_begin(): avoid priming unneeded directories 2017-05-24 21:21:21 +09:00
ref-cache.h create_ref_entry(): remove check_name option 2017-05-23 14:29:56 +09:00
refs-internal.h packed_ref_store: make class into a subclass of ref_store 2017-06-23 13:27:33 -07:00