mootools php faith camera linux


Git Log - Commit
Message CSV

This one liner prints a comma delimited list of today's git log entries.

git log 
--format="%s" --since=yesterday perl -pe "s/\n/$1, /" perl -pe 's/Merge[^,]*, //'

Note the pipes | , in Linux that passes the output of the command to the next command chained by the pipe. There are two pipes here.

The output of git log is quite common, and git log -p and git log --stat are also quite useful for reveiwing commit histories.

In this case we are asking the output of git log to have the --format of %s . There are many other valid placeholders for git log --format="<PLACEHOLDER>" . Here is a list from that link:

  • '%H': commit hash
  • '%h': abbreviated commit hash
  • '%T': tree hash
  • '%t': abbreviated tree hash
  • '%P': parent hashes
  • '%p': abbreviated parent hashes
  • '%an': author name
  • '%ae': author email
  • '%ad': author date (format respects --date= option)
  • '%aD': author date, RFC2822 style
  • '%ar': author date, relative
  • '%at': author date, UNIX timestamp
  • '%ai': author date, ISO 8601 format
  • '%cn': committer name
  • '%ce': committer email
  • '%cd': committer date
  • '%cD': committer date, RFC2822 style
  • '%cr': committer date, relative
  • '%ct': committer date, UNIX timestamp
  • '%ci': committer date, ISO 8601 format
  • '%d': ref names, like the --decorate option of linkgit:git-log[1]
  • '%e': encoding
  • '%s': subject
  • '%f': sanitized subject line, suitable for a filename
  • '%b': body
  • '%B': raw body (unwrapped subject and body)
  • '%N': commit notes
  • '%gD': reflog selector, e.g., `refs/stash@\{1\}`
  • '%gd': shortened reflog selector, e.g., `stash@\{1\}`
  • '%gs': reflog subject
  • '%Cred': switch color to red
  • '%Cgreen': switch color to green
  • '%Cblue': switch color to blue
  • '%Creset': reset color
  • '%C(...)': color specification, as described in color.branch.* config option
  • '%m': left, right or boundary mark
  • '%n': newline
  • '%%': a raw '%'
  • '%x00': print a byte from a hex code
  • '%w([[,[,]]])': switch line wrapping

Note that some of the placeholders require other options

The perl switches just do some text manipulation to remove Merge entries and create a csv out of the list created by the git log --format="%s" command.

Last Updated: 2014-11-04 14:06:59
Creative Commons License Jay Johnston is a Zend Certified Engineer in PHP 5 LPI-ID: LPI000102450, Verfication Code: wmnnt56y2k  ... Jay Johnston is certified as LPIC-1 by the Linux Professional Institute