如何在git log中显示SVN修订号? [英] How do I show the SVN revision number in git log?
问题描述
我正在自定义我的git日志,全部在1行。具体而言,我添加了以下别名:
lg = log --graph --pretty = format:'%Cred%h% Creset - %C(黄色)%an%Creset - %s%Cgreen(%cr)%Creset'--abbrev-commit --date =相对
因此,当我运行 git lg
时,我看到以下内容:
* 41a49ad - zain - 提交1条消息(3小时前)
* 6087812 - zain - 提交2条消息(5小时前)
* 74842dd - zain - 在此处提交3条消息(6小时前)
但是,我想添加SVN修订版那么它看起来像这样:
* 41a49ad - r1593 - zain - 提交1条消息(3小时前)
正常的 git log
SVN修订号,所以我相信这一定是可能的。我该怎么做呢? 当你说正常 git log
SVN修订版号,我想你的意思是你正在处理一个由 git svn
处理的存储库,默认情况下在同步提交的最后添加了一行:
git-svn-id:svn:// path / to / repository @ ######< domain>
现在,就git而言,这只是随机文本,所以我怀疑你可以找到一个%
访问器,从那里读取 ######
修订版号。
在这一点上,您最好的选择是仅仅解析
git log -z | tr'\\\
\0''\\\
'| sed's / \(commit \S * \)。* git-svn-id:svn:[^ @] * @ \([0-9] * \)。* / \ 1 r \ 2 /'
I'm customizing my git log to be all in 1 line. Specifically, I added the following alias:
lg = log --graph --pretty=format:'%Cred%h%Creset - %C(yellow)%an%Creset - %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
So, when I run git lg
, I see the following:
* 41a49ad - zain - commit 1 message here (3 hours ago)
* 6087812 - zain - commit 2 message here (5 hours ago)
* 74842dd - zain - commit 3 message here (6 hours ago)
However, I want to add the SVN revision number in there too, so it looks something like:
* 41a49ad - r1593 - zain - commit 1 message here (3 hours ago)
The normal git log
shows you the SVN revision number, so I'm sure this must be possible. How do I do this?
When you say that "the normal git log
shows you the SVN revision number", I guess you mean that you are dealing with a repository handled by git svn
, which by default adds a line like this at the end of the synchronized commits:
git-svn-id: svn://path/to/repository@###### <domain>
Now, as far as git is concerned, this is just random text, so I doubt that you can find a %
accessor to read the ######
revision number from there.
At this point your best option would be to just parse the output of plain git log
by yourself. Here's a crude starting point:
git log -z | tr '\n\0' ' \n' | sed 's/\(commit \S*\) .*git-svn-id: svn:[^@]*@\([0-9]*\) .*/\1 r\2/'
这篇关于如何在git log中显示SVN修订号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!