3

Current code to generate change logs:

svn2cl --linelen 78 --reparagraph --include-rev --group-by-day

The closest I could get with vanilla options is

git shortlog --format='* [%h] %s' -w78,8,10

How do I emulate the svn2cl output as closely as possible?

Example output:

2013-02-19  username

        * [r30695] path1: commit message
        * [r30691] path2, path3, path4: looooooooooooooooooooooooooooong
          commit message
        * [r30690] path1, path3: commit message

2013-02-19  other_user
        * ...

2013-02-18  username
        * ...

Two issues remain:

  • Include a human-readable list of paths before the commit message
  • Pretty-print long commit messages
2

Another solution gave the right direction. The result so far:

#!/usr/bin/env bash
while read -r -u 9 date name
do
    echo "$date  $name"
    echo
    GIT_PAGER=cat git log --no-merges --committer="$name" --since="$date 00:00:00 +0000" --until="$(date --date="$date + 1 day" +%Y-%m-%d) 00:00:00 +0000" --format='        * [%h] %s'
    echo
done 9< <(git log --no-merges --format=$'%cd %cn' --date=short | sort --unique --reverse)

The midnight times were necessary. It looks like for some reason it uses the current time instead of the start of the day by default.

Two issues remain:

  • Include a human-readable list of paths before the commit message
  • Pretty-print long commit messages

Sample output:

2013-02-19  username

        * [f97bb5f] commit message
        * [f0e419d] looooooooooooooooooooooooooooong commit message
        * [070e50f] commit message

2013-02-19  other_user
        * ...

2013-02-18  username
        * ...
1

In order to get this to work on OS X, I made some minor modifications to l0b0's solution:

git-grouped-log () {
  while read -r -u 9 since name
  do
    until=$(date -j -v+1d -f '%Y-%m-%d' $since +%Y-%m-%d)

    echo "$since $name"
    echo

    GIT_PAGER=cat git log             \
      --no-merges                     \
      --committer="$name"             \
      --since="$since 00:00:00 +0000" \
      --until="$until 00:00:00 +0000" \
      --format='  * [%h] %s'

    echo
  done 9< <(git log --no-merges --format=$'%cd %cn' --date=short | sort --unique --reverse)
}

I also wrapped it in a function, because then I can save it in an arbitrary file.

  • the git log statement helped me a lot – Rudolf Olah Aug 12 '14 at 16:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.