When passing objects to the `git log`, by just naming them or using
the `--objects` option, relative paths are evaluated using the current
working directory instead of the current working tree path.
Even the error message is clearly wrong.
"unknown revision or path not in the working tree."
Example:
Given a repo at "~/path/to_repo" containing a file such as "README.md"
("~/path/to_repo/README.md")
~/path$ git --work-tree=~/path/to_repo log README.md
fatal: ambiguous argument 'README.md': unknown revision or path not in
the working tree.
As you can see here
(https://github.com/robertodecurnex/git/blob/master/setup.c#L147) git
is trying to `lstat` the path as it was given when it should validate
the file existence within the work tree (perpending the work-tree
before the file name).
Note: I now several workarounds for this, I'm not looking for a
solution to the specific problem but to discuss the implementation and
evaluate a change over the current behavior.
Regards,
--
Roberto Decurnex
Hi Roberto,
Roberto Eduardo Decurnex Gorosito wrote:
When passing objects to the `git log`, by just naming them or using
the `--objects` option, relative paths are evaluated using the current
working directory instead of the current working tree path.
Why should they be relative to the worktree root? When you use
relative paths within a worktree, they are not relative to the
worktree root. For example, the following works within a clone of
git.git:
$ cd Documentation
$ git log git.txt
You might be looking for 'git -C <directory>', which chdirs to the
named directory so paths are relative to there.
Hope that helps,
Jonathan
Ok. Yes, it 's kind of tricky. But the `-- <path>` does both things.
`-- <path>` looks for the relative path within the current directory
but defaults to the work-tree root if your current directory does not
belong to the repo.
About `git -C <dir>`, awesome feature, I love that, but it's not my
point. (and I'm actually maintaining the ruby-git gem, supporting git
= 1.6 T_T)
I really appreciate your feedback.
Regards,
--
Roberto Decurnex
On Mon, Sep 29, 2014 at 5:56 PM, Jonathan Nieder [off-list ref] wrote:
Hi Roberto,
Roberto Eduardo Decurnex Gorosito wrote:
quoted
When passing objects to the `git log`, by just naming them or using
the `--objects` option, relative paths are evaluated using the current
working directory instead of the current working tree path.
Why should they be relative to the worktree root? When you use
relative paths within a worktree, they are not relative to the
worktree root. For example, the following works within a clone of
git.git:
$ cd Documentation
$ git log git.txt
You might be looking for 'git -C <directory>', which chdirs to the
named directory so paths are relative to there.
Hope that helps,
Jonathan