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

Re: [PATCH] Make git log work for git CWD outside of work tree

From
Jeff King <peff@peff.net>
Date
Apr 12, 2017, 13:01 UTC
Message-ID
<20170412130145.jjnyait5234qsmys@sigill.intra.peff.net>
In-Reply-To
<CACsJy8DPFzgxqvPzpMbmoM4sMP7oSZ=eO6DJa+dv4sY=QKHjoA@mail.gmail.com>
On Wed, Apr 12, 2017 at 06:13:49PM +0700, Duy Nguyen wrote:
Show 10 quoted lines
> > Can't we model this after how setup_git_directory_gently() gives the
> > subcommands a choice?  While the majority of subcommands do not call
> > the _gently() variant and die when we are not in a repository, the
> > rest do use it and continue after learning that they are outside a
> > repository.
> 
> It may work, but we need to be careful because paths as command line
> arguments will not be relative to cwd anymore. If some code assumes
> cwd unchanged, they're in trouble. I guess they're in trouble either
> way because of the "sometimes chdir, sometimes not" current behavior.

Exactly. The code itself must respect "prefix", and if it doesn't, it's broken. So I don't think a code switch makes any sense here. It's not the code which needs to care, it's the user who might be relying on the externally visible behavior.

I can't think of a case where the existing behavior actually makes sense for the user, though. They've provided a $GIT_WORK_TREE, but somehow want their out-of-worktree relative paths to still work? What are they using the paths for? Surely:

  cd /out-of-tree
  echo content >foo
  GIT_DIR=/repo/.git GIT_WORK_TREE=/repo git add foo
shouldn't work?

Likewise reading .mailmap and .gitattributes from /out-of-tree is simply a bug.

I dunno. Maybe I am missing some subtle case, but it's not clear to me what the user would be trying to do by having git stay in the original directory.

-Peff
Previous: Duy NguyenNext: Duy Nguyen
Message 10 of 15 in “Make git log work for git CWD outside of work tree”
  1. Make git log work for git CWD outside of work treeDanny Sauer, Apr 9, 2017
  2. Johannes SchindelinApr 9, 2017
  3. Danny SauerApr 9, 2017
  4. Junio C HamanoApr 10, 2017
  5. Duy NguyenApr 10, 2017
  6. Jeff KingApr 10, 2017
  7. Duy NguyenApr 12, 2017
  8. Junio C HamanoApr 12, 2017
  9. Duy NguyenApr 12, 2017
  10. Jeff KingApr 12, 2017
  11. Duy NguyenApr 12, 2017
  12. Jeff KingApr 13, 2017
  13. Junio C HamanoApr 17, 2017
  14. Duy NguyenApr 17, 2017
  15. Jeff KingApr 12, 2017

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.