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

Re: [PATCH] git-symbolic-ref: fix error message when ref doesn't exist

From
Julian Phillips <julian@quantumfyre.co.uk>
Date
Mar 19, 2007, 09:03 UTC
Message-ID
<Pine.LNX.4.64.0703190857320.25879@beast.quantumfyre.co.uk>
In-Reply-To
<7vslc1iprn.fsf@assigned-by-dhcp.cox.net>
On Mon, 19 Mar 2007, Junio C Hamano wrote:
Show 17 quoted lines
> Julian Phillips <julian@quantumfyre.co.uk> writes:
>
>> When calling resolve_ref from check_symref set reading to 1, since we
>> do want to know if the given ref doesn't exist.  This means that
>> "git symbolic-ref foo" will now print "fatal: No such ref: foo" as
>> expected.
>
> Hmmmm.  That would break:
>
> 	$ rm -fr a; mkdir a; cd a
> 	$ git init-db
>        $ git symbolic-ref HEAD
>        refs/heads/master
>
> wouldn't it?  We do want it not to fail and tell us that the
> commit we are going to create will be on refs/heads/master
> (i.e. "the master branch").
Um .. yes ... as per the comment in refs.c ... :$
Show 8 quoted lines
>
> And  the command errors out as expected when given a
> non-existent symbolic ref:
>
> 	$ git symbolic-ref no-such; echo $?
> 	fatal: ref no-such is not a symbolic ref
> 	128
>

The thing is, that wasn't what I expected. From looking at the code for symbolic-ref I was expecting:

 	$ git symbolic-ref no-such; echo $?
 	fatal: No such ref: no-such
 	128

In particular, in quiet mode you will get a return of 1 - rather than 128, which would potentially lead you astray if you belived the man page ...

-- 
Julian

  ---
"Intelligence without character is a dangerous thing."
-- G. Steinem
Previous: Junio C Hamano
Message 3 of 3 in “git-symbolic-ref: fix error message when ref doesn't exist”
  1. git-symbolic-ref: fix error message when ref doesn't existJulian Phillips, Mar 18, 2007
  2. Junio C HamanoMar 19, 2007
  3. Julian PhillipsMar 19, 2007

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.