diff mbox series

[v2,1/9] setup: unset ref storage when reinitializing repository version

Message ID 8b11127daf4c1d06eed4a0c83dd3dc981ffdc728.1716545235.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series refs: ref storage format migrations | expand

Commit Message

Patrick Steinhardt May 24, 2024, 10:14 a.m. UTC
When reinitializing a repository's version we may end up unsetting the
hash algorithm when it matches the default hash algorithm. If we didn't
do that then the previously configured value might remain intact.

While the same issue exists for the ref storage extension, we don't do
this here. This has been fine for most of the part because it is not
supported to re-initialize a repository with a different ref storage
format anyway. We're about to introduce a new command to migrate ref
storages though, so this is about to become an issue there.

Prepare for this and unset the ref storage format when reinitializing a
repoistory with the "files" format.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 setup.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Justin Tobler May 24, 2024, 9:33 p.m. UTC | #1
On 24/05/24 12:14PM, Patrick Steinhardt wrote:
> When reinitializing a repository's version we may end up unsetting the
> hash algorithm when it matches the default hash algorithm. If we didn't
> do that then the previously configured value might remain intact.
> 
> While the same issue exists for the ref storage extension, we don't do
> this here. This has been fine for most of the part because it is not
> supported to re-initialize a repository with a different ref storage
> format anyway. We're about to introduce a new command to migrate ref
> storages though, so this is about to become an issue there.

Ah, so this would be important in the context of migrating a repository
from "reftable" to "files".

> Prepare for this and unset the ref storage format when reinitializing a
> repoistory with the "files" format.

s/repoistory/repository/

-Justin
Patrick Steinhardt May 28, 2024, 5:13 a.m. UTC | #2
On Fri, May 24, 2024 at 04:33:51PM -0500, Justin Tobler wrote:
> On 24/05/24 12:14PM, Patrick Steinhardt wrote:
> > When reinitializing a repository's version we may end up unsetting the
> > hash algorithm when it matches the default hash algorithm. If we didn't
> > do that then the previously configured value might remain intact.
> > 
> > While the same issue exists for the ref storage extension, we don't do
> > this here. This has been fine for most of the part because it is not
> > supported to re-initialize a repository with a different ref storage
> > format anyway. We're about to introduce a new command to migrate ref
> > storages though, so this is about to become an issue there.
> 
> Ah, so this would be important in the context of migrating a repository
> from "reftable" to "files".

Exactly.

> > Prepare for this and unset the ref storage format when reinitializing a
> > repoistory with the "files" format.
> 
> s/repoistory/repository/

Thanks, fixed.

Patrick
diff mbox series

Patch

diff --git a/setup.c b/setup.c
index 7975230ffb..8c84ec9d4b 100644
--- a/setup.c
+++ b/setup.c
@@ -2028,6 +2028,8 @@  void initialize_repository_version(int hash_algo,
 	if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
 		git_config_set("extensions.refstorage",
 			       ref_storage_format_to_name(ref_storage_format));
+	else if (reinit)
+		git_config_set_gently("extensions.refstorage", NULL);
 }
 
 static int is_reinit(void)