views:

169

answers:

2

It appears to insert less blank lines the closer I type the command to the bottom of the terminal window. If I type it at the top of the terminal window, it inserts nearly a full window height of blank lines; if I type it at the very bottom, no blank lines are inserted.

It seems like the pager program is pushing output to the bottom of the terminal window, but I want the output to be right below my command or at the top, like in Linux git.

I can get expected behavior by using git --no-pager log, but what if I want to use a pager?

+1  A: 

That's the behavior of the pager. By default, Git output is piped through a paper that behaves the way you describe. (You could try to find another pager that acts like you want, and use that as your pager instead.)

mipadi
This doesn't seem to be the case in Linux - for example, I can use `git log --grep=...` with a pattern that matches only one commit, and it appears to invoke the pager (I get the (END) and have to press q) but doesn't consume the whole terminal. Not actually sure how that works, to be honest.
Jefromi
+1  A: 

Just to add a few elements:

msysgit was already discussing alternative consoles in issue 29 back a year ago (mid-2009: mintty, but for cygwin only, a capturing window I/O).

The issue 369 mentions the option "git config pager.log off" to disable paging for "log", which can come in handy for certain scenario similar to the one the OP mentions.

A similar problem is being discussed right now (May 2010) in issue 484 (by none other than SO user kusma as he points out in the comments ;) )

I can reproduce this, but I don't think it's an issue with git itself. It's the pager; less on msys has some serious issues. Some experiments with less shows that the culprit seems to be the -R flag:

$ git --no-pager diff --color=always HEAD~1 TestSegmentedText.java | less -R
VonC
Thanks for quoting me ;)Anyway, yes. It's definitely worth checking out if less -R is the culprit in this case also. If so, we expect to have a fix in 'devel' soon.
kusma
@kusma: Hi Kusma! I didn't realize you were also a SO user :) I have edited the answer to add the proper attribution.
VonC