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

Re: [PATCH] introduce git root

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Nov 30, 2014, 11:58 UTC
Message-ID
<vpqoaro99xd.fsf@anie.imag.fr>
In-Reply-To
<CAJFMrCEciWXhBb36MVeFPi7Y7D=9zQ2xGPpiyUz9y4_hOh_taw@mail.gmail.com>
Arjun Sreedharan <arjun024@gmail.com> writes:
Show 16 quoted lines
> On 30 November 2014 at 04:38, Philip Oakley <philipoakley@iee.org> wrote:
>> From: "Arjun Sreedharan" <arjun024@gmail.com>
>>>
>>> This introduces `git root` which outputs the root directory
>>> (the directory that contains .git).
>>> The same can be accomplished by `git rev-parse --show-toplevel`.
>>> `git root` is much more intuitive and easy to remember.
>>> All it does is set the arguments for rev-parse
>>
>>
>> This may be better as an alias.
>> I've added it to my aliases list.
>>
>
> I know that. I am suggesting this to be a built-in command, without having the
> need to add as an alias.

Indeed, suggesting people to add an alias does not solve the discoverability issue. git rev-parse --show-toplevel is not just long, it's just not the place where people would look for (it's neither about revision nor about parsing, so clearly, "rev-parse" is not a good place to host the feature in the UI).

If we were to rewrite Git from scratch, then I would be all for having a "git root" command. Given that we already have rev-parse --show-toplevel, and that we'll have to keep it anyway for backward compatibility, I'm a bit more hesitant ("Git is hard to use because it doesn't have enough commands" is not a complain I hear so often ;-) ), but still mostly positive.

If we go this way, then the documentation must be updated too. I think the doc should still recommend "git rev-parse --show-toplevel" for scripting until Git versions implementing "git root" are widely deployed enough.

Also, there are other options of git rev-parse which should be dealt with: at least --show-cdup (could be eg. "git root --relative") and --show-prefix, but probably also others from the "Options for Files" in the man of git-rev-parse.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Arjun SreedharanNext: Junio C Hamano
Message 4 of 23 in “introduce git root”
  1. introduce git rootArjun Sreedharan, Nov 29, 2014
  2. Philip OakleyNov 29, 2014
  3. Arjun SreedharanNov 30, 2014
  4. Matthieu MoyNov 30, 2014
  5. Junio C HamanoDec 1, 2014
  6. Christian CouderDec 1, 2014
  7. Junio C HamanoDec 1, 2014
  8. Jeff KingDec 2, 2014
  9. Christian CouderDec 2, 2014
  10. Junio C HamanoDec 2, 2014
  11. Jeff KingDec 4, 2014
  12. Junio C HamanoDec 4, 2014
  13. Matthieu MoyDec 4, 2014
  14. Junio C HamanoDec 4, 2014
  15. Jeff KingDec 4, 2014
  16. Junio C HamanoDec 4, 2014
  17. Christian CouderDec 5, 2014
  18. Jeff KingDec 5, 2014
  19. Christian CouderDec 7, 2014
  20. Junio C HamanoDec 9, 2014
  21. Christian CouderDec 10, 2014
  22. Jeff KingDec 10, 2014
  23. Junio C HamanoDec 10, 2014

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.