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
Junio C Hamano <gitster@pobox.com>
Date
Apr 12, 2017, 08:41 UTC
Message-ID
<xmqqy3v6ow54.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CACsJy8B8osxd-0axJ9giaMYKuict2h1zW8TcYYuRFGXfBbdF0A@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 10 quoted lines
>> I think this is much more than just .mailmap, though. For instance, I
>> have noticed a similar problem with .gitattributes:
>
> Urgh. assuming that we should not read .gitattributes if there's no
> worktree to read from (similar to the "defaults to .git" situation),
> how about
>
>  - if mailmap stuff is requested, setup worktree, or die trying
>  - if worktree is detected, but setup code does not jump to it, do it
>  - if no worktree is detected, tell git-log to stop reading .gitattributes

My gut reaction is that we are doing something wrong once we start saying "if mailmap stuff is requested". This is not about .mailmap but is about how sanely the paths relative to the root of the working tree (which includes a path in the index, or comparing $commit:$path with $path in the working tree) can be named by any subcommand of Git.

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.

Perhaps we want a new bit GOTO_WORK_TREE_ROOT that is orthogonal to NEED_WORK_TREE to tell the codepath that calls cmd_foo() to always move to the root of the working tree (if there is one), regaredless of the behaviour f3bb8b4b84 documents. I have a strong suspicion that we didn't _care_ about a silly use case where GIT_WORK_TREE is specified and the command is started from somewhere completely unrelated to that location, and the users with such a silly use case didn't care either what Git does to the files in the working tree, i.e. what you quoted in your previous message

    "11. When user's cwd is outside worktree, cwd remains unchanged,
        prefix is NULL."
    This behavior probably started long before my topic though, mine was
    more of documentation, making worktree detection more consistent. It's

was not describing the design, but just describing whatever random thing the code happened to be doing.

Previous: Duy NguyenNext: Duy Nguyen
Message 8 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.