Re: includeIf breaks calling dashed externals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 14, 2017 at 07:04:23PM +0200, Bert Wesarg wrote:

> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]