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

Re: Commit-ish shortcut for immediate parent range

From
Jeff King <peff@peff.net>
Date
Oct 22, 2006, 19:53 UTC
Message-ID
<20061022195315.GB10977@coredump.intra.peff.net>
In-Reply-To
<200610221548.42048.andyparkins@gmail.com>
On Sun, Oct 22, 2006 at 03:48:35PM +0100, Andy Parkins wrote:
Show 10 quoted lines
> Git's commit-ish is very powerful.  I was wondering however, if there was a 
> shortcut for (for example)?
> 
>  git-diff 3435fdb4c^..3435fdb4c
> 
> That is - the short range of a particular commit's parent to that commit; like
> 
>  git-diff 3435fdb4c!
> 
> Or similar.

I think a more general (but possibly harder to implement and use!) form would be a commit-ish token for "refer to previous commit-ish." This would not increase expressiveness, but could save a lot of typing. So if '!' meant "the last sha1/ref parsed", your example range would be:

  3435fdb4c^..!
but you could also do more exotic things like:
  3435fdb4c~25..!~20

Obviously you could think of more interesting ways to refer to previous THINGS. But I think in most cases in which you have repeated refs, you really are just repeating one ref twice as a basis for a range.

The '!' character is probably a bad choice, since it's generally an interactive shell metacharacter. I'm not sure what would be a better choice; we're running low on punctuation.

At any rate, I'm not convinced this is a worthwhile optimization. It's annoying to have to re-specify a long sha1, but in 99% of cases, you really are looking for sha1^..sha1. As others have pointed out, that's already handled through git-show.

-Peff
Previous: Johannes Schindelin
Message 13 of 13 in “Commit-ish shortcut for immediate parent range”
  1. Andy ParkinsOct 22, 2006
  2. Jakub NarebskiOct 22, 2006
  3. Linus TorvaldsOct 22, 2006
  4. Linus TorvaldsOct 22, 2006
  5. Andy ParkinsOct 22, 2006
  6. Linus TorvaldsOct 22, 2006
  7. Jakub NarebskiOct 22, 2006
  8. Johannes SchindelinOct 22, 2006
  9. Jakub NarebskiOct 22, 2006
  10. Junio C HamanoOct 22, 2006
  11. Linus TorvaldsOct 23, 2006
  12. Johannes SchindelinOct 22, 2006
  13. Jeff KingOct 22, 2006

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.