Re: Usability improvement request: git show revision -- file
- From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
- Date
- Mar 31, 2011, 19:59 UTC
- Message-ID
- <AANLkTimkdRtY_2S1U=Kog08EOAx_U2cgAFdEC60AZ4eO@mail.gmail.com>
- In-Reply-To
- <4D94322A.8030409@drmicha.warpmail.net>
On Thu, Mar 31, 2011 at 9:50 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:
Show 16 quoted lines
> Piotr Krukowiecki venit, vidit, dixit 31.03.2011 08:45: >> Hi, >> >> if there's existing way to do this please tell me. >> >> There's this file "src/subdir/file". I'm in the "src" directory and want to >> see the "file" at specific revision. >> >> Knowing about git show I'd expect something like this to work: >> >> $ git show master -- subdir/file >> >> But it shows nothing (no output, no warning). > > ...because you are asking git to show the commit master, filtered by > subdir/file, and if that file is not changed there, the commit is not
It wasn't - I was doing git-blame and wanted to see file as it was before the blamed commit.
> selected. If it is changed there, it shows you only the diff affecting
I see - that makes sense too.
> that file. (We might want to change this to filter the diff only.)
Not sure what you mean by that?
Show 8 quoted lines
>> Following also does not >> work as expected: >> >> $ git show master:subdir/file >> fatal: Path 'src/subdir/file' exists, but not 'subdir/file'. >> Did you mean 'master:src/subdir/file'? > > But git is really understanding about your situation, isn't it? ;)
Yeah, but this looks like a workround for a common problem - people specify relative path a lot, so a warning was added.
Show 13 quoted lines
>> Of course following works: >> >> $ git show master:src/subdir/file >> >> but it's not very convenient to have to specify full path, and it's not what >> you would expect given that most other commands accept "-- relativepath" >> syntax. > > It's not the command in this case, but the "commit:pathspec" syntax, and > for every command which understands it, it is relative to root (i.e. > expects a full path). But we do have a syntax for relative: > > git show master:./subdir/file
Thanks, I'll try to remember. I don't have a better idea for solving this problem.
-- Piotr Krukowiecki