threads / discuss / 9410

core.pager handling broken

Subject: core.pager handling broken

## tl;dr

5 messages between Aug 6, 2007 and Aug 6, 2007.

replies: 4people: 3as markdown or json

Brian Gernhardt· Aug 6, 2007, 15:56 UTC · lore

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· Aug 6, 2007, 17:32 UTC · re: Brian Gernhardt · lore

[PATCH] check_repository_format_version(): run git_default_config() again

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· Aug 6, 2007, 20:26 UTC · lore

Re: [PATCH] check_repository_format_version(): run git_default_config() again

Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> 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· Aug 6, 2007, 23:08 UTC · re: Junio C Hamano · lore

Re: [PATCH] check_repository_format_version(): run git_default_config() again

Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> 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· Aug 6, 2007, 23:26 UTC · re: Junio C Hamano · lore

Re: [PATCH] check_repository_format_version(): run git_default_config() again

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

← back to recent threads