为什么一些 git 提交隐藏在 cygwin shell 内?
我的一位同事最近注意到正常的 git log 命令和以下别名之间存在差异:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
经过一番研究,我们发现它可能与 cygwin bash 有关。
以下是我们的发现:
git log --graph
所有提交可见
git log --oneline
缺少一些提交...好吧!让我们通过将输出重定向到文本文件来准备错误报告:
git log --oneline >测试.txt
唉,所有提交都在
test.txt
中可见?!? 让我们通过分解别名来进一步研究。删除颜色代码:git log --graph --pretty=format:'%h - %d %s (%cr) <%an>'
缺少一些提交。所以它一定是变量之一...
[...稍后会发生一些错误...]
git log --graph --pretty=format:'%h - %d %s (%cr )'
所有提交可见
git log --graph --pretty=format:'%h - %d %s <%an>'
所有提交可见
它似乎在之后中断某些变量的组合。在这种情况下 (%cr) <%an>
我还在 Linux 上尝试了相同的存储库,它按预期工作(即所有提交都显示在日志中)。
我们想知道为什么会发生这种情况。
One of my colleagues recently noticed a discrepancy between the normal git log
command, and and the following alias:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
After a bit of poking, we found out that it may be related to the cygwin bash.
Here are our findings:
git log --graph
all commits visible
git log --oneline
some commits missing... okay! let's prepare an error report by redirecting the output to a text file:
git log --oneline > test.txt
Alas, all commits are visible in
test.txt
?!?
Let's investigate further by taking apart the alias. Removing color codes:git log --graph --pretty=format:'%h - %d %s (%cr) <%an>'
some commits missing. So it must be one of the variables...
[... some frobnications later ...]
git log --graph --pretty=format:'%h - %d %s (%cr)'
all commits visible
git log --graph --pretty=format:'%h - %d %s <%an>'
all commits visible
It seems to break after certain combinations of variables. In this case (%cr) <%an>
I also tried the same repository on linux and on there, it works as expected (i.e. all commits are shown in the log).
We would like to know why this is happening.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这些方法来更接近原因:
$PAGER
并查看它如何影响错误。$PAGER
为less
,则从less
(S) 内部保存日志,和/或 -R 打开/关闭 ANSI 转义处理(如果打开了颜色)。$LC_ALL
、$LANG
等。尝试LANG=C git log等
Try these to get closer to the cause:
$PAGER
and see how that affects the bug.$PAGER
isless
, save the log from insideless
(S), and/or -R to turn on /off processing of ANSI escapes, if you have color on.$LC_ALL
,$LANG
etc. tryLANG=C git log
etc