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

Re: [PATCH] config: complain about --local outside of a git repo

From
Jeff King <peff@peff.net>
Date
May 15, 2017, 03:18 UTC
Message-ID
<20170515031831.c4wrhgm7gky3dldw@sigill.intra.peff.net>
In-Reply-To
<CANuW5x2-gzHuPN9ox8hEgNUiTsEKeAqeZQXZZ=SMFbsfabXd1w@mail.gmail.com>
On Sun, May 14, 2017 at 08:31:54PM -0400, Josh Hagins wrote:
Show 10 quoted lines
> For context, the "user.name" bit was purely notional; I just wanted to
> give a sample reproduction. Where I've actually been running into this
> in real life is with oh-my-git, a GitHub-themed Powerline bash prompt:
> https://github.com/arialdomartini/oh-my-git/blob/42c11f08540949b75bd513e6880a4ce6824a2bcc/base.sh#L52.
> 
> Since this command is invoked every time the prompt is build, I see
> the error message after every single command I run outside of a Git
> repository. While this is more indicative of a code smell in
> oh-my-git, I figured that, as you said, BUG assertions should never
> get hit in the wild. Thanks for the patch!

Ah, thanks for the context. That makes a lot more sense. I do think oh-my-git should just drop the "--local", which will cause git-config to follow the usual precedence rules (and it will skip repo-level config automatically when we are not in a repo).

Since the oh-my-git code only looks for "false", nobody would ever need to default the value to true in their ~/.gitconfig. But respecting the usual config rules would mean you could set it to "false" in ~/.gitconfig to turn it off everywhere, but then opt back into it for specific repos by setting it to "true" there. Probably not a use case anybody cares that much about, but it's how "git config" was meant to be used. :)

Anyway, thanks again for reporting the BUG assertion. I'm glad to be weeding out more cases.

-Peff
Previous: Josh Hagins
Message 25 of 25 in “[Git 2.13.0] BUG: setup_git_env called without repository”
  1. Josh HaginsMay 12, 2017
  2. Johannes SchindelinMay 12, 2017
  3. Josh HaginsMay 15, 2017
  4. config: complain about --local outside of a git repoJeff King, May 12, 2017
  5. Ævar Arnfjörð BjarmasonMay 12, 2017
  6. Jeff KingMay 13, 2017
  7. 0/3 BUG() and "config --local" outside of repoJeff King, May 13, 2017
  8. 1/3 usage.c: add BUG() functionJeff King, May 13, 2017
  9. Jeff KingMay 13, 2017
  10. Junio C HamanoMay 15, 2017
  11. 2/3 setup_git_env: convert die("BUG") to BUG()Jeff King, May 13, 2017
  12. 3/3 config: complain about --local outside of a git repoJeff King, May 13, 2017
  13. 0/4 Finish the conversion from die("BUG: ...") to BUG()Johannes Schindelin, May 2, 2018
  14. 1/4 test-tool: help verifying BUG() code pathsJohannes Schindelin, May 2, 2018
  15. Duy NguyenMay 2, 2018
  16. Johannes SchindelinMay 5, 2018
  17. 2/4 run-command: use BUG() to report bugs, not die()Johannes Schindelin, May 2, 2018
  18. Jeff KingMay 7, 2018
  19. 3/4 Replace all die("BUG: ...") calls by BUG() onesJohannes Schindelin, May 2, 2018
  20. 4/4 Convert remaining die*(BUG) messagesJohannes Schindelin, May 2, 2018
  21. Jeff KingMay 7, 2018
  22. Jonathan NiederMay 13, 2017
  23. Jeff KingMay 13, 2017
  24. Josh HaginsMay 15, 2017
  25. Jeff KingMay 15, 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.