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

Re: [PATCH/RFC] Add [] as an alias for a reference to the empty tree

From
Jeff King <peff@peff.net>
Date
May 8, 2010, 04:53 UTC
Message-ID
<20100508045319.GD14998@coredump.intra.peff.net>
In-Reply-To
<1273250247-20762-1-git-send-email-pkj@axis.com>
On Fri, May 07, 2010 at 06:37:27PM +0200, Peter Kjellerstedt wrote:
> Instead of specifying the SHA1 for the empty tree (i.e.,
> 4b825dc642cb6eb9a060e54bf8d69288fbee4904) one can now say [], e.g.,
> 'git diff [] v1.7.1' would give all the changes between the empty tree
> and the tag v1.7.1.

FWIW, I like the idea of a special namespace that indicates "this is not a regular ref, but you can resolve it to some object". It seems to come up once in a while, but I don't recall anybody ever actually making a patch.

Show 6 quoted lines
> The rationale for selecting [] as the alias for the empty tree was that
> it looks empty, the brackets are not used for anything related to
> references (AFAIK), they are not allowed in references according to
> 'man git-check-ref-format', and the syntax can easily be extended to
> allow other types of references by adding information between the
> brackets.

I am a little iffy on brackets, as they can invoke shell wildcarding behavior. But the fact that they don't cause a syntactic conflict does make them appealing.

Based on past discussions, I suspect other people would be interested in:

  $ git diff [index] HEAD
  $ git diff HEAD [index]
  $ git diff [working-tree] [index]

etc. I don't think I would want to type those all the time, but they conceptually are quite clear about what is happening, so they may be nice for showing new users what is happening with each diff invocation (as opposed to, say, "git diff --cached" versus "git diff", which is somewhat unintuitive, even though it is more handy in practice).

-Peff
Previous: Peter KjellerstedtNext: Junio C Hamano
Message 2 of 10 in “Add [] as an alias for a reference to the empty tree”
  1. Add [] as an alias for a reference to the empty treePeter Kjellerstedt, May 7, 2010
  2. Jeff KingMay 8, 2010
  3. Junio C HamanoMay 8, 2010
  4. Jeff KingMay 8, 2010
  5. Jonathan NiederMay 8, 2010
  6. Peter KjellerstedtMay 10, 2010
  7. Jeff KingMay 10, 2010
  8. Sverre RabbelierMay 10, 2010
  9. Jeff KingMay 10, 2010
  10. Sverre RabbelierMay 10, 2010

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.