msysGit: Why does git log output blank lines?

2019-07-03 13:37发布

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?

2条回答
等我变得足够好
2楼-- · 2019-07-03 14:34

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
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-03 14:41

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.)

查看更多
登录 后发表回答