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

Re: Support of '^' as alias for 'HEAD^'

From
Jeff King <peff@peff.net>
Date
Jul 15, 2012, 07:44 UTC
Message-ID
<20120715074441.GA18385@sigill.intra.peff.net>
In-Reply-To
<CAAa3hFMNf_wA22ngypSu379jr31r3L3yAjTkvDUd_L-mVwPJkA@mail.gmail.com>
On Sun, Jul 15, 2012 at 01:24:18AM +0300, Zeeshan Ali (Khattak) wrote:
> > Think what "log ^^ origin" would mean.  Is it "log ^HEAD^ origin"?
> > Is it "log HEAD^^ origin"?  They mean totally different things.
> 
> Sorry for my ignorance here but what does ^ *before* HEAD even mean? I

It means "not" (before "HEAD" or any other commit specifier). See "Specifying Ranges" in "git help revisions".

Show 7 quoted lines
> > Compared to that, at least ~<n> does not have such ambiguity within
> > the context of Git (having to quote is an ambiguity within the
> > context of using Git with shells that support dirstacks in their
> > tilde expansion).
> 
> Don't know whats dirstacks support either but that I guess just means
> that bash (the shell I have always used) doesn't do that.

Bash does support them, but you may not use them personally. Here are some examples of how a more bare "~" can go wrong:

  $ set -x
  [this instructs the shell to show us what it is executing]
  $ git log ~
  + git log /home/peff
  [oops, the shell expanded our home directory and passed it to git]
  $ git log ~1
  + git log '~1'
  [this one works ok, but...]
  $ pushd /tmp
  $ pushd $HOME
  $ git log ~1
  + git log /tmp
  [oops, pushd users cannot use ~<n> without quoting]
-Peff
Previous: Zeeshan Ali (Khattak)Next: Holger Hellmuth
Message 8 of 10 in “Support of '^' as alias for 'HEAD^'”
  1. Zeeshan Ali (Khattak)Jul 14, 2012
  2. Stefan NäweJul 14, 2012
  3. Junio C HamanoJul 14, 2012
  4. Junio C HamanoJul 14, 2012
  5. Zeeshan Ali (Khattak)Jul 14, 2012
  6. Junio C HamanoJul 14, 2012
  7. Zeeshan Ali (Khattak)Jul 14, 2012
  8. Jeff KingJul 15, 2012
  9. Holger HellmuthJul 15, 2012
  10. Zeeshan Ali (Khattak)Jul 15, 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.