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

Re: [PATCH] git-show.txt: mention that object path must be relative in EXAMPLES.

From
Jari Aalto <jari.aalto@cante.net>
Date
Feb 8, 2009, 07:52 UTC
Message-ID
<87skmpxt5g.fsf@jondo.cante.net>
In-Reply-To
<200902072259.29121.bss@iguanasuicide.net>
"Boyd Stephen Smith Jr." <bss@iguanasuicide.net> writes:
Show 21 quoted lines
> On Saturday 07 February 2009 17:31:47 Jakub Narebski wrote:
>
>> Jari Aalto <jari.aalto@cante.net> writes:
>> > +	`next`. *Note:* the 'object' path must always be relative to git
>> > +	project root. This wouldn't have worked:
>> > +
>> > +	$ cd Documentation
>> > +	$ git show next~10:README
>>
>> Actually that is not exactly true.  In the <tree-ish>:<path> the
>> 'object' path must be always relative to <tree-ish), in this case
>> to "next~10", which means relative to project root at given commit
>> (important in case of subtree merge).
>
> Also important if one of your commits moves everything into a subdirectory in 
> preparation for adding new top-level directories.  Sure, everyone on this list 
> always knows exactly what their project tree should look like from the first 
> commit, but there may be users of git that aren't that sophisticated.  ;)
>
> So, I think better additional text would simply be:
> *Note:* the path is interpreted relative to the tree-ish.
Changed, See below.
> A example of what not to do is probably not useful in this case.
It is important to give examples. This is a common mistake:
    $ cd todir
    $ ls file.txt
    file.txt
    $ git show 8b2de93:file.txt
    fatal: ambiguous argument '8b2de93:file.txt':
    unknown revision or path not in the working tree.

The path is in working tree from user's point of view but Git expects it from project root. Not intuitive if you're deep/in/the/directory/hierarchy

Jari
>From 9de53447e456aaf5ab64f616df76f05888cc0d76 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Sun, 8 Feb 2009 09:43:57 +0200
Subject: [PATCH] git-show.txt: mention that object path must be relative in EXAMPLES.
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 Documentation/git-show.txt |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt
index 48b612e..27f771b 100644
--- a/Documentation/git-show.txt
+++ b/Documentation/git-show.txt
@@ -57,7 +57,13 @@ git show v1.0.0^\{tree\}::
 git show next~10:Documentation/README::
 	Shows the contents of the file `Documentation/README` as
 	they were current in the 10th last commit of the branch
-	`next`.
+	`next`. *Note:* the path is interpreted relative to the tree-ish.
+	A typical mistake is that after changing to a subdirectory from
+	project root, the current' directory's filename is used:
+
+	$ cd Documentation
+	$ git show next~10:README		 # Error, needs path
+	$ git show next~10:Documentation/README  # Ok, relative to tree-ish
 
 git show master:Makefile master:t/Makefile::
 	Concatenates the contents of said Makefiles in the head
-- 
1.5.6.5
Previous: Boyd Stephen Smith Jr.Next: Boyd Stephen Smith Jr.
Message 4 of 5 in “git-show.txt: mention that object path must be relative in EXAMPLES.”
  1. git-show.txt: mention that object path must be relative in EXAMPLES.Jari Aalto, Feb 7, 2009
  2. Jakub NarebskiFeb 7, 2009
  3. Boyd Stephen Smith Jr.Feb 8, 2009
  4. Jari AaltoFeb 8, 2009
  5. Boyd Stephen Smith Jr.Feb 8, 2009

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.