Format Svn Log Output

I would like to fetch the log message for a file committed to svn. I'm using the following command currently:

 svn --non-interactive log "myfile.c" | sed -e "s/[\-]//g"'   

The output is :

r42153 | sam | 2012-03-02 14:51:53 -0800 (Fri, 02 Mar 2012) | 1 line

Update to code.  

I would like to get rid of the first line "r42153 | sam |...." and output just the log message.

How can I do this?

4 Answers

use | grep -v "what you don't want to include" to leave out the lines you don't want. However, trying to leave out anything with a \n just leaves out everything, so don't do that.

1

You can throw away useful lines from your commit messages while using grep. SVN provides propget command out of the box:

use

$ svn propget svn:log --revprop -r R [TARGET]

to get commit message

or

$ svn propget svn:log --revprop -r R [TARGET] --xml

to get it in XML.

TARGET is path to repository and can be omitted id you are in working copy.

1

You can use | sed -e ':a;N;$!ba;s/-\+\(\n[^\n]*\n\)\?//g' to remove all "---" with treir next lines.

As long as you are logging a single revision, you can use

svn log -rXXXX | tail -n+4 | head -n-1

to get rid of everything except the message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest