Question

this is related to this question, but I think it warrants a separate question.

git blame --line-porcelain's output is something like this

27ce485030bf872158ceb011e6bd775d2ead5eeb 9 36 1
author Joao Tavora
author-time 1358179206
committer Joao Tavora
committer-time 1358179206
summary initial commit
boundary
filename test.el
    (defun AB (space task next.task)
242020d0de6363d48d32465299d07239f0a9940f 19 37 1
author Joao Tavora
author-time 1358179709
committer Joao Tavora
committer-time 1358179709
summary reinstate declare
previous 11da1748d905aa9520ee3d6d9ac6a8712db0040f test.el
filename test.el
      (declare (ignore space))
cbfa1ec071dd30a27be82dd041ccc9c384e5ff60 11 38 2
author Joao Tavora
author-time 1358179273
committer Joao Tavora
committer-time 1358179273
summary use thingy
previous 69af7ace6e2b6c006c86e4fd91bf3c15ff8cec07 test.el
filename test.el
      (if (and (some.task.p (task (IP.TASK-thingy task)))

How would I use sed (or grep or awk) toparse to filter out just the commit sha and the comitter-time? In the example above it should yield:

27ce485030bf872158ceb011e6bd775d2ead5eeb 1358179206
242020d0de6363d48d32465299d07239f0a9940f 1358179709
cbfa1ec071dd30a27be82dd041ccc9c384e5ff60 1358179273 

I'd rather not depend on ruby, although a perl one-liner might be OK.

Était-ce utile?

La solution

This might work for you (GNU sed):

sed -r '/^[0-9a-f]{40}\b/!d;:a;/\ncommitter-time\b/bb;$!{N;ba};:b;s/\s+.*(\s.*)/\1/' file

Autres conseils

This might be completely the wrong thing, but try this:

git shortlog --format="%H %ct" -- <filename>

You may also want to cut off the first couple of lines with a tail -n +2 piped after the command. Granted, this doesn't show line-by-line changes but I'm not sure exactly what pieces you want.

I've found out that

git blame -l -e -t -- file-to-blame | awk '{print $1 " " $3}'

almost solves my problem, but does so for authorship time I think. And I would really like to learn to parse --line-porcelain output.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top