Re: [PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-17 Thread Jeff King
On Mon, Apr 17, 2017 at 05:07:52PM +0700, Duy Nguyen wrote: > > You can see the second problem with: > > > > # random external > > cat >git-foo <<-\EOF > > #!/bin/sh > > echo foo > > EOF > > chmod +x git-foo > > PATH=$PWD:$PATH > > > > git init > > git config pager.foo 'sed s/^/r

Re: [PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-17 Thread Jeff King
On Mon, Apr 17, 2017 at 09:13:35AM +0700, Duy Nguyen wrote: > > So we call get_git_dir() always when we're not in early config. Even if > > we don't have a git dir! Doesn't this mean that programs operating > > outside of a repo will still hit the BUG? I.e.: > > > > git config --global includei

Re: [PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-17 Thread Junio C Hamano
Duy Nguyen writes: > (To Junio, this series conflicts slightly with > nd/conditional-config-include, let me know if you want me to rebase > this on top of that) I think I can manage---having to resolve inter-topic conflict every once in a while is a good sanity check for me anyway ;-). Please h

Re: [PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-17 Thread Duy Nguyen
(To Junio, this series conflicts slightly with nd/conditional-config-include, let me know if you want me to rebase this on top of that) On Sun, Apr 16, 2017 at 10:51 PM, Jeff King wrote: >> + if (opts.git_dir) { >> struct git_config_source repo_config; >> >> memset

Re: [PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-16 Thread Duy Nguyen
On Sun, Apr 16, 2017 at 11:51:32AM -0400, Jeff King wrote: > > diff --git a/cache.h b/cache.h > > index e29a093839..27b7286f99 100644 > > --- a/cache.h > > +++ b/cache.h > > @@ -1884,6 +1884,8 @@ enum config_origin_type { > > > > struct config_options { > > unsigned int respect_includes : 1;

Re: [PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-16 Thread Jeff King
On Sun, Apr 16, 2017 at 05:41:25PM +0700, Nguyễn Thái Ngọc Duy wrote: > If setup_git_directory() and friends have not been called, > get_git_dir() (because of includeIf.gitdir:XXX) would lead to > > die("BUG: setup_git_env called without repository"); > > There are two cases when a config fi

[PATCH 2/2] config: handle conditional include when $GIT_DIR is not set up

2017-04-16 Thread Nguyễn Thái Ngọc Duy
If setup_git_directory() and friends have not been called, get_git_dir() (because of includeIf.gitdir:XXX) would lead to die("BUG: setup_git_env called without repository"); There are two cases when a config file could be read before $GIT_DIR is located. The first one is check_repository_form