Re: [PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-19 Thread brian m. carlson
On Wed, Dec 19, 2018 at 10:38:41AM -0500, Jeff King wrote: > Hmm. It looks like we never set repo_fmt.hash_algo to anything besides > GIT_HASH_SHA1 anyway. I guess the existing field is really just there in > preparation for us eventually respecting extensions.hashAlgorithm (or > whatever it's call

Re: [PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-19 Thread Jeff King
On Wed, Dec 19, 2018 at 10:46:52PM +0100, Martin Ågren wrote: > > 2. Arguably we should not even look at extensions.* unless we see a > > version >= 1. But we do process them as we parse the config file. > > This is mostly an oversight, I think. We have to handle them as we > > se

Re: [PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-19 Thread Martin Ågren
On Wed, 19 Dec 2018 at 16:38, Jeff King wrote: > > On Tue, Dec 18, 2018 at 08:25:27AM +0100, Martin Ågren wrote: > > > Check that `version` is non-negative before using `hash_algo`. > Hmm. It looks like we never set repo_fmt.hash_algo to anything besides > GIT_HASH_SHA1 anyway. I guess the existi

Re: [PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-19 Thread Martin Ågren
On Wed, 19 Dec 2018 at 01:18, brian m. carlson wrote: > I think this change is fine, because we initialize the value in > the_repository elsewhere, and if there's no repository, this should > never have a value other than the default anyway. Thanks, it feels good that this patch matches how you t

Re: [PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-19 Thread Jeff King
On Tue, Dec 18, 2018 at 08:25:27AM +0100, Martin Ågren wrote: > If `read_repository_format()` encounters an error, `format->version` > will be -1 and all other fields of `format` will be undefined. However, > in `setup_git_directory_gently()`, we use `repo_fmt.hash_algo` > regardless of the value

Re: [PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-18 Thread brian m. carlson
On Tue, Dec 18, 2018 at 08:25:27AM +0100, Martin Ågren wrote: > I fully admit to not understanding all of this setup code, neither in > its current incarnation, nor in terms of an ideal end game. This check > seems like a good thing to do though. It's definitely complex. > diff --git a/setup.c

[PATCH 2/3] setup: do not use invalid `repository_format`

2018-12-17 Thread Martin Ågren
If `read_repository_format()` encounters an error, `format->version` will be -1 and all other fields of `format` will be undefined. However, in `setup_git_directory_gently()`, we use `repo_fmt.hash_algo` regardless of the value of `repo_fmt.version`. This can be observed by adding this to the end