{"thread":{"id":"6846","subject":"[BUG] git -p status does not use colors","startedAt":"2007-02-16T15:19:25Z","lastAt":"2007-02-16T19:43:30Z","messageCount":7,"participants":["Matthias Lederhofer","Jeff King","Johannes Schindelin","Simon 'corecode' Schubert"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"34800","messageId":"20070216151925.GA28974@moooo.ath.cx","threadId":"6846","inReplyTo":null,"subject":"[BUG] git -p status does not use colors","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-02-16T15:19:25Z","receivedAt":"2007-02-16T15:19:25Z","isPatch":false,"sender":{"key":"matled@gmx.net","avatar":null},"body":"git -p status starts the pager, then runs git-commit.sh (named\ngit-status) which in turn runs git-runstatus.  I guess the problem is\nthat git-runstatus cannot check that the pager was started and just\nknows that stdout is no terminal.  Has anyone an idea how to fix\nthis?\n"},{"id":"34804","messageId":"20070216155658.GB7183@coredump.intra.peff.net","threadId":"6846","inReplyTo":"20070216151925.GA28974@moooo.ath.cx","subject":"Re: [BUG] git -p status does not use colors","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-02-16T15:56:58Z","receivedAt":"2007-02-16T15:56:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Feb 16, 2007 at 04:19:25PM +0100, Matthias Lederhofer wrote:\n\n> git -p status starts the pager, then runs git-commit.sh (named\n> git-status) which in turn runs git-runstatus.  I guess the problem is\n> that git-runstatus cannot check that the pager was started and just\n> knows that stdout is no terminal.  Has anyone an idea how to fix\n> this?\n\nYour analysis looks right to me.  I think you would need to set\nGIT_PAGER_IN_USE in the environment whenever you turn on the pager in\nthe git wrapper, and then set git's internal pager_in_use variable based\non that.\n\n-Peff\n"},{"id":"34817","messageId":"20070216182231.GA31676@moooo.ath.cx","threadId":"6846","inReplyTo":"20070216155658.GB7183@coredump.intra.peff.net","subject":"[PATCH] pager: use an environment variable for pager_in_use","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-02-16T18:22:31Z","receivedAt":"2007-02-16T18:22:31Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"When running a shell script the value of pager_in_use is\nlost for later processes.  Therefore pager_in_use is\nreplaced by the environment variable GIT_PAGER_IN_USE.\n\nSigned-off-by: Matthias Lederhofer <matled@gmx.net>\n---\n\nJeff King <peff@peff.net> wrote:\n> Your analysis looks right to me.  I think you would need to set\n> GIT_PAGER_IN_USE in the environment whenever you turn on the pager in\n> the git wrapper, and then set git's internal pager_in_use variable based\n> on that.\nThis patch replaces pager_in_use because pager_in_use was only used at\ntwo places (one sets it, the other reads it).\n---\n cache.h       |    1 -\n color.c       |    2 +-\n environment.c |    1 -\n pager.c       |    3 ++-\n 4 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex c62b0b0..aeaac9f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -445,7 +445,6 @@ extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char\n \n /* pager.c */\n extern void setup_pager(void);\n-extern int pager_in_use;\n extern int pager_use_color;\n \n /* base85 */\ndiff --git a/color.c b/color.c\nindex 09d82ee..50e073a 100644\n--- a/color.c\n+++ b/color.c\n@@ -121,7 +121,7 @@ int git_config_colorbool(const char *var, const char *value)\n \tif (!value)\n \t\treturn 1;\n \tif (!strcasecmp(value, \"auto\")) {\n-\t\tif (isatty(1) || (pager_in_use && pager_use_color)) {\n+\t\tif (isatty(1) || (getenv(\"GIT_PAGER_IN_USE\") && pager_use_color)) {\n \t\t\tchar *term = getenv(\"TERM\");\n \t\t\tif (term && strcmp(term, \"dumb\"))\n \t\t\t\treturn 1;\ndiff --git a/environment.c b/environment.c\nindex 54c22f8..5b477c3 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -26,7 +26,6 @@ const char *apply_default_whitespace;\n int zlib_compression_level = Z_DEFAULT_COMPRESSION;\n size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;\n size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;\n-int pager_in_use;\n int pager_use_color = 1;\n \n static const char *git_dir;\ndiff --git a/pager.c b/pager.c\nindex 5f280ab..f59c94f 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -38,7 +38,8 @@ void setup_pager(void)\n \telse if (!*pager || !strcmp(pager, \"cat\"))\n \t\treturn;\n \n-\tpager_in_use = 1; /* means we are emitting to terminal */\n+\t/* means we are emitting to terminal */\n+\tsetenv(\"GIT_PAGER_IN_USE\", \"1\", 0);\n \n \tif (pipe(fd) < 0)\n \t\treturn;\n-- \n1.5.0\n"},{"id":"34819","messageId":"Pine.LNX.4.63.0702161934230.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6846","inReplyTo":"20070216182231.GA31676@moooo.ath.cx","subject":"Re: [PATCH] pager: use an environment variable for pager_in_use","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-16T18:35:37Z","receivedAt":"2007-02-16T18:35:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 16 Feb 2007, Matthias Lederhofer wrote:\n\n> When running a shell script the value of pager_in_use is\n> lost for later processes.  Therefore pager_in_use is\n> replaced by the environment variable GIT_PAGER_IN_USE.\n\nAm I the only one who finds it ugly to set an environment variable for use \nin the same program?\n\n> -int pager_in_use;\n\nHow about\n\n+int pager_in_use = getenv(\"GIT_PAGER_IN_USE\");\n\n???\n\nCiao,\nDscho\n"},{"id":"34820","messageId":"20070216185653.GA10308@moooo.ath.cx","threadId":"6846","inReplyTo":"Pine.LNX.4.63.0702161934230.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] pager: use an environment variable for pager_in_use","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-02-16T18:56:53Z","receivedAt":"2007-02-16T18:56:53Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> +int pager_in_use = getenv(\"GIT_PAGER_IN_USE\");\ntest.c:3: error: initializer element is not constant\n\nSo you could only add this at another place where pager_in_use is not yet\nused (e.g. start of main or some other initialization method).\nI did not want to put it at the beginning of main or another function.\nAfter adding GIT_PAGER_IN_USE I thought it would make sense to remove\npager_in_use because there were only two parts of code using\npager_in_use:\n> pager_in_use = 1;\n> setenv(..);\nand\n> pager_in_use || getenv(..)\n"},{"id":"34821","messageId":"Pine.LNX.4.63.0702162004590.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6846","inReplyTo":"20070216185653.GA10308@moooo.ath.cx","subject":"Re: [PATCH] pager: use an environment variable for pager_in_use","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-16T19:06:32Z","receivedAt":"2007-02-16T19:06:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 16 Feb 2007, Matthias Lederhofer wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > +int pager_in_use = getenv(\"GIT_PAGER_IN_USE\");\n> test.c:3: error: initializer element is not constant\n\nSorry.\n\nStill, it feels wrong to use two system calls when you need none.\n\nHow about working on making status and commit a builtin instead? This \nwould not only solve your issue, but portability issues as well.\n\nCiao,\nDscho\n"},{"id":"34823","messageId":"45D60962.6010605@fs.ei.tum.de","threadId":"6846","inReplyTo":"Pine.LNX.4.63.0702162004590.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] pager: use an environment variable for pager_in_use","fromName":"Simon 'corecode' Schubert","fromEmail":"corecode@fs.ei.tum.de","sentAt":"2007-02-16T19:43:30Z","receivedAt":"2007-02-16T19:43:30Z","isPatch":true,"sender":{"key":"corecode@fs.ei.tum.de","avatar":"https://gravatar.com/avatar/eff9dbf0cdac0d1e6a6cd7ed0e50763edcb376b493b5253a35ff167918ad79e1?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>>> +int pager_in_use = getenv(\"GIT_PAGER_IN_USE\");\n>> test.c:3: error: initializer element is not constant\n> Sorry.\n> \n> Still, it feels wrong to use two system calls when you need none.\n\ngetenv() is usually no system call, but processed in userland.\n\nHowever, I also always get the feeling that using environment variables within one process to communicate state seems wrong, but many old unix tools do it this way.\n\ncheers\n  simon\n\n-- \nServe - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /\"\\\nWork - Mac      +++  space for low €€€ NOW!1  +++      Campaign     \\ /\nParty Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \\\nDude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \\\n\n"}]}