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

[PATCH v2 0/1] Make the includeif:onbranch feature more robust

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 31, 2019, 20:06 UTC
Message-ID
<pull.300.v2.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.300.git.gitgitgadget@gmail.com>

I actually stumbled over this while rebasing the VFS for Git patches, in relation with the pre-command hook that we still support there (we're slowly migrating toward Trace2, of course).

Once I figured out what the problem was, I hunted for a way to trigger this bug in plain Git, and git help -a is the one I settled on. It had to be a command that uses the early config machinery (and git help -a uses it to list all aliases), and it had to be a command that does not discover a .git directory automatically (cmd_help is listed without any flags in git.c, so: check).

Of course, part of me wants to just go and dig into the refs part of the code to introduce an equivalent to the "early config" machinery (calling it "early ref store"), but:

 1. We're really in feature freeze, and I want this bug fix to go into
    v2.23.0.
 2. It is actually a pretty obscure thing to want: a branch-dependent config
    that is used that early that the Git directory was not yet discovered. I 
    could imagine that some power user wants to play some games at some
    stage, say, with the pager depending on the name of the current branch,
    but even then, to run into the issue with this here patch where it
    simply ignores the includeif.onbranch: setting in the early config code
    path, a command has to be run that does not immediately set up 
    the_repository->gitdir but still wants to use the configured pager.

So yes, this patch introduces a known issue, but it does fix a BUG() where no bug should be reported.

Changes since v1:
 * Now using my correct email address for Git contributions.
Johannes Schindelin (1):
  config: work around bug with includeif:onbranch and early config
 config.c                | 3 ++-
 t/t1309-early-config.sh | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
base-commit: 026dd738a6e5f1e42ef0f390feacb5ed6acc4ee8
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-300%2Fdscho%2Fonbranch-and-early-config-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-300/dscho/onbranch-and-early-config-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/300
Range-diff vs v1:
 1:  4aa8834013 ! 1:  ea1a746113 config: work around bug with includeif:onbranch and early config
     @@ -1,4 +1,4 @@
     -Author: Johannes Schindelin <johasc@microsoft.com>
     +Author: Johannes Schindelin <johannes.schindelin@gmx.de>
      
          config: work around bug with includeif:onbranch and early config
      
-- 
gitgitgadget
Previous: Junio C HamanoNext: Johannes Schindelin via GitGitGadget
Message 4 of 17 in “Make the includeif:onbranch feature more robust”
  1. 0/1 Make the includeif:onbranch feature more robustJohannes Schindelin via GitGitGadget, Jul 31, 2019
  2. 1/1 config: work around bug with includeif:onbranch and early configJohannes Schindelin via GitGitGadget, Jul 31, 2019
  3. Junio C HamanoJul 31, 2019
  4. 0/1 Make the includeif:onbranch feature more robustJohannes Schindelin via GitGitGadget, Jul 31, 2019
  5. 1/1 config: work around bug with includeif:onbranch and early configJohannes Schindelin via GitGitGadget, Jul 31, 2019
  6. Jeff KingJul 31, 2019
  7. Johannes SchindelinJul 31, 2019
  8. Jeff KingJul 31, 2019
  9. Jeff KingAug 1, 2019
  10. Jeff HostetlerAug 1, 2019
  11. 0/3 the_repository initialization cleanupJeff King, Aug 6, 2019
  12. 1/3 t1309: use short branch name in includeIf.onbranch testJeff King, Aug 6, 2019
  13. 2/3 common-main: delay trace2 initializationJeff King, Aug 6, 2019
  14. 3/3 config: stop checking whether the_repository is NULLJeff King, Aug 6, 2019
  15. Jeff KingAug 6, 2019
  16. Johannes SchindelinAug 8, 2019
  17. Jeff KingAug 6, 2019

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.