git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Jakub Narębski" <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Bryan Turner <bturner@atlassian.com>,
	Steffen Nurpmeso <steffen@sdaoden.eu>,
	Git Users <git@vger.kernel.org>
Subject: Re: v2.9.3 and v2.10.0: `name-ref' HEAD gives wrong branch name
Date: Wed, 21 Sep 2016 19:54:17 +0200	[thread overview]
Message-ID: <60391836-a1c3-bfbe-b2d0-476d8bc82044@gmail.com> (raw)
In-Reply-To: <xmqq8tulb45n.fsf@gitster.mtv.corp.google.com>

W dniu 21.09.2016 o 18:37, Junio C Hamano pisze:
> Jakub Narębski <jnareb@gmail.com> writes:
>>> Have you tried "git symbolic-ref HEAD"?
>>>
>>> $ git symbolic-ref HEAD
>>> refs/heads/master
>>>
>>> If you don't want the fully-qualified ref, you can add --short:
>>>
>>> $ git symbolic-ref --short HEAD
>>> master
>>
>> This does not work for detached HEAD, but perhaps you don't need
>> to worry about this.
> 
> I am not sure what you mean by "does not work".  Asking what ref
> HEAD points at to symbolic-ref will tell you it does not point at
> anything by exiting with non-zero status and that can be relied
> upon.
> 
> Asking "symbolic-ref HEAD" has been the way how "git branch" and
> other commands find out what branch is currently checked out for
> almost eternity ("git symbolic-ref" appeared in Git v0.99.8).

I'm sorry, I was wrong saying "does not work".  The problem is not
that it does not work, but that you need to take care of exit 
condition to correctly support detached HEAD state, and not end
with empty name for a branch, for example...

But if handled correctly, git-symbolic-ref is as good as git-rev-parse
as a plumbing to resolve current branch name.

Best,
-- 
Jakub Narębski


      reply	other threads:[~2016-09-21 17:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 16:23 v2.9.3 and v2.10.0: `name-ref' HEAD gives wrong branch name Steffen Nurpmeso
2016-09-20 18:54 ` Bryan Turner
2016-09-20 19:29   ` Steffen Nurpmeso
2016-09-21 13:43   ` Jakub Narębski
2016-09-21 14:21     ` Steffen Nurpmeso
2016-09-21 16:37     ` Junio C Hamano
2016-09-21 17:54       ` Jakub Narębski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60391836-a1c3-bfbe-b2d0-476d8bc82044@gmail.com \
    --to=jnareb@gmail.com \
    --cc=bturner@atlassian.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=steffen@sdaoden.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).