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

Bug: bad errno report from lock_ref_sha1_basic() when contents bad

From
Thomas Rast <trast@inf.ethz.ch>
Date
Apr 2, 2012, 10:04 UTC
Message-ID
<878viephzm.fsf@thomas.inf.ethz.ch>
Hi Junio,
User "mbrochh" on IRC reported a result along the lines of
  error: unable to resolve reference refs/remotes/origin/master: Success
  ! [new branch] master -> origin/master (unable to update local ref)

from 'git fetch' (or pull actually, but clearly it's the fetch part failing). This error message is from lock_ref_sha1_basic(), and suggests a confused error exit taken with errno=0.

I can reproduce the problem by writing a bit of garbage to a remote ref and then fetching, though I usually get some other error in the message (usually ENOENT, which is equally wrong).

As far as I can tell it's caused by resolve_ref_unsafe() returning NULL when the content checks fail:

	if (get_sha1_hex(buffer, sha1) || (buffer[40] != '\0' && !isspace(buffer[40]))) {
		if (flag)
			*flag |= REF_ISBROKEN;
		return NULL;
	}

This used to warn before your 5595635 (resolve_ref(): report breakage to the caller without warning, 2011-10-19), but otherwise suffered from the same problem.

As far as I can see lock_ref_sha1_basic() needs a similar check for REF_ISBROKEN (and presumably the only fix is to nuke it so maybe it should even suggest that to the user). But in general, the "errno may be crucial or worthless" interface of lock_ref_sha1_basic() seems a bit broken...

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Next: Junio C Hamano
Message 1 of 3 in “Bug: bad errno report from lock_ref_sha1_basic() when contents bad”
  1. Thomas RastApr 2, 2012
  2. Junio C HamanoApr 2, 2012
  3. Thomas RastApr 2, 2012

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.