{"thread":{"id":"5039","subject":"[PATCH] pager: config variable pager.program","startedAt":"2006-07-29T21:28:13Z","lastAt":"2006-07-31T13:27:00Z","messageCount":5,"participants":["Matthias Lederhofer","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24352","messageId":"E1G6wM1-00040z-Bu@moooo.ath.cx","threadId":"5039","inReplyTo":null,"subject":"[PATCH] pager: config variable pager.program","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-07-29T21:28:13Z","receivedAt":"2006-07-29T21:28:13Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nI'd like to use another pager (or other options) with git than the\nnormal pager.  Normally I would not want the -R option with less but\nfor git less should show colors.\n---\n Documentation/config.txt |    5 +++++\n pager.c                  |   16 +++++++++++++++-\n 2 files changed, 20 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 465eb13..96429b6 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -116,6 +116,11 @@ apply.whitespace::\n \tTells `git-apply` how to handle whitespaces, in the same way\n \tas the '--whitespace' option. See gitlink:git-apply[1].\n \n+pager.program::\n+\tUse this program as pager.  git will try this configuration\n+\tvariable first, then the 'PAGER' environment variable and\n+\t\"less\" as fallback.\n+\n diff.color::\n \tWhen true (or `always`), always use colors in patch.\n \tWhen false (or `never`), never.  When set to `auto`, use\ndiff --git a/pager.c b/pager.c\nindex 280f57f..3f753f6 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -5,6 +5,18 @@ #include \"cache.h\"\n  * something different on Windows, for example.\n  */\n \n+static const char *pager = NULL;\n+\n+static int git_pager_config(const char *var, const char *value)\n+{\n+\tif (!strcmp(var, \"pager.program\")) {\n+\t\tif (value)\n+\t\t\tpager = strdup(value);\n+\t\treturn 0;\n+\t}\n+\treturn 0;\n+}\n+\n static void run_pager(const char *pager)\n {\n \texeclp(pager, pager, NULL);\n@@ -15,10 +27,12 @@ void setup_pager(void)\n {\n \tpid_t pid;\n \tint fd[2];\n-\tconst char *pager = getenv(\"PAGER\");\n \n \tif (!isatty(1))\n \t\treturn;\n+\tgit_config(git_pager_config);\n+\tif (!pager)\n+\t\tpager = getenv(\"PAGER\");\n \tif (!pager)\n \t\tpager = \"less\";\n \telse if (!*pager || !strcmp(pager, \"cat\"))\n-- \n1.4.2.rc2.g688a\n"},{"id":"24397","messageId":"7v8xmabo37.fsf@assigned-by-dhcp.cox.net","threadId":"5039","inReplyTo":"E1G6wM1-00040z-Bu@moooo.ath.cx","subject":"Re: [PATCH] pager: config variable pager.program","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-31T00:43:56Z","receivedAt":"2006-07-31T00:43:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I am not enthused about any configuration stored in .git/config\nto override the environment variables.  Files are to store\nreasonable default, and command line flags and environments are\nto override them, but this patch does it the other way around.\n"},{"id":"24431","messageId":"E1G7WfC-000728-9j@moooo.ath.cx","threadId":"5039","inReplyTo":"7v8xmabo37.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] pager: config variable pager.program","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-07-31T12:14:26Z","receivedAt":"2006-07-31T12:14:26Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nJunio C Hamano <junkio@cox.net> wrote:\n> I am not enthused about any configuration stored in .git/config\n> to override the environment variables.  Files are to store\n> reasonable default, and command line flags and environments are\n> to override them, but this patch does it the other way around.\nYou're right, this patch uses $GIT_PAGER.  I don't think pager.program\ndoes make much sense with this (expect someone does not want to export\n$PAGER/$GIT_PAGER), should it be introduced anyway (I don't need\nit)?\n---\n Documentation/git.txt |    3 +++\n pager.c               |    5 ++++-\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 7310a2b..d243883 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -627,6 +627,9 @@ git Diffs\n \n other\n ~~~~~\n+'GIT_PAGER'::\n+\tThis environment variable overrides `$PAGER`.\n+\n 'GIT_TRACE'::\n \tIf this variable is set git will print `trace:` messages on\n \tstderr telling about alias expansion, built-in command\ndiff --git a/pager.c b/pager.c\nindex 280f57f..ab9be5d 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -15,10 +15,13 @@ void setup_pager(void)\n {\n \tpid_t pid;\n \tint fd[2];\n-\tconst char *pager = getenv(\"PAGER\");\n+\tchar *pager;\n \n \tif (!isatty(1))\n \t\treturn;\n+\tpager = getenv(\"GIT_PAGER\");\n+\tif (!pager)\n+\t\tpager = getenv(\"PAGER\");\n \tif (!pager)\n \t\tpager = \"less\";\n \telse if (!*pager || !strcmp(pager, \"cat\"))\n-- \n1.4.2.rc2.g91b7\n"},{"id":"24434","messageId":"Pine.LNX.4.63.0607311454040.29667@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"5039","inReplyTo":"E1G7WfC-000728-9j@moooo.ath.cx","subject":"Re: [PATCH] pager: config variable pager.program","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-07-31T12:56:25Z","receivedAt":"2006-07-31T12:56:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 31 Jul 2006, Matthias Lederhofer wrote:\n\n> Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n\nThe commit message no longer reflects what the patch does ;-)\n\n> -\tconst char *pager = getenv(\"PAGER\");\n> +\tchar *pager;\n\nYou do not need to lose the \"const\" (it means that you cannot access the \nmemory it points to, but you can change the pointer). Also, you could make \na more minimal patch by replacing PAGER by GIT_PAGER here, instead of \nhaving this extra line:\n\n> +\tpager = getenv(\"GIT_PAGER\");\n\nCiao,\nDscho\n"},{"id":"24436","messageId":"E1G7XnQ-0002bA-Fm@moooo.ath.cx","threadId":"5039","inReplyTo":"Pine.LNX.4.63.0607311454040.29667@wbgn013.biozentrum.uni-wuerzburg.de","subject":"[PATCH] pager: environment variable GIT_PAGER to override PAGER","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-07-31T13:27:00Z","receivedAt":"2006-07-31T13:27:00Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nJohannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n> \n> On Mon, 31 Jul 2006, Matthias Lederhofer wrote:\n> \n> > Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n> \n> The commit message no longer reflects what the patch does ;-)\n> \n> > -\tconst char *pager = getenv(\"PAGER\");\n> > +\tchar *pager;\n> \n> You do not need to lose the \"const\" (it means that you cannot access the \n> memory it points to, but you can change the pointer). Also, you could make \n> a more minimal patch by replacing PAGER by GIT_PAGER here, instead of \n> having this extra line:\n> \n> > +\tpager = getenv(\"GIT_PAGER\");\nThanks, I should be more careful when correcting a patch with\n--amend.\n---\n Documentation/git.txt |    3 +++\n pager.c               |    4 +++-\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 7310a2b..d243883 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -627,6 +627,9 @@ git Diffs\n \n other\n ~~~~~\n+'GIT_PAGER'::\n+\tThis environment variable overrides `$PAGER`.\n+\n 'GIT_TRACE'::\n \tIf this variable is set git will print `trace:` messages on\n \tstderr telling about alias expansion, built-in command\ndiff --git a/pager.c b/pager.c\nindex 280f57f..dcb398d 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -15,11 +15,13 @@ void setup_pager(void)\n {\n \tpid_t pid;\n \tint fd[2];\n-\tconst char *pager = getenv(\"PAGER\");\n+\tconst char *pager = getenv(\"GIT_PAGER\");\n \n \tif (!isatty(1))\n \t\treturn;\n \tif (!pager)\n+\t\tpager = getenv(\"PAGER\");\n+\tif (!pager)\n \t\tpager = \"less\";\n \telse if (!*pager || !strcmp(pager, \"cat\"))\n \t\treturn;\n-- \n1.4.2.rc2.g91b7\n"}]}