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
Duy Nguyen <pclouds@gmail.com>
Date
Apr 17, 2017, 10:29 UTC
Message-ID
<CACsJy8ATXZZ27wHFHCUUoAbAjOzaaOUDrn=enSu8dsaCOk=fLQ@mail.gmail.com>
In-Reply-To
<20170413212909.eb7zrhs7rzk6nxl6@sigill.intra.peff.net>
On Fri, Apr 14, 2017 at 4:29 AM, Jeff King <peff@peff.net> wrote:
Show 25 quoted lines
> On Wed, Apr 12, 2017 at 08:11:22PM +0700, Duy Nguyen wrote:
>
>> On Wed, Apr 12, 2017 at 8:01 PM, Jeff King <peff@peff.net> wrote:
>> > 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.
>>
>> Not sure if it really happens. But if we jump from worktree is inside
>> original cwd and we have to jump to worktree, we set empty prefix, not
>> "../../../" one. So we can't refer back to files relative to original
>> cwd with prefix. I was kinda hoping "super prefix" would solve it, but
>> that one seems designed specifically for submodules.
>
> Ah, right. I think the issue is that "prefix" really serves two uses.
> For things like command-line arguments, we use to find the original path
> after we've moved. But we also use it for "where in the working tree
> are we".
>
> So with an out-of-tree cwd, we'd want to set the first one to the real
> path ("../../whatever" or even just an absolute path), but the second
> one would probably be empty (i.e., just pretend that we started from the
> top-level).
>
> But that would require first refactoring all of the cmd_* functions to
> handle those prefixes separately.

Yeah. I probably shouldn't start another series until all others of mine settle. But if anyone is changing cmd_*, I suggest we take this opportunity to pass "struct struct startup_info *" in the as the only option. argv/argv could be stored there as well. And you can add "cwd_prefix" to present that "../../whatever" (I would avoid the name "super prefix" until things settle), or just keep the original "cwd" in there and let people do whatever they want with it.

-- 
Duy
Previous: Junio C HamanoNext: Jeff King
Message 14 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.