# core.pager handling broken

5 messages from 2007-08-06 to 2007-08-06. Participants: Brian Gernhardt, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/9410

## Brian Gernhardt, 2007-08-06 15:56

Subject: core.pager handling broken
Message-ID: <2BA49414-54E0-4353-B237-7799B675FAE8@silverinsanity.com>
URL: https://gitlist.dev/e/2BA49414-54E0-4353-B237-7799B675FAE8%40silverinsanity.com

```
I don't have time to look into it, but something broke the core.pager  
variable.  I've bisected it down to  
"e90fdc39b6903502192b2dd11e5503cea721a1ad: Clean up work-tree  
handling".  With this commit:

$ git config core.pager
tig
$ git log
# Uses less
$ GIT_PAGER=tig git log
# Uses tig

I don't have time to track it down right now (I'm off visiting  
family), but will look into it tomorrow unless someone thinks it's  
obvious and points it out before then.

~~ Brian

```

## Johannes Schindelin, 2007-08-06 17:32

Subject: [PATCH] check_repository_format_version(): run git_default_config() again
Message-ID: <Pine.LNX.4.64.0708061831070.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0708061831070.14781%40racer.site
In-Reply-To: <2BA49414-54E0-4353-B237-7799B675FAE8@silverinsanity.com>

```

I broke this in "e90fdc39: Clean up work-tree handling".  It is
needed, for example for interpreting core.pager before starting the
pager.

Noticed by Brian Gernhardt.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	My first commit with git-gui!  Yeah!

	On Mon, 6 Aug 2007, Brian Gernhardt wrote:

	> I don't have time to look into it, but something broke the 
	> core.pager variable.  I've bisected it down to 
	> "e90fdc39b6903502192b2dd11e5503cea721a1ad: Clean up work-tree 
	> handling".

	Thanks.

 setup.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index 4945eb3..35fa031 100644
--- a/setup.c
+++ b/setup.c
@@ -355,7 +355,8 @@ int check_repository_format_version(const char *var, const char *value)
 			free(git_work_tree_cfg);
 		git_work_tree_cfg = xstrdup(value);
 		inside_work_tree = -1;
-	}
+	} else
+		return git_default_config(var, value);
 	return 0;
 }
 
-- 
1.5.3.rc4.17.gb980

```

## Junio C Hamano, 2007-08-06 20:26

Subject: Re: [PATCH] check_repository_format_version(): run git_default_config() again
Message-ID: <7vsl6wbe9e.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vsl6wbe9e.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <7vbqdkcxy3.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano <gitster@pobox.com> writes:

> Sorry, I do not understand this patch from the commit log
> description.
>
> In the old days in 1.5.2 before either implementation of
> work-tree stuff, this function never called git_default_config()
> and presumably "git log" worked as expected for Brian.  Why is
> this call needed _here_, not in some of the callers?

Sorry scratch that.  v1.5.2 did not even have core.pager.

I see git_config(git_default_config) is called from
setup_git_directory_gently() in the version that introduced
core.pager.  Curiously enough it does the config twice, once
where no GIT_DIR is set and it sets inside_work_tree, and
another by calling git_config(git_setup_config) -- big thanks
for sorting this mess out.

I however have a mild suspicion that this has to be done much
earlier.

For example, "git -p log" would first call handle_options(),
which calls the setup_pager() logic, and then we call
handle_internal_command() which calls setup_git_directory() that
eventually leads to the callchain of finding the .git directory
and .git/config file to be used.  In that case, when we make the
call to setup_pager() from handle_options(), we haven't even
figured out if there is a configuration file, let alone reading
from it.

We could work this around by having the "we need config -- where
is it" logic in setup_pager(), but if we later have new options
like -p that affects the way how git wrapper itself behaves
based on the configuration, we would need the same "early config
read" logic to support it.

```

## Junio C Hamano, 2007-08-06 23:08

Subject: Re: [PATCH] check_repository_format_version(): run git_default_config() again
Message-ID: <7vy7go9s84.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy7go9s84.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <7vsl6wbe9e.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano <gitster@pobox.com> writes:

> I see git_config(git_default_config) is called ... big thanks
> for sorting this mess out.
>
> I however have a mild suspicion that this has to be done much
> earlier.
> ...
> We could work this around by having the "we need config -- where
> is it" logic in setup_pager(), but if we later have new options
> like -p that affects the way how git wrapper itself behaves
> based on the configuration, we would need the same "early config
> read" logic to support it.

Ok, how about this as an interim solution?

This is a minimum change in the sense that it restores the old
behaviour of not even reading config in setup_git_directory(),
but have the core.pager honored when we know it matters.

---

 pager.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/pager.c b/pager.c
index 3bfed02..8bac9d9 100644
--- a/pager.c
+++ b/pager.c
@@ -31,8 +31,11 @@ void setup_pager(void)
 
 	if (!isatty(1))
 		return;
-	if (!pager)
+	if (!pager) {
+		if (!pager_program)
+			git_config(git_default_config);
 		pager = pager_program;
+	}
 	if (!pager)
 		pager = getenv("PAGER");
 	if (!pager)

```

## Johannes Schindelin, 2007-08-06 23:26

Subject: Re: [PATCH] check_repository_format_version(): run git_default_config() again
Message-ID: <Pine.LNX.4.64.0708070025320.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0708070025320.14781%40racer.site
In-Reply-To: <7vy7go9s84.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Mon, 6 Aug 2007, Junio C Hamano wrote:

> This is a minimum change in the sense that it restores the old
> behaviour of not even reading config in setup_git_directory(),
> but have the core.pager honored when we know it matters.

Looks obviously correct to me, and much better than relying on other sites 
reading the config.

ACK.

Ciao,
Dscho

```
