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

Re: git branch command is incompatible with bash

From
Jeff King <peff@peff.net>
Date
Jul 28, 2015, 16:25 UTC
Message-ID
<20150728162516.GA28031@peff.net>
In-Reply-To
<xmqq4mkogvb7.fsf@gitster.dls.corp.google.com>
On Tue, Jul 28, 2015 at 08:23:40AM -0700, Junio C Hamano wrote:
> 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).

I think --abbrev-ref can handle much more than just shortening symrefs, though:

E.g. resolving other symbolic names:
  $ git rev-parse --abbrev-ref @{u}
  origin/master
Or resolving any arbitrary name you happen to have:
  $ git rev-parse --abbrev-ref refs/heads/master
  master

Even ones that aren't fully qualified (which would be tough to do with simple pattern substitution):

  $ git rev-parse --abbrev-ref remotes/origin/master
  origin/master
Or handling ambiguities during abbreviation:
  $ git tag master
  $ git rev-parse --abbrev-ref HEAD
  heads/master
-Peff
Previous: Junio C HamanoNext: Johannes Sixt
Message 7 of 9 in “git branch command is incompatible with bash”
  1. Anatol RudolphJul 27, 2015
  2. Johannes SixtJul 27, 2015
  3. Junio C HamanoJul 27, 2015
  4. Johannes SixtJul 28, 2015
  5. Jakub NarębskiJul 28, 2015
  6. Junio C HamanoJul 28, 2015
  7. Jeff KingJul 28, 2015
  8. Johannes SixtJul 28, 2015
  9. Scott SchmitJul 29, 2015

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.