Felipe Contreras [off-list ref] writes:
On Wed, May 29, 2013 at 1:26 PM, Ramkumar Ramachandra
[off-list ref] wrote:
quoted
Bráulio Bhavamitra wrote:
quoted
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 say
cd 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).
Junio C Hamano wrote:
quoted
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.
How is the project built? When I type `make` inside Documentation/, I
want documentation to be built. When I want a toplevel-build, I use a
custom git-make function (which does a cd before calling make).
[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 say
cd Documentation; git blame :/Makefile
*scratches head*
cd Documentation; git blame ../Makefile
Isn't this how pathspecs are specified everywhere?
cd Documentation; git log ../Makefile
cd Documentation; git log -L0,10:../Makefile
What is the difference between "concrete path" and "pathspec"?
On Thu, May 30, 2013 at 3:07 AM, Junio C Hamano [off-list ref] wrote:
*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 say
cd 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).
You should have CCed me when it's about pathspec :) At least we can
safely turn on :/ trick for git-blame and reject other features (like
globbing) that blame can't handle. I'll look into how easy/hard to
make git-blame support pathspec.
--
Duy