git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Usability improvement request: git show revision -- file

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 31, 2011, 07:50 UTC
Message-ID
<4D94322A.8030409@drmicha.warpmail.net>
In-Reply-To
<AANLkTi=JPVXD7Je7Rz9yhKHnJo+K2rs5WnwTY22c3h6L@mail.gmail.com>
Piotr Krukowiecki venit, vidit, dixit 31.03.2011 08:45:
Show 12 quoted lines
> 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 selected. If it is changed there, it shows you only the diff affecting that file. (We might want to change this to filter the diff only.)

Show 6 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? ;)
Show 8 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

Cheers, Michael

Previous: Piotr KrukowieckiNext: Michael J Gruber
Message 2 of 29 in “Usability improvement request: git show revision -- file”
  1. Piotr KrukowieckiMar 31, 2011
  2. Michael J GruberMar 31, 2011
  3. 1/3 t1506: factor out test for "Did you mean..."Michael J Gruber, Mar 31, 2011
  4. 2/3 sha1_name: Suggest commit:./file for path in subdirMichael J Gruber, Mar 31, 2011
  5. Junio C HamanoMar 31, 2011
  6. Michael J GruberApr 1, 2011
  7. Junio C HamanoApr 1, 2011
  8. 3/3 builtin/show.c: do not prune by pathspecMichael J Gruber, Mar 31, 2011
  9. Johannes SixtMar 31, 2011
  10. Michael J GruberMar 31, 2011
  11. Johannes SixtMar 31, 2011
  12. Michael J GruberMar 31, 2011
  13. Nguyen Thai Ngoc DuyMar 31, 2011
  14. Michael J GruberMar 31, 2011
  15. Nguyen Thai Ngoc DuyMar 31, 2011
  16. Michael J GruberMar 31, 2011
  17. Junio C HamanoMar 31, 2011
  18. Michael J GruberApr 1, 2011
  19. 0/4 reflog, show and command line overridesMichael J Gruber, Apr 1, 2011
  20. 1/4 builtin/log.c: separate default and setup of cmd_log_init()Michael J Gruber, Apr 1, 2011
  21. 2/4 t/t1411: test reflog with formatsMichael J Gruber, Apr 1, 2011
  22. 3/4 reflog: fix overriding of command line optionsMichael J Gruber, Apr 1, 2011
  23. 4/4 builtin/show: do not prune by pathspecMichael J Gruber, Apr 1, 2011
  24. Junio C HamanoApr 1, 2011
  25. Junio C HamanoApr 1, 2011
  26. Michael J GruberApr 3, 2011
  27. Junio C HamanoApr 4, 2011
  28. Michael J GruberApr 5, 2011
  29. Piotr KrukowieckiMar 31, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.