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

Re: Commiting automatically (2)

From
Jakub Narebski <jnareb@gmail.com>
Date
Jan 3, 2011, 17:34 UTC
Message-ID
<201101031834.09115.jnareb@gmail.com>
In-Reply-To
<4D211AA4.4050108@seznam.cz>
On Mon, 3 Jan 2011, Maaartin-1 wrote:
> On 10-12-27 13:04, Jakub Narebski wrote:
>> On Wed, 22 Dec 2010, Maaartin-1 wrote:
Show 24 quoted lines
>>> Moreover, git-show-ref --head shows all branches and tags, this can't be
>>> right, can it? According to your above explanation, getting HEAD using a
>>> pattern is impossible, so I'd say that's what is "--head" good for.
>>>
>>> Moreover, "git-show-ref --heads" shows less than "git-show-ref --head",
>>> despite the plural.
>> 
>> "git show-ref --head" is strange in that it doesn't play well
>> with '--heads' and '--tags' and '<pattern>'.
>> 
>> I think it is a bit of misdesign, but I don't know how it should be
>> fixed; current output of "git show-ref --head" has to be kept because
>> of backward compatibility - git-show-ref is plumbing.
> 
> I wonder what
> git show-ref --head
> really does. It seems to output everything, is this the expected (albeit
> strange) behavior? Maybe, I know now, s. below.
> 
> For sure, either the doc is completely wrong or the implementation. I
> hope I understand "Show the HEAD reference" correctly as showing the
> HEAD reference, don't I? So it must show a single reference (singular).
> Instead I get all tags and all heads. Could anybody either fix the doc
> or convince me that the many lines I'm seeing are a single one?
Well, it might be that *both* documentation and implementation are wrong.
Show 11 quoted lines
> 
> Shouldn't there be an option *really* doing what --head is expected and
> documented to do? I mean something like
> git show-ref --head --yes-I-really-mean-the-head
> with the output consisting of a single line like
> 4ba2b422cf3cc229d894bb31c429c0c588de85c0 HEAD
> Maybe it could be called --head-only.
> 
> It could help a lot to add the word "additionally" to the doc like
> --head
> Additionally show the HEAD reference.

Well, actually it doesn't do that. If '--head' is *alone* ref selector (e.g. "git show-ref --head") it shows HEAD reference in addition to all other refs (e.g. what "git show-ref" would show). But it doesn't seem to work in described way when combined with any of ref specifiers; neither "git show-ref --head --heads" not "git show-ref --head master" work as one would expect.

Show 11 quoted lines
> 
>>>> I tripped over strange git-show-ref <pattern> semantic too.
>>>>
>>>> P.S. there is also git-for-each-ref.
>> 
>> I don't know why there is git-show-ref when we have git-for-each-ref
>> for scripting; I guess they were added nearly at the same time...
> 
> I guess, I can get the single line I wanted using
> git for-each-ref $(git symbolic-ref HEAD)
> right?

Well, both git-show-ref and git-for-each-ref are meant for checking or viewing multiple refs at once. If you are working with a single ref, then git-rev-parse (e.g. "git rev-parse --symboolic HEAD" or "git rev-parse --symbolic-full-name HEAD") or git-symbolic-ref would be a better choice IMHO.

-- 
Jakub Narebski
Poland
Previous: Maaartin-1
Message 13 of 13 in “Commiting automatically (2)”
  1. MaaartinDec 19, 2010
  2. Taylor HedbergDec 19, 2010
  3. Jonathan NiederDec 19, 2010
  4. Jonathan NiederDec 19, 2010
  5. MaaartinDec 20, 2010
  6. Junio C HamanoDec 19, 2010
  7. MaaartinDec 20, 2010
  8. Enrico WeigeltDec 20, 2010
  9. MaaartinDec 21, 2010
  10. Jakub NarebskiDec 21, 2010
  11. Jakub NarebskiDec 27, 2010
  12. Maaartin-1Jan 3, 2011
  13. Jakub NarebskiJan 3, 2011

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.