有没有一种方法来定制git blame的输出? [英] Is there a way to customize the output of git blame?

查看:154
本文介绍了有没有一种方法来定制git blame的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

> git log 有一个很好的 - format 选项来指定输出格式。



但是 git blame 似乎没有等价物,但默认输出 blame code>不太友善。我希望看到更少。



例如,而不是:

  5600cab7 js / sidebar / VehicleGrid.js(Rene Saarsoo 2009-10-08 18:55:24 +0000 127)if(x> y){
b5f1040c js / map / monitoring / VehicleGrid.js (Mihkel Muhkel 2010-05-31 07:20:13 +0000 128)return x;

我想要:

<$ p $ x $ b> 5600cab7 Rene Saarsoo(1年前)127:if(x> y){
b5f1040c Mihkel Muhkel(5个月前)128:return x;

我想我可以编写脚本来解析 git blame的输出--porcelain ,但是考虑到 blame 这个可怕的默认输出,我觉得那里的某个人肯定已经做了些什么。



任何想法?或者实现这样的脚本的任何提示?



编辑:通过编写 small script

解决方案

<您可以使用其他输出格式: git annotate git blame -c



您可以使用 - date =< format> 选项(或 blame.date config变量),其中< format> relative,local,default,iso,rfc,short 之一。请参阅 git-blame git-log 获取详细信息。


git log has a nice --format option to specify how the output should be formatted.

But git blame doesn't seem to have an equivalent, although default output of blame is not quite human-friendly. I would like to see much less.

For example, instead of:

5600cab7 js/sidebar/VehicleGrid.js        (Rene Saarsoo    2009-10-08 18:55:24 +0000 127)    if (x > y) {
b5f1040c js/map/monitoring/VehicleGrid.js (Mihkel Muhkel   2010-05-31 07:20:13 +0000 128)        return x;

I would like to have:

5600cab7 Rene Saarsoo (1 year ago)     127:    if (x > y) {
b5f1040c Mihkel Muhkel (5 months ago)  128:        return x;

I figure that I could write a script to parse the output of git blame --porcelain but given the horrendous default output of blame I feel that somebody out there must have already done something about it.

Any ideas? Or any tips for implementing such a script?

Edit: Solved it by writing small script.

解决方案

You can use alternate output format: git annotate or git blame -c.

You can change formatting of dates with --date=<format> option (or blame.date config variable), where <format> is one of relative, local, default, iso, rfc, short. See git-blame and git-log manpages for details.

这篇关于有没有一种方法来定制git blame的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆