{"thread":{"id":"35932","subject":"Cygwin + git log = no pager!","startedAt":"2014-02-22T05:18:44Z","lastAt":"2014-02-27T07:36:19Z","messageCount":11,"participants":["Robert Dailey","Chris Packham","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"235163","messageId":"CAHd499BT1Q308+q0NB9Dpx=ncQZwRn0tg=q_PE8RutaVqH+xQQ@mail.gmail.com","threadId":"35932","inReplyTo":null,"subject":"Cygwin + git log = no pager!","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-02-22T05:18:44Z","receivedAt":"2014-02-22T05:18:44Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"So it seems that the pager doesn't work by default when running `git\nlog` from Cygwin like it does in msysgit for Windows.\n\nI know I can pipe to `less` but that requires the additional typing\nobviously. Does anyone know how I can get the pager to work in Cygwin\nfor git log, reflog, and other commands like it does in msysgit?\n\nThanks in advance.\n"},{"id":"235165","messageId":"53085434.4060106@gmail.com","threadId":"35932","inReplyTo":"CAHd499BT1Q308+q0NB9Dpx=ncQZwRn0tg=q_PE8RutaVqH+xQQ@mail.gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2014-02-22T07:39:32Z","receivedAt":"2014-02-22T07:39:32Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On 22/02/14 18:18, Robert Dailey wrote:\n> So it seems that the pager doesn't work by default when running `git\n> log` from Cygwin like it does in msysgit for Windows.\n> \n> I know I can pipe to `less` but that requires the additional typing\n> obviously. Does anyone know how I can get the pager to work in Cygwin\n> for git log, reflog, and other commands like it does in msysgit?\n> \n> Thanks in advance.\n\nAdd GIT_PAGER=less to your environment. I don't know if you were using\nthe cygwin packaged git or building from source but I'm surprised the\npager is not set by default as you actually have to define the use of\nsomething other than less.\n"},{"id":"235207","messageId":"CAHd499AbsUwmA0HWu31jW2n8eUNnRtU7URKPfBU7EhU6-F48zg@mail.gmail.com","threadId":"35932","inReplyTo":"53085434.4060106@gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-02-23T20:33:01Z","receivedAt":"2014-02-23T20:33:01Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Sat, Feb 22, 2014 at 1:39 AM, Chris Packham <judge.packham@gmail.com> wrote:\n> On 22/02/14 18:18, Robert Dailey wrote:\n>> So it seems that the pager doesn't work by default when running `git\n>> log` from Cygwin like it does in msysgit for Windows.\n>>\n>> I know I can pipe to `less` but that requires the additional typing\n>> obviously. Does anyone know how I can get the pager to work in Cygwin\n>> for git log, reflog, and other commands like it does in msysgit?\n>>\n>> Thanks in advance.\n>\n> Add GIT_PAGER=less to your environment. I don't know if you were using\n> the cygwin packaged git or building from source but I'm surprised the\n> pager is not set by default as you actually have to define the use of\n> something other than less.\n\nThanks for the response. I did set this environment variable in my\n.bashrc like so:\n\nexport GIT_PAGER=less\n\nHowever after I do a 'git log' it is just spitting it out all at once\nand not entering the pager.\n"},{"id":"235226","messageId":"530AFAFD.2060504@gmail.com","threadId":"35932","inReplyTo":"CAHd499AbsUwmA0HWu31jW2n8eUNnRtU7URKPfBU7EhU6-F48zg@mail.gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2014-02-24T07:55:41Z","receivedAt":"2014-02-24T07:55:41Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On 24/02/14 09:33, Robert Dailey wrote:\n> On Sat, Feb 22, 2014 at 1:39 AM, Chris Packham <judge.packham@gmail.com> wrote:\n>> On 22/02/14 18:18, Robert Dailey wrote:\n>>> So it seems that the pager doesn't work by default when running `git\n>>> log` from Cygwin like it does in msysgit for Windows.\n>>>\n>>> I know I can pipe to `less` but that requires the additional typing\n>>> obviously. Does anyone know how I can get the pager to work in Cygwin\n>>> for git log, reflog, and other commands like it does in msysgit?\n>>>\n>>> Thanks in advance.\n>>\n>> Add GIT_PAGER=less to your environment. I don't know if you were using\n>> the cygwin packaged git or building from source but I'm surprised the\n>> pager is not set by default as you actually have to define the use of\n>> something other than less.\n> \n> Thanks for the response. I did set this environment variable in my\n> .bashrc like so:\n> \n> export GIT_PAGER=less\n> \n> However after I do a 'git log' it is just spitting it out all at once\n> and not entering the pager.\n> \n\nUm OK that was the obvious thing to try. There is also the config\nvariable core.pager but GIT_PAGER should take precedence.\n\nCould something be setting the environment variable LESS? Reading the\ngit-config man page for core.pager git wants to set LESS to FRSX but if\nit is already set git takes that as an indication that you don't want to\nset LESS automatically.\n\nIf neither of those help you probably want to let us know your cygwin\nversion as well as your git version and how you installed git (i.e.\nbuilt from source or installed via cygwin).\n"},{"id":"235234","messageId":"20140224090618.GB10698@sigill.intra.peff.net","threadId":"35932","inReplyTo":"530AFAFD.2060504@gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-02-24T09:06:18Z","receivedAt":"2014-02-24T09:06:18Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 24, 2014 at 08:55:41PM +1300, Chris Packham wrote:\n\n> > Thanks for the response. I did set this environment variable in my\n> > .bashrc like so:\n> > \n> > export GIT_PAGER=less\n> > \n> > However after I do a 'git log' it is just spitting it out all at once\n> > and not entering the pager.\n> > \n> \n> Um OK that was the obvious thing to try. There is also the config\n> variable core.pager but GIT_PAGER should take precedence.\n\nPresumably we are actually running what's in GIT_PAGER, but we can\ndouble-check with:\n\n  GIT_PAGER='echo custom pager' git log\n\nYou can also try:\n\n  GIT_TRACE=1 git log\n\nwhich should describe the pager being run.\n\n> Could something be setting the environment variable LESS? Reading the\n> git-config man page for core.pager git wants to set LESS to FRSX but if\n> it is already set git takes that as an indication that you don't want to\n> set LESS automatically.\n\nWe can also double-check the LESS setting in the executed pager:\n\n  GIT_PAGER='echo LESS=$LESS' git log\n\nIf we are running less, and it is using FRSX, I'd suspect some kind of\nterminal weirdness with less itself. With \"-F\", less will quit if the\nwhole output can be displayed; it's possible it thinks the screen is\nbigger than it is.\n\nTrying:\n\n  GIT_PAGER=less LESS=RSX git log\n\nmight help.\n\n-Peff\n"},{"id":"235283","messageId":"CAHd499BDBgaAZFkoc=S9i9hG=NifAmqhaW86fqgkzjShZd07ww@mail.gmail.com","threadId":"35932","inReplyTo":"20140224090618.GB10698@sigill.intra.peff.net","subject":"Re: Cygwin + git log = no pager!","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-02-24T19:34:34Z","receivedAt":"2014-02-24T19:34:34Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Mon, Feb 24, 2014 at 3:06 AM, Jeff King <peff@peff.net> wrote:\n> On Mon, Feb 24, 2014 at 08:55:41PM +1300, Chris Packham wrote:\n>\n>> > Thanks for the response. I did set this environment variable in my\n>> > .bashrc like so:\n>> >\n>> > export GIT_PAGER=less\n>> >\n>> > However after I do a 'git log' it is just spitting it out all at once\n>> > and not entering the pager.\n>> >\n>>\n>> Um OK that was the obvious thing to try. There is also the config\n>> variable core.pager but GIT_PAGER should take precedence.\n>\n> Presumably we are actually running what's in GIT_PAGER, but we can\n> double-check with:\n>\n>   GIT_PAGER='echo custom pager' git log\n>\n> You can also try:\n>\n>   GIT_TRACE=1 git log\n>\n> which should describe the pager being run.\n>\n>> Could something be setting the environment variable LESS? Reading the\n>> git-config man page for core.pager git wants to set LESS to FRSX but if\n>> it is already set git takes that as an indication that you don't want to\n>> set LESS automatically.\n>\n> We can also double-check the LESS setting in the executed pager:\n>\n>   GIT_PAGER='echo LESS=$LESS' git log\n>\n> If we are running less, and it is using FRSX, I'd suspect some kind of\n> terminal weirdness with less itself. With \"-F\", less will quit if the\n> whole output can be displayed; it's possible it thinks the screen is\n> bigger than it is.\n>\n> Trying:\n>\n>   GIT_PAGER=less LESS=RSX git log\n>\n> might help.\n>\n> -Peff\n\nSo I set GIT_PAGER to 'echo custom pager' as you instructed, and I\nnoticed that wasn't being printed when I ran my git log alias. So what\nI did after that was set GIT_TRACE=1 and here is the output I see\nbefore my logs start printing:\n\n$ git lg\ntrace: exec: 'git-lg'\ntrace: run_command: 'git-lg'\ntrace: run_command: 'git lg1'\ntrace: exec: 'git-lg1'\ntrace: run_command: 'git-lg1'\ntrace: run_command: 'git short-log-base --branches --remotes --tags'\ntrace: exec: 'git-short-log-base' '--branches' '--remotes' '--tags'\ntrace: run_command: 'git-short-log-base' '--branches' '--remotes' '--tags'\ntrace: alias expansion: short-log-base => 'log' '--graph'\n'--abbrev-commit' '--decorate' '--date=relative'\n'--format=format:%C(bold blue)%h%C(reset)%x09%C(bold\ngreen)(%ar)%C(reset)%C(bold yellow)%d%C(reset) %C(dim\nwhite)%an%C(reset) - %C(white)%s%C(reset)'\ntrace: built-in: git 'log' '--graph' '--abbrev-commit' '--decorate'\n'--date=relative' '--format=format:%C(bold blue)%h%C(reset)%x09%C(bold\ngreen)(%ar)%C(reset)%C(bold yellow)%d%C(reset) %C(dim\nwhite)%an%C(reset) - %C(white)%s%C(reset)' '--branches' '--remotes'\n'--tags'\n\nDoes using an alias have something to do with this?\n"},{"id":"235357","messageId":"20140226092610.GB32537@sigill.intra.peff.net","threadId":"35932","inReplyTo":"CAHd499BDBgaAZFkoc=S9i9hG=NifAmqhaW86fqgkzjShZd07ww@mail.gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-02-26T09:26:10Z","receivedAt":"2014-02-26T09:26:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 24, 2014 at 01:34:34PM -0600, Robert Dailey wrote:\n\n> So I set GIT_PAGER to 'echo custom pager' as you instructed, and I\n> noticed that wasn't being printed when I ran my git log alias. So what\n> I did after that was set GIT_TRACE=1 and here is the output I see\n> before my logs start printing:\n> [...]\n> Does using an alias have something to do with this?\n\nThe aliases shouldn't matter (and I constructed a scenario like the one\nyou showed and it starts the pager for me on Linux). It's more like git\nis deciding not to show a pager at all (e.g., it thinks your stdout is\nnot a tty). Does running:\n\n  git log\n\nnot use a pager, but:\n\n  git -p log\n\ndoes? In that case, I think that your stdout is not a tty for some\nreason.\n\nIf that is the case, try:\n\n  git -p lg\n\nThat _should_ turn on the pager, but I think it does not due to a bug\nwith setup_pager and aliases. Something like the patch below would make\nit work (but if you are having to use \"-p\" manually, there is something\nto fix in your cygwin environment, which does not think you are on a\nterminal).\n\n-Peff\n\n---\ndiff --git a/cache.h b/cache.h\nindex dc040fb..ecc410e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1238,6 +1238,7 @@ static inline ssize_t write_str_in_full(int fd, const char *str)\n \n /* pager.c */\n extern void setup_pager(void);\n+extern void setup_pager_with_options(int stdout_is_tty);\n extern const char *pager_program;\n extern int pager_in_use(void);\n extern int pager_use_color;\ndiff --git a/git.c b/git.c\nindex 7cf2953..ad54891 100644\n--- a/git.c\n+++ b/git.c\n@@ -27,7 +27,7 @@ static void commit_pager_choice(void) {\n \t\tsetenv(\"GIT_PAGER\", \"cat\", 1);\n \t\tbreak;\n \tcase 1:\n-\t\tsetup_pager();\n+\t\tsetup_pager_with_options(1);\n \t\tbreak;\n \tdefault:\n \t\tbreak;\ndiff --git a/pager.c b/pager.c\nindex 0cc75a8..b28125d 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -62,7 +62,12 @@ const char *git_pager(int stdout_is_tty)\n \n void setup_pager(void)\n {\n-\tconst char *pager = git_pager(isatty(1));\n+\tsetup_pager_with_options(isatty(1));\n+}\n+\n+void setup_pager_with_options(int stdout_is_tty)\n+{\n+\tconst char *pager = git_pager(stdout_is_tty);\n \n \tif (!pager || pager_in_use())\n \t\treturn;\n"},{"id":"235384","messageId":"CAHd499Co9Amdf_gWnY81dkRa2uDTH0fVM8HSb99VHhrb1AAKhA@mail.gmail.com","threadId":"35932","inReplyTo":"20140226092610.GB32537@sigill.intra.peff.net","subject":"Re: Cygwin + git log = no pager!","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-02-26T15:54:39Z","receivedAt":"2014-02-26T15:54:39Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Wed, Feb 26, 2014 at 3:26 AM, Jeff King <peff@peff.net> wrote:\n> On Mon, Feb 24, 2014 at 01:34:34PM -0600, Robert Dailey wrote:\n>\n>> So I set GIT_PAGER to 'echo custom pager' as you instructed, and I\n>> noticed that wasn't being printed when I ran my git log alias. So what\n>> I did after that was set GIT_TRACE=1 and here is the output I see\n>> before my logs start printing:\n>> [...]\n>> Does using an alias have something to do with this?\n>\n> The aliases shouldn't matter (and I constructed a scenario like the one\n> you showed and it starts the pager for me on Linux). It's more like git\n> is deciding not to show a pager at all (e.g., it thinks your stdout is\n> not a tty). Does running:\n>\n>   git log\n>\n> not use a pager, but:\n>\n>   git -p log\n>\n> does? In that case, I think that your stdout is not a tty for some\n> reason.\n>\n> If that is the case, try:\n>\n>   git -p lg\n>\n> That _should_ turn on the pager, but I think it does not due to a bug\n> with setup_pager and aliases. Something like the patch below would make\n> it work (but if you are having to use \"-p\" manually, there is something\n> to fix in your cygwin environment, which does not think you are on a\n> terminal).\n>\n> -Peff\n>\n> <snip>\n\nI have tried `git -p log` and `git log` and neither use the pager.\nShould I apply the provided patch to the Git for Windows master\nbranch? Also I'm not sure if there is a convenient way to apply a\npatch via email, so should I copy & paste it to a file & then apply\nthe file?\n\nI'm assuming your patch depended on -p working but not without it, so\nI'm not sure if you still think the patch might help. Let me know!\nThanks for your help.\n"},{"id":"235387","messageId":"CAHd499DnDNu5N+Jiva_xfc2O5Gxxb=cogYN2YHtrSJDFEjtO-A@mail.gmail.com","threadId":"35932","inReplyTo":"CAHd499Co9Amdf_gWnY81dkRa2uDTH0fVM8HSb99VHhrb1AAKhA@mail.gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2014-02-26T16:41:18Z","receivedAt":"2014-02-26T16:41:18Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"Copying the patch from the email text results in corrupted patch,\nsomething isn't quite right with it so it won't let me apply it.\n\nCan you attach it as an actual file so I can try again? Thanks.\n"},{"id":"235437","messageId":"20140227062107.GA21000@sigill.intra.peff.net","threadId":"35932","inReplyTo":"CAHd499Co9Amdf_gWnY81dkRa2uDTH0fVM8HSb99VHhrb1AAKhA@mail.gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-02-27T06:21:07Z","receivedAt":"2014-02-27T06:21:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 26, 2014 at 09:54:39AM -0600, Robert Dailey wrote:\n\n> > That _should_ turn on the pager, but I think it does not due to a bug\n> > with setup_pager and aliases. Something like the patch below would make\n> > it work (but if you are having to use \"-p\" manually, there is something\n> > to fix in your cygwin environment, which does not think you are on a\n> > terminal).\n> \n> I have tried `git -p log` and `git log` and neither use the pager.\n\nI thought Git's behavior was a bug, but it seems to be the intended\neffect that \"-p\" is just \"cancel --no-pager\" and not \"turn on the pager,\neven if stdout is not a tty\".\n\nSo the patch I sent is not something we would want to apply, but it\nmight help debugging your situation (if my hunch is right that isatty()\nis returning false, then \"git -p log\" would work with it). Or perhaps a\nsimpler way to check that is just:\n\ndiff --git a/pager.c b/pager.c\nindex 0cc75a8..6d870ac 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -41,8 +41,10 @@ const char *git_pager(int stdout_is_tty)\n {\n \tconst char *pager;\n \n-\tif (!stdout_is_tty)\n+\tif (!stdout_is_tty) {\n+\t\twarning(\"disabling pager, stdout is not a tty\");\n \t\treturn NULL;\n+\t}\n \n \tpager = getenv(\"GIT_PAGER\");\n \tif (!pager) {\n\n> Should I apply the provided patch to the Git for Windows master\n> branch? Also I'm not sure if there is a convenient way to apply a\n> patch via email, so should I copy & paste it to a file & then apply\n> the file?\n\nThe usual way is to save the patch to an mbox, then use \"git am\" to\napply it. Most Unix-y mail clients have mbox support, but I suspect many\nWindows ones do not.\n\n-Peff\n"},{"id":"235440","messageId":"530EEAF3.7080006@gmail.com","threadId":"35932","inReplyTo":"CAHd499Co9Amdf_gWnY81dkRa2uDTH0fVM8HSb99VHhrb1AAKhA@mail.gmail.com","subject":"Re: Cygwin + git log = no pager!","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2014-02-27T07:36:19Z","receivedAt":"2014-02-27T07:36:19Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On 27/02/14 04:54, Robert Dailey wrote:\n> On Wed, Feb 26, 2014 at 3:26 AM, Jeff King <peff@peff.net> wrote:\n>> On Mon, Feb 24, 2014 at 01:34:34PM -0600, Robert Dailey wrote:\n>>\n>>> So I set GIT_PAGER to 'echo custom pager' as you instructed, and I\n>>> noticed that wasn't being printed when I ran my git log alias. So what\n>>> I did after that was set GIT_TRACE=1 and here is the output I see\n>>> before my logs start printing:\n>>> [...]\n>>> Does using an alias have something to do with this?\n>>\n>> The aliases shouldn't matter (and I constructed a scenario like the one\n>> you showed and it starts the pager for me on Linux). It's more like git\n>> is deciding not to show a pager at all (e.g., it thinks your stdout is\n>> not a tty). Does running:\n>>\n>>   git log\n>>\n>> not use a pager, but:\n>>\n>>   git -p log\n>>\n>> does? In that case, I think that your stdout is not a tty for some\n>> reason.\n>>\n>> If that is the case, try:\n>>\n>>   git -p lg\n>>\n>> That _should_ turn on the pager, but I think it does not due to a bug\n>> with setup_pager and aliases. Something like the patch below would make\n>> it work (but if you are having to use \"-p\" manually, there is something\n>> to fix in your cygwin environment, which does not think you are on a\n>> terminal).\n>>\n>> -Peff\n>>\n>> <snip>\n> \n> I have tried `git -p log` and `git log` and neither use the pager.\n> Should I apply the provided patch to the Git for Windows master\n> branch? \n\nThat may be relevant (refer to my previous questions about what version\nyou're using and how you got it). Are you using git via cygwin or \"Git\nFor Windows\"? I believe the two are different (*caveat* I haven't used\nwindows in years and I've never used Git For Windows, I've added the\nmsysgit list to this email thread).\n\nIf you're executing the Git For Windows installation from the cygwin\nbash shell that's probably why the terminal detection is getting\nconfused. If you've installed Git For Windows you should use the Git\nBASH shell that comes with it. If you want to use git with other bits of\ncygwin I suggest uninstalling Git For Windows and installing the git\npackage via the cygwin setup tool.\n\n> Also I'm not sure if there is a convenient way to apply a\n> patch via email, so should I copy & paste it to a file & then apply\n> the file?\n\nSave the email file in your email client. Most support saving as plain\ntext or RFC822 format. Then 'git am <filename>' should do the trick.\n\n> I'm assuming your patch depended on -p working but not without it, so\n> I'm not sure if you still think the patch might help. Let me know!\n> Thanks for your help.\n> \n"}]}