]> git.ipfire.org Git - thirdparty/git.git/commit
refs: fix format migration on Cygwin
authorPatrick Steinhardt <ps@pks.im>
Tue, 23 Jul 2024 12:31:28 +0000 (14:31 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Jul 2024 15:58:03 +0000 (08:58 -0700)
commit09c817383f56d4bbcfb8089e7c4ed5dd9db0f547
tree4b06423c83910be20a111792d63d0a89d48a4666
parent25a0023f28600102f54e7529c20da5928c3e9c75
refs: fix format migration on Cygwin

It was reported that t1460-refs-migrate.sh fails when using Cygwin with
errors like the following:

    error: could not link file '.git/ref_migration.sr9pEF/reftable' to '.git/reftable': Permission denied

As some debugging surfaced, the root cause of this is that some files of
the newly-initialized ref store are still open when the target format is
the "reftable" format, and Cygwin refuses to rename open files.

Fix this issue by closing the new ref store before renaming its files
into place. This is a slight change in behaviour compared to before,
where we kept the new ref store open and then updated the repository's
ref store to point to it.

While we could re-open the new ref store after we have moved files
around, this is ultimately unnecessary. We know that the only user of
`repo_migrate_ref_storage_format()` is the git-refs(1) command, and it
won't access the ref store after it has been migrated anyway. So
reinitializing the ref store would be a waste of time. Regardless of
that it is still sensible to leave the repository in a consistent state.
But instead of reinitializing the ref store, we can simply unset the
repo's ref store altogether and let `get_main_ref_store()` lazily
initialize the new ref store as required.

Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c