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

`git log relative_path_to_object` does not respect the --work-tree path

From
Roberto Eduardo Decurnex Gorosito <decurnex.roberto@gmail.com>
Date
Sep 29, 2014, 16:40 UTC
Message-ID
<CABj5xzc0bVfyzR5PD5K3STSvdvWEOYeMkayB=GTfKbfij+G5Zw@mail.gmail.com>

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

Next: Junio C Hamano
Message 1 of 5 in “`git log relative_path_to_object` does not respect the --work-tree path”
  1. Roberto Eduardo Decurnex GorositoSep 29, 2014
  2. Junio C HamanoSep 29, 2014
  3. Roberto Eduardo Decurnex GorositoSep 29, 2014
  4. Jonathan NiederSep 29, 2014
  5. Roberto Eduardo Decurnex GorositoSep 30, 2014

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.