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
Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Date
May 10, 2010, 08:14 UTC
Message-ID
<A612847CFE53224C91B23E3A5B48BAC74482E511E7@xmail3.se.axis.com>
In-Reply-To
<7vhbmjc6dy.fsf@alter.siamese.dyndns.org>
Show 17 quoted lines
> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Junio C Hamano
> Sent: den 8 maj 2010 07:25
> To: Jeff King
> Cc: Peter Kjellerstedt; git@vger.kernel.org
> Subject: Re: [PATCH/RFC] Add [] as an alias for a reference to the
> empty tree
> 
> Jeff King <peff@peff.net> writes:
> 
> > 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]

Interesting. I had not thought of that, but I can see the use for it in some situations if nothing else but to clarify what is going on.

> > etc. I don't think I would want to type those all the time,...

Well, I have to agree on that, even though I guess they could be abbreviated like [i] and [wt].

> If you go that route, why not use INDEX and WORKTREE (all caps) to at
> least avoid the brackets?  I am not personally interested in [] at all,
> but as part of that repertoire of syntactic sugar tokens EMPTY might be
> able to sneak in [*1*]

The reason I choose to use some special characters like [] was that I explicitly did not want to touch the normal namespace for references, since these refs do not actually exist in the .git directory and things could get a bit surprising if someone actually created a branch/tag named INDEX...

However, if INDEX, WORKTREE and EMPTY are preferred as syntactic sugar tokes, then that is fine by me. Unfortunately, I do not have the time nor the knowledge needed to add support for the INDEX and WORKTREE tokens, so I am afraid I will have to leave this as a suggestion for the future.

Show 7 quoted lines
> [Footnote]
> 
> *1* Without that "[]" syntax, the feature is "Meh" for me, but with the
> syntax, it becomes "Yuck".  The reason I am not interested in the
> feature is because I don't see much value in running "git diff EMPTY
> <anything>". Perhaps "git archive" might be what the user really wants 
> to find.

As I mentioned in [1] I am post-processing the generated diff, and then the empty tree is just another starting point for the diff. Having to get the full content some other way (e.g., via git archive) would just mean a lot of unnecessary code and special casing in this case.

//Peter
[1] http://thread.gmane.org/gmane.comp.version-control.git/146468/focus=146518
Previous: Jonathan NiederNext: Jeff King
Message 6 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.