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
Michael McClimon <michael@mcclimon.org>
Date
Oct 22, 2022, 23:19 UTC
Message-ID
<Y1R6ecMO+6X8tFlF@newk>
In-Reply-To
<Y1Rp+7R7e+LFa5k6@coredump.intra.peff.net>
Show 5 quoted lines
> I prepared it on top of your fix in the mm/git-pm-try-catch-syntax-fix
> branch. That's not strictly necessary, since my patch deletes the line
> you fixed. :) But I think it's nicer to use your fix as the starting
> point, since it means the test runs but produces the wrong behavior,
> rather than barfing with a syntax error.

My vanity thanks you for this, even if it's not strictly necessary. As a professional programmer with roughly no C chops and a long-time admirer of the Git project, all I _really_ wanted to do was to fix a thing that was in my wheelhouse so that I could say I have a commit in the history. (This isn't a good reason on its own, of course, but I'm happy it was useful even if the line is immediately deleted!)

> We can fix this by just relying on rev-parse to tell us when we're not
> in a repository, which fixes the vulnerability. Furthermore, we'll ask
> its --is-bare-repository function to tell us if we're bare or not, and
> rely on that.

Your suggested patch seems fine to me, and indeed I think if we were writing it today we'd just rely on rev-parse to do the heavy lifting. It looks like the code in question -- and indeed, the syntax error in question -- blames to d5c7721d (Git.pm: Add support for subdirectories inside of working copies, 2006-06-23), at which point rev-parse did not appear to have any special handling for bare repositories.

-- 
Michael McClimon
michael@mcclimon.org
Previous: Jeff KingNext: Jeff King
Message 21 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.