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

Re: Itches with the current rev spec

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Apr 29, 2013, 14:00 UTC
Message-ID
<517E7D12.6020605@drmicha.warpmail.net>
In-Reply-To
<vpqehdzkoix.fsf@grenoble-inp.fr>
Matthieu Moy venit, vidit, dixit 25.04.2013 10:22:
Show 31 quoted lines
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
> 
>> Hi,
>>
>> So, I have three serious itches that would be nice to address:
>>
>> 1. git reset --hard HEAD~1/ git show HEAD~1 is a very common idiom
>> that's unnecessarily cumbersome to type out.  We can make the <rev>
>> part of <rev>~<n> optional without being ambiguous: you might argue
>> that ~<n> normally refers to a /home/<n>, but who uses numbers in
>> place of usernames?  Even if they do, how can that path possibly be
>> inside our repository?
> 
> It's a bit more complex than that: the ~<username> is expanded by the
> shell, before Git has any opportunity to guess anything.
> 
> ~1 would be unusable for zsh users and tcsh users at least by default:
> 
> zsh% echo ~1
> zsh: not enough directory stack entries.
> 
> tcsh% echo ~1
> Unknown user: 1.
> 
> (An obvious workaround is to shell-quote it, but as the goal is to have
> something easy to type, \~1 or '~1' do not give so much benefit over
> HEAD~1)
> 
> That said, it seems to work fine for bash (even if the number is a PID,
> it's not expanded), so it may be a good idea to add it as a shortcut,
> with a warning in the doc about shell expansion.

I've been using a patch for that for ages without problems; it had been rejected because of the reasons above, plus:

Note that even in bash ~1 has a different meaning when your directory stack is non-empty. It's just that I don't use that feature, and bash leaves '~1' as is when there is no stack (you haven't used pushd), whereas zsh errors out.

So, I do understand that some consider this semi-broken, even though it's not. But we avoid clashes with shell expansion in most cases for most shells.

As for rebase, I still have to look up what "git rebase A B" means. This would be much clearer with a range notation. I seem to recall I even suggested it, but that might have been in a parallel universe.

Michael
Previous: Ramkumar RamachandraNext: Andreas Schwab
Message 6 of 24 in “Itches with the current rev spec”
  1. Ramkumar RamachandraApr 25, 2013
  2. Ramkumar RamachandraApr 25, 2013
  3. Matthieu MoyApr 25, 2013
  4. Felipe ContrerasApr 25, 2013
  5. Ramkumar RamachandraApr 25, 2013
  6. Michael J GruberApr 29, 2013
  7. Andreas SchwabApr 25, 2013
  8. Ramkumar RamachandraApr 25, 2013
  9. Phil HordApr 25, 2013
  10. Yann DirsonApr 26, 2013
  11. Johannes SixtApr 26, 2013
  12. Ramkumar RamachandraApr 26, 2013
  13. Junio C HamanoApr 26, 2013
  14. Felipe ContrerasApr 26, 2013
  15. Junio C HamanoApr 26, 2013
  16. Ramkumar RamachandraApr 29, 2013
  17. Yann DirsonApr 29, 2013
  18. Junio C HamanoApr 29, 2013
  19. Ramkumar RamachandraApr 29, 2013
  20. Junio C HamanoApr 29, 2013
  21. Ramkumar RamachandraApr 29, 2013
  22. Ramkumar RamachandraApr 29, 2013
  23. Junio C HamanoApr 30, 2013
  24. Ramkumar RamachandraApr 29, 2013

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.