Re: [PATCH v2] show-index: fix uninitialized hash function
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Jul 15, 2024, 22:07 UTC
- Message-ID
- <ZpWdkq2GBqIBI8Lr@tapette.crustytoothpaste.net>
- In-Reply-To
- <20240715102344.182388-1-abhijeet.nkt@gmail.com>
On 2024-07-15 at 10:23:43, Abhijeet Sonar wrote:
Show 19 quoted lines
> diff --git a/t/t8101-show-index-hash-function.sh b/t/t8101-show-index-hash-function.sh > new file mode 100755 > index 0000000000..2e9308f73c > --- /dev/null > +++ b/t/t8101-show-index-hash-function.sh > @@ -0,0 +1,15 @@ > +#!/bin/sh > + > +test_description='git show-index' > + > +. ./test-lib.sh > + > +test_expect_success 'show-index: should not fail outside a repository' ' > + git init --object-format=sha1 && ( > + echo "" | git hash-object -w --stdin | git pack-objects test && > + rm -rf .git && > + cat test-*.idx | git show-index > + ) > +'
I don't think this change is going to work. If you run with `GIT_TEST_DEFAULT_HASH=sha256`, as I do, you see this error:
fatal: attempt to reinitialize repository with different hash
That's because the repository is already initialized as SHA-256 when you do `git init`.
The reason that the `--object-format` option was added was to make this configuration work outside a repository. It would probably be better to require the user to specify that option if we're outside of a repository rather than just try to guess. We want to have _fewer_ dependencies on SHA-1 as the implicit algorithm, not more.
-- brian m. carlson (they/them or he/him) Toronto, Ontario, CA