Re: [GIT BUG] show-ref doesn't work with Symbolic Refs other than HEAD
To
Junio C Hamano
Cc
git@vger.kernel.org
From
Casey Meijer
See Also
Prev Ref 1
Date
2019-12-23 14:59:27 UTC
I see.  Perhaps an enhancement then?

It's not at all intuitive that show-ref isn't able to show refs, symbolic or not. 

To clarify: I don't at all expect show-ref to change what it displays to be the "interesting branch" on the remote, nor to output the branch that a symbolic ref points at. 

I would expect it to show the commit SHA (useful) and the ref-name (not super useful), as it does for other refs (though perhaps the dereference option could be reused here somehow to give both options?).

In any case, no serious concern since `symbolic-ref` works, just a weird inconsistency. 

The documentation could certainly be improved.  I would just add a line "show-ref does not inspect or follow symbolic references like HEAD or those made with symbolic-ref" to the summary at the top.  Something like the following:
 
"""
Displays references available in a local repository along with the associated commit IDs. Results can be filtered using a pattern and tags can be dereferenced into object IDs. Additionally, it can be used to test whether a particular ref exists. 

By default, shows the tags, heads, and remote refs.  It does not ever inspect or follow symbolic references like HEAD or those made with `git symbolic-ref NAME REF`.

The --exclude-existing form is a filter that does the inverse. It reads refs from stdin, one ref per line, and shows those that don’t exist in the local repository.

Use of this utility is encouraged in favor of directly accessing files under the .git directory.
"""

Thanks for taking a look!

Best,

Casey  

On 2019-12-20, 4:22 PM, "Junio C Hamano" <gitster@pobox.com> wrote:

    Casey Meijer <cmeijer@strongestfamilies.com> writes:
    
    > `git version 2.21.0`
    >  
    > Example
    > ------------
    >  
    > `git symbolic-ref DEV refs/heads/dev`
    > `git symbolic-ref DEV`
    > `>> refs/heads/dev
    > `git show-ref DEV`
    > `>> [NO OUTPUT]`
    >  
    > Expected output
    > ---------------------
    >  
    > `FULL_COMMIT_HASH refs/heads/dev`
    
    What made you expect such an output?  That may be caused by a
    documentation bug or two, which may well be worth fixing.
    
    The show-ref command never resolves a symbolic ref to its pointee,
    and it only shows things under refs/ hierarchy.
    
    And DEV is not special.
    
    	git show-ref HEAD
    
    would not show HEAD (i.e. the commit that is at the tip of the
    current branch), and it would show refs/remotes/origin/HEAD in a
    repository cloned from elsewhere but it does not say what other ref
    is pointed at (in other words, what the remote repository considered
    the primarily interesting branch).
    
    Thanks.