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

Re: includeIf breaks calling dashed externals

From
Jeff King <peff@peff.net>
Date
Apr 14, 2017, 17:43 UTC
Message-ID
<20170414174337.n6qksfvugkrexnsi@sigill.intra.peff.net>
In-Reply-To
<CAKPyHN1W175wm1doQHF71vB3PHpU2o=xtEAcZMqZtR=U_Kv0_g@mail.gmail.com>
On Fri, Apr 14, 2017 at 07:04:23PM +0200, Bert Wesarg wrote:
Show 20 quoted lines
> Dear Duy,
> 
> heaving an includeIf in a git config file breaks calling external git
> commands, most prominently git-gui.
> 
> $ git --version
> git version 2.12.2.599.gcf11a6797
> $ git rev-parse --is-inside-work-tree
> true
> $ git echo
> git: 'echo' is not a git command. See 'git --help'.
> 
> Did you mean this?
>     fetch
> $ echo '[includeIf "gitdir:does-not-exists"]path = does-not-exists'
> >>.git/config
> $ git rev-parse --is-inside-work-tree
> true
> $ git echo
> fatal: BUG: setup_git_env called without repository
Probably this fixes it:
diff --git a/config.c b/config.c
index b6e4a57b9..8d66bdf56 100644
--- a/config.c
+++ b/config.c
@@ -213,6 +213,9 @@ static int include_by_gitdir(const char *cond, size_t cond_len, int icase)
 	struct strbuf pattern = STRBUF_INIT;
 	int ret = 0, prefix;
 
+	if (!have_git_dir())
+		return 0;
+
 	strbuf_add_absolute_path(&text, get_git_dir());
 	strbuf_add(&pattern, cond, cond_len);
 	prefix = prepare_include_condition_pattern(&pattern);

But it does raise a question of reading config before/after repository
setup, since those will give different answers. I guess they do anyway
because of $GIT_DIR/config.

-Peff
Previous: Bert WesargNext: Duy Nguyen
Message 2 of 24 in “includeIf breaks calling dashed externals”
  1. Bert WesargApr 14, 2017
  2. Jeff KingApr 14, 2017
  3. Duy NguyenApr 15, 2017
  4. Jeff KingApr 16, 2017
  5. 1/2 config: prepare to pass more info in git_config_with_options()Nguyễn Thái Ngọc Duy, Apr 16, 2017
  6. 2/2 config: handle conditional include when $GIT_DIR is not set upNguyễn Thái Ngọc Duy, Apr 16, 2017
  7. Jeff KingApr 16, 2017
  8. Duy NguyenApr 17, 2017
  9. Jeff KingApr 18, 2017
  10. Duy NguyenApr 17, 2017
  11. 1/3 config: prepare to pass more info in git_config_with_options()Nguyễn Thái Ngọc Duy, Apr 17, 2017
  12. 2/3 config: handle conditional include when $GIT_DIR is not set upNguyễn Thái Ngọc Duy, Apr 17, 2017
  13. Junio C HamanoApr 18, 2017
  14. Junio C HamanoApr 18, 2017
  15. Jeff KingApr 18, 2017
  16. 3/3 config: correct file reading order in read_early_config()Nguyễn Thái Ngọc Duy, Apr 17, 2017
  17. Jeff KingApr 18, 2017
  18. Junio C HamanoApr 18, 2017
  19. Jeff KingApr 18, 2017
  20. Junio C HamanoApr 18, 2017
  21. Junio C HamanoApr 18, 2017
  22. Jeff KingApr 18, 2017
  23. Jeff KingApr 16, 2017
  24. Duy NguyenApr 17, 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.