Re: git branch command is incompatible with bash

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

 



Am 28.07.2015 um 17:23 schrieb Junio C Hamano:
Johannes Sixt <j6t@xxxxxxxx> writes:

Are you trying to say that the result of 'rev-parse --abbrev-ref HEAD'
is suboptimal and that of 'symbolic-ref --short HEAD' is OK?

My "Interesting" was primarily about that I wasn't aware of the
"--abbrev-ref" option.

Yes, I am sure some time ago I accepted a patch to add it, but I
simply do not see the point, especially because the "--short" option
to symbolic-ref feels much more superiour.  "What branch am I on?"
is about symbolic refs, rev-parse is about revisions.

I can see that "symbolic-ref --short" is much newer than the other
one, so addition of "--abbrev-ref" to "rev-parse" may have been a
mistake made while being desperate (i.e. not having a way to do so
with plumbing, we wanted "some" way to do so and chose poorly).

Heh. Originially, I was about to suggest

   git symbolic-ref -q --short HEAD || git rev-parse --abbrev HEAD

in order to handle the detached HEAD case by printing the abbreviated commit name, only to learn that this doesn't do what I expected. Looking at the man page of rev-parse, I discovered --abbrev-ref. And learned that I actually should have used --short instead of --abbrev in the above rev-parse command.

Confusing...

-- Hannes

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]