Re: [git-users] Highlevel (but simple to implement) commands provided by default for git
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 29, 2013, 20:07 UTC
- Message-ID
- <7v38t5sg7k.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CAMP44s1VFxarV4Gp5KsxhFKJbmd033-DW8koe9P4XUZQcX4mrA@mail.gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 8 quoted lines
> On Wed, May 29, 2013 at 1:26 PM, Ramkumar Ramachandra > <artagnon@gmail.com> wrote: >> Bráulio Bhavamitra wrote: >>> root = rev-parse --show-toplevel >> >> What is your usecase for this? > > Some Git commands expect to be in the top level directory (e.g. git blame).
"Git" things we can fix [*1*], but more importantly, build structure of many project may require you to go up to the top to build the whole thing, so being able to get a relative path to the top when you are deep inside is a necessity.
[Footnote]
*1* "blame" is an oddball (and I suspect the recent log -Ln,m:path
may share the same) in that it really wants a concret path, not
a pathspec, so you cannot even saycd Documentation; git blame :/Makefile
I think the right fix is to teach it that the argument it has
been taking as a pathname is actually a pathspec, match the
pathspec with appropriate place (either in the working tree, or
in the commit we start digging from), and use the path that the
pathspec matches to a single one (otherwise barf).