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

Re: ~ and ^

From
Karl Hasselström <kha@treskal.com>
Date
May 13, 2007, 19:13 UTC
Message-ID
<20070513191350.GB14657@diana.vm.bytemark.co.uk>
In-Reply-To
<7v8xbssfti.fsf@assigned-by-dhcp.cox.net>
On 2007-05-13 12:07:21 -0700, Junio C Hamano wrote:
Show 9 quoted lines
> Sean <seanlkml@sympatico.ca> writes:
>
> > Would it be possible/reasonable to treat a bare ~3 (or ^) on the
> > git command line as equivalent to "<current branch>~3" ? At least
> > @{3} already works this way and it would be nice to do the same
> > for the even more common tilde and hat operations. If so, it would
> > be a small convenience to just type: "git show ~3"
>
> Interesting.
Yes. I think we should have this, even if just for consistency.
> At least, "ls ~0" does not seem to get confused by bash to be the
> home directory of the root user, so I do not offhand think of a
> reason not to have ~$n as a synonym to HEAD~$n.

It seems that ~foo is only expanded to foo's home if there is such a user. Since all-numeric users probably aren't common, we can probably get away with it.

> Would that be useful? I dunno.
It would allow you to say
  git log ~5..
instead of
  git log HEAD~5..
so I'd say it is useful.
-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Previous: Junio C HamanoNext: Sean
Message 3 of 6 in “~ and ^”
  1. SeanMay 13, 2007
  2. Junio C HamanoMay 13, 2007
  3. Karl HasselströmMay 13, 2007
  4. SeanMay 13, 2007
  5. SeanMay 13, 2007
  6. Robin RosenbergMay 13, 2007

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.