Re: v2.9.3 and v2.10.0: `name-ref' HEAD gives wrong branch name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey.

Bryan Turner <bturner@xxxxxxxxxxxxx> wrote:
 |On Tue, Sep 20, 2016 at 9:23 AM, Steffen Nurpmeso <steffen@xxxxxxxxxx> \
 |wrote:
 |> yah, sorry, i'm back again..
 |> I try to find a way to find the name of the current branch in an
 |> automated way, because i need to ensure that a commit happens on
 |> it and no other branch.  Now the problem arises that the commit
 |> ref at the time of that commit maybe shared in between several
 |> different branches, but no more thereafter, of course:
 |>
 |>   ?0[steffen@wales ]$ git branch|grep '^*'
 |>   * stable/v14.9
 |>   ?0[steffen@wales ]$ git name-rev --name-only HEAD
 |>   stable/v14.8
 |>
 |> Is there another way except looking into .git/HEAD or using sed(1)
 |> on the output of `branch' to find the right name?
 |
 |Have you tried "git symbolic-ref HEAD"?

Not until now.

 |$ git symbolic-ref HEAD
 |refs/heads/master

Works.

 |If you don't want the fully-qualified ref, you can add --short:
 |
 |$ git symbolic-ref --short HEAD
 |master

Yep, works even better.  Fantastic.  Thank you.  And that command
was already existing when i have learned to use git(1), it is even
in the progit-09.markdown as of 2011-09-22 that i have laying
around.  Five years, and anything forgotten.  That is what you get
from working with blinkers on.  Shame!

Thank you Bryan.

--steffen



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]