Hello,
I was frustrated for some minutes trying to get the HEAD version of a
file, as is in the documentation. Using git's source as an example:
git/Documentation$ git show HEAD:docbook.xsl
fatal: ambiguous argument 'HEAD:docbook.xsl': unknown revision or path
not in the working tree.
Use '--' to separate paths from revisions
<hmmm>
$ git show HEAD -- docbook.xsl
<nil>
$
Seeing in the documentation that the parsing was made by git-rev-parse,
I tried running git-rev-parse directly, ending with the same error.
I tried with the full path, just in case, but it didn't work also
($PWD/docbook.xsl).
Until finally I tried the absolute path as git is concerned, and it
worked.
It works anywhere:
git$ git show HEAD:Documentation/docbook.xsl
<contents>
git/Documentation$ git show HEAD:Documentation/docbook.xsl
<contents>
...
Is it difficult to make rev-parse accept relative path specifications?
--
Luciano Rocha [off-list ref]
Eurotux Informática, S.A. <http://www.eurotux.com/>
Luciano Rocha wrote (2008-05-26 20:58 +0100):
Is it difficult to make rev-parse accept relative path specifications?
I don't know but let's consider this: The revision user is asking for
with "git show <commit>:<path>" may not even contain the directory user
is currently in. Also, there may not be any working directory at all, or
user may be completely outside the repository and using "git
--git-dir=/somewhere/else". I guess the system is much simpler as the
"<commit>:" always refers to repository's root.
If you are using Git's bash completions it's easy to complete paths with
"git show <commit>:". For example, try
$ git show HEAD~10:Docum<tab>
and the path is completed.
On Mon, May 26, 2008 at 11:18:42PM +0300, Teemu Likonen wrote:
Luciano Rocha wrote (2008-05-26 20:58 +0100):
quoted
Is it difficult to make rev-parse accept relative path specifications?
I don't know but let's consider this: The revision user is asking for
with "git show <commit>:<path>" may not even contain the directory user
is currently in. Also, there may not be any working directory at all, or
user may be completely outside the repository and using "git
--git-dir=/somewhere/else". I guess the system is much simpler as the
"<commit>:" always refers to repository's root.
If <commit>:<path> is valid assuming the repository's root, then use it.
If it isn't, try <commit>:<path_to_git_root>/<path>.
If you are using Git's bash completions it's easy to complete paths with
"git show <commit>:". For example, try
I find bash-completion more an hassle than useful, thanks anyway.
$ git show HEAD~10:Docum<tab>
and the path is completed.
But a user usually thinks relative to the current directory, not to the
project's root.
But I should check the archives before any further discussion, as Junio
C Hamano observed.
Thanks for your input.
--
Luciano Rocha [off-list ref]
Eurotux Informática, S.A. <http://www.eurotux.com/>