2

You can customize the output of git log using --pretty and you can show the number of added and deleted lines using --numstat. It looks like this:

$ git log --pretty=format:"%h - %ar : %s" --numstat config*.ini
f665c63 - 6 months ago : fixes session end post
1 1 config.ini
4541de2 - 7 months ago : fixes missing strings
6 1 config.ini
3 1 config_office.ini

But what I want is the output of both, the commit information and the changes in the files, to show in one line each. Something like this:

1 1 config.ini f665c63 - 6 months ago : fixes session end post
6 1 config.ini 4541de2 - 7 months ago : fixes missing strings
3 1 config_office.ini 4541de2 - 7 months ago : fixes missing strings

This way it would be straightforward to parse this output using grep, sort, etc. Does git already provide this functionality?

asked Nov 3, 2012 at 18:04

1 Answer 1

1

As far as I can tell, git log can't do that natively. However, this sed command will do it:

sed '/^[0-9]\+\t[0-9]\+\t[^\t]\+$/ b file; h; d; : file; G; s/\n/\t/'

It looks for the --numstat lines. Any non-numstat line is copied into the hold buffer and not printed. Lines with numstat output get the current contents of the hold buffer appended, leaving a newline in the middle, which is then replaced with a tab.

answered Nov 4, 2012 at 21:25

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.