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

Re: [PATCH 1/2] builtin/symbolic-ref.c: add option to fall back to normal ref

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2012, 22:21 UTC
Message-ID
<7v1upf6hp5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1330380536-9647-1-git-send-email-jk@jk.gs>
Jan Krüger <jk@jk.gs> writes:
Show 5 quoted lines
> Frequently, people want to determine the current value of HEAD in
> scripts. However, there is no tool that can always output it, since "git
> symbolic-ref" will fail if HEAD isn't currently a symref, and other
> tools (e.g. "git rev-parse --symbolic-full-name") will also fail in
> one of HEAD's possible modes.
What is "the current value of HEAD"?

The symbolic-ref command is there for people who _care_ about the distinction between a HEAD that points at a branch and a HEAD that points directly at a commit. There is no room for the command to "fall back" anywhere, as that will only introduce an unnecessary ambiguity to the command whose sole purpose is to be able to tell them apart.

If the caller does not need to know if the HEAD is detached or not, and wants to know what commit it points at, why is it insufficient to just use rev-parse, e.g. "git rev-parse --verify HEAD"?

Previous: Jan KrügerNext: Jan Krüger
Message 2 of 3 in “builtin/symbolic-ref.c: add option to fall back to normal ref”
  1. 1/2 builtin/symbolic-ref.c: add option to fall back to normal refJan Krüger, Feb 27, 2012
  2. Junio C HamanoFeb 27, 2012
  3. Jan KrügerFeb 27, 2012

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.