2012-10-29 76 views
3

如何将我的提交日志转储为仅显示具有给定名称空间的备注的日志?过滤git日志以仅显示提交提示

提交无笔记,或Notes不属于给定的命名空间应该被过滤掉

在文本转储我不想只是说明,还提交信息。

我玩过:show refs/notes /,我相信解决方案可能在那里,而不是“git log”。不过,我仍然遇到一些问题,以找到正确的命令,并显示所有提交。

+0

你有没有尝试过'git notes list'? –

回答

4

git notes会给你每个音符的id和它适用于什么对象。所以第二列就是你想要的。那最后一列使用cut,并将其传递到git show

$ git notes 
f5ac8874676de3029ffc8c31935644ff7c4deae0 07ca160c58cf259fe8bb5e87b9d9a7cbf8845f87 
62ecfc95355587d6d1f779fcaca6e4f53d088ccc eb6c60b9dcb56219d9d882759c0bf928f6d6c3fa 

抢。

$ [ "$(git notes)" = "" ] || git notes | cut -d' ' -f2 | xargs git show 

要选择一个特定的命名空间,添加--ref=namespacegit notes

$ [ "$(git notes --ref=namespace)" = "" ] || git notes --ref=namespace | cut -d' ' -f2 | xargs git show 

最初的测试,可以防止一个小问题:git show将显示当前结帐如果没有参数传递。 所以如果没有笔记,你会得到误导性的输出。初始测试不是 是一个问题:如果测试失败,即没有笔记,那么git show将不会被调用。

+0

谢谢!它会使一个非常好的别名 – SystematicFrank

+3

'-r'标志(或'--no-run-if-empty')将修复GNU'xargs'的“轻微问题”。 –

0

您可以将测试添加到Schwern拥有答案:

[ "$(git notes)" = "" ] || git notes | cut -d' ' -f2 | xargs git show 

或拿起一个特定的命名空间:

[ "$(git notes --ref=namespace)" = "" ] || git notes --ref=namespace | cut -d' ' -f2 | xargs git show 

然后,如果最初的测试[...]失败,即如果没有笔记,git show不会被调用。