How do I show the SVN revision number in git log?

前端 未结 4 377
抹茶落季
抹茶落季 2020-12-24 11:56

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         


        
4条回答
  •  攒了一身酷
    2020-12-24 12:37

    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@###### 
    

    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/'
    

提交回复
热议问题