mirror of
https://github.com/git/git.git
synced 2024-09-08 03:50:44 +02:00
Merge branch 'ps/ref-storage-migration-fix'
Hotfix for a topic already in -rc. * ps/ref-storage-migration-fix: refs: fix format migration on Cygwin
This commit is contained in:
commit
c89facd58e
22
refs.c
22
refs.c
@ -2843,6 +2843,14 @@ int repo_migrate_ref_storage_format(struct repository *repo,
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the new ref store such that any potentially-open files will
|
||||
* be closed. This is required for platforms like Cygwin, where
|
||||
* renaming an open file results in EPERM.
|
||||
*/
|
||||
ref_store_release(new_refs);
|
||||
FREE_AND_NULL(new_refs);
|
||||
|
||||
/*
|
||||
* Until now we were in the non-destructive phase, where we only
|
||||
* populated the new ref store. From hereon though we are about
|
||||
@ -2874,10 +2882,14 @@ int repo_migrate_ref_storage_format(struct repository *repo,
|
||||
*/
|
||||
initialize_repository_version(hash_algo_by_ptr(repo->hash_algo), format, 1);
|
||||
|
||||
free(new_refs->gitdir);
|
||||
new_refs->gitdir = xstrdup(old_refs->gitdir);
|
||||
repo->refs_private = new_refs;
|
||||
/*
|
||||
* Unset the old ref store and release it. `get_main_ref_store()` will
|
||||
* make sure to lazily re-initialize the repository's ref store with
|
||||
* the new format.
|
||||
*/
|
||||
ref_store_release(old_refs);
|
||||
FREE_AND_NULL(old_refs);
|
||||
repo->refs_private = NULL;
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -2888,8 +2900,10 @@ done:
|
||||
new_gitdir.buf);
|
||||
}
|
||||
|
||||
if (ret && new_refs)
|
||||
if (new_refs) {
|
||||
ref_store_release(new_refs);
|
||||
free(new_refs);
|
||||
}
|
||||
ref_transaction_free(transaction);
|
||||
strbuf_release(&new_gitdir);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user