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

Re: [PATCH v2 2/2] setup: allow Git.pm to do unsafe repo checking

From
Jeff King <peff@peff.net>
Date
Oct 22, 2022, 21:18 UTC
Message-ID
<Y1ReKB701QXRv64A@coredump.intra.peff.net>
In-Reply-To
<xmqq1qr0ifya.fsf@gitster.g>
On Fri, Oct 21, 2022 at 10:29:33PM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> I also have to wonder (and this is *not* a suggestion for inventing
> an alternative fix for perl/Git.pm) if we were creating perl/Git.pm
> from scratch today, we even need to be worried about this issue.  We
> may have Git::repo_path() helper but if we call it in a natural way
> (read: as if an interactive end-user would type commands), it is
> likely that we would run "git rev-parse --git-dir" or something
> without setting GIT_DIR, and when we need to run "git" command, say
> "git diff", we would also run "git diff" as if the end user would
> type from within their interactive session and without setting
> GIT_DIR, and everything should work.  IOW, why do we even setting
> and exporting the auto-detected value in GIT_DIR?
I think it has to in order to avoid surprises. If I do this:
  perl -MGit -e '
    my $r = Git->repository;
    chdir("/somewhere/else");
    $r->git_command(...);
  '

that command ought to run in the repository I opened earlier. So I think to keep the illusion of a lib-ified object, creating that object has to lock in the path.

But it really seems like we should be asking rev-parse what that path is, not trying to do any magic ourselves.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 23 in “Git.pm: add semicolon after catch statement”
  1. 0/1 Git.pm: add semicolon after catch statementMichael McClimon, Oct 16, 2022
  2. 1/1 Git.pm: add semicolon after catch statementMichael McClimon, Oct 16, 2022
  3. Jeff KingOct 16, 2022
  4. Michael McClimonOct 17, 2022
  5. Jeff KingOct 17, 2022
  6. Michael McClimonOct 18, 2022
  7. Johannes SchindelinNov 10, 2022
  8. Jeff KingNov 10, 2022
  9. 0/2 Fix behavior of Git.pm in unsafe bare repositoriesMichael McClimon, Oct 22, 2022
  10. 1/2 Git.pm: add semicolon after catch statementMichael McClimon, Oct 22, 2022
  11. 2/2 setup: allow Git.pm to do unsafe repo checkingMichael McClimon, Oct 22, 2022
  12. Junio C HamanoOct 22, 2022
  13. Jeff KingOct 22, 2022
  14. Junio C HamanoOct 22, 2022
  15. Ævar Arnfjörð BjarmasonOct 22, 2022
  16. Jeff KingOct 22, 2022
  17. Ævar Arnfjörð BjarmasonOct 24, 2022
  18. Jeff KingOct 24, 2022
  19. Jeff KingOct 22, 2022
  20. Jeff KingOct 22, 2022
  21. Michael McClimonOct 22, 2022
  22. Jeff KingOct 24, 2022
  23. Junio C HamanoOct 22, 2022

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.