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

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

From
Derrick Stolee <derrickstolee@github.com>
Date
Apr 21, 2022, 13:29 UTC
Message-ID
<b884d627-4a81-5be9-eed5-feff3b2bd010@github.com>
In-Reply-To
<xmqqczhbo4s3.fsf@gitster.g>
On 4/20/2022 4:53 PM, Junio C Hamano wrote:
Show 10 quoted lines
> "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?
Sorry, this title of the commit message is stale from a version
where I started making the clones succeed (but without these
bad refs). I changed my mind to only switch BUG() to die() to
avoid giving the impression that we have a "matching" repo after
the clone.
 
Show 21 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.
Perhaps the commit could instead start with
	clone: die() instead of BUG() on bad refs
?

Thanks, -Stolee

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.