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

Re: [PATCH] clone: ignore invalid local refs in remote

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 20, 2022, 20:53 UTC
Message-ID
<xmqqczhbo4s3.fsf@gitster.g>
In-Reply-To
<pull.1214.git.1650301959803.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Derrick Stolee <derrickstolee@github.com>
> Subject: Re: [PATCH] clone: ignore invalid local refs in remote

After seeing the title, I expected that cloning from such a repository with cruft in .git/refs/ directory would issue a warning and succeed without these non-ref files.

But that is not what is happening here?
Show 9 quoted lines
> +test_expect_success 'local clone from repo with corrupt refs fails gracefully' '
> +	git init corrupt &&
> +	test_commit -C corrupt one &&
> +	echo a >corrupt/.git/refs/heads/topic &&
> +
> +	test_must_fail git clone corrupt working 2>err &&
> +	grep "has a null OID" err
> +'
> +
We keep expecting that clone _will_ fail.

So the net change is that we still do not tolerate a corrupt repository and do not let corruption to propagate through cloning, but we diagnose this breakage as an error by calling die(), which is appropriate for dealing with runtime data error, instead of hitting a BUG(), which is reserved for program errors.

I agree with the fixed behaviour and implementation. It just is that "ignore" on the title seems misleading. Other than that, thanks for a good finding and a clean fix.

Show 6 quoted lines
> -	if (!new_oid || is_null_oid(new_oid))
> -		BUG("create called without valid new_oid");
> +	if (!new_oid || is_null_oid(new_oid)) {
> +		strbuf_addf(err, "'%s' has a null OID", refname);
> +		return 1;
> +	}
Previous: Ævar Arnfjörð BjarmasonNext: Derrick Stolee
Message 3 of 6 in “clone: ignore invalid local refs in remote”
  1. clone: ignore invalid local refs in remoteDerrick Stolee via GitGitGadget, Apr 18, 2022
  2. Ævar Arnfjörð BjarmasonApr 18, 2022
  3. Junio C HamanoApr 20, 2022
  4. Derrick StoleeApr 21, 2022
  5. Junio C HamanoApr 21, 2022
  6. clone: die() instead of BUG() on bad refsDerrick Stolee via GitGitGadget, Apr 25, 2022

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.