git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin/clone: avoid failure with GIT_DEFAULT_HASH

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 12, 2020, 03:24 UTC
Message-ID
<20200912032448.GB1988@nand.local>
In-Reply-To
<20200911233815.2808426-1-sandals@crustytoothpaste.net>
On Fri, Sep 11, 2020 at 11:38:15PM +0000, brian m. carlson wrote:
Show 5 quoted lines
> Neither of those are appealing, so let's tell the repository
> initialization code if we're doing a reinit like this, and if so, to
> clear the extension if we're using SHA-1.  This makes sure we produce a
> valid and functional repository and doesn't break any of our other use
> cases.

Your explanation makes sense, and what you're proposing here seems like a very reasonable path forward. I can't think of anything that would cause it not to work as expected.

> -void initialize_repository_version(int hash_algo);
> +void initialize_repository_version(int hash_algo, int reinit);

I'm not a huge fan of adding a 'reinit' parameter to a function that itself begins with the word 'initialize' (why wouldn't you call 'reinitialize_repository_version()' instead?), but seeing as there are only a couple of callers, maybe it is OK.

Alternatively, I certainly wouldn't complain if you did introduce a new function and updated the call-site that passes reinit as 1.

Show 10 quoted lines
> +test_expect_success 'clone with GIT_DEFAULT_HASH' '
> +	(
> +		sane_unset GIT_DEFAULT_HASH &&
> +		git init test
> +	) &&
> +	test_commit -C test foo &&
> +	git clone test test-clone &&
> +	git -C test-clone status
> +'
> +

This test looks very reasonable, and certainly demonstrates the bug and fix. Thanks.

With or without my nitpick:
  Reviewed-by: Taylor Blau <me@ttaylorr.com>

Thanks, Taylor

Previous: brian m. carlsonNext: brian m. carlson
Message 4 of 15 in “Posible bug with GIT_DEFAULT_HASH during clone”
  1. Matheus TavaresSep 11, 2020
  2. brian m. carlsonSep 11, 2020
  3. builtin/clone: avoid failure with GIT_DEFAULT_HASHbrian m. carlson, Sep 11, 2020
  4. Taylor BlauSep 12, 2020
  5. brian m. carlsonSep 12, 2020
  6. Junio C HamanoSep 14, 2020
  7. Junio C HamanoSep 14, 2020
  8. brian m. carlsonSep 15, 2020
  9. builtin/clone: avoid failure with GIT_DEFAULT_HASHbrian m. carlson, Sep 15, 2020
  10. Junio C HamanoSep 15, 2020
  11. brian m. carlsonSep 15, 2020
  12. builtin/clone: avoid failure with GIT_DEFAULT_HASHbrian m. carlson, Sep 20, 2020
  13. Junio C HamanoSep 21, 2020
  14. brian m. carlsonSep 22, 2020
  15. Junio C HamanoSep 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.