Skip to content

mackyle/git-log-compact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-log-compact

A compact alternative to git log --oneline that includes dates, times and author and/or committer initials in a space efficient output format.

The git-log-compact script is intended to fill the gap between the --oneline log output format and the --pretty=short/--pretty=medium output formats. It is not strictly a one line per commit output format (but almost) and while it only shows the title of each commit (like the --pretty=short format) it does include author and date information (like the --pretty=medium format) except that timestamps are shown very compactly and author/committer names are shown as initials.

This allows one to get a complete view of repository activity in a very compact output format that can show many commits per screen full and is fully compatible with the --graph option.

The --notes, --pretty and --format options are not allowed but any other git log options should work fine (especially --graph).

In both --graph and non --graph modes:

  • Root commits are identified by _ on either side of the hash

When --graph mode is enabled, the graph output is enhanced as follows:

  • Breaks are inserted when necessary to avoid parent/child ambiguity

Installation

Put the git-log-compact executable file in one of the directories included in the PATH environment variable.

Optionally set a global alias to save typing such as lc like so:

git config --global alias.lc log-compact

Optionally set global default options such as --two-initials and --abbrev=8 like so:

git config --global log-compact.defaults "--two-initials --abbrev=8"

Dates & Times

Dates and times are shown in the local timezone. Set the TZ variable before running git log-compact (e.g. TZ=UTC git log-compact to show dates and times in UTC) or use the --time-zone= option (e.g. git log-compact --time-zone=UTC) to change that.

Dates are shown on a date line all by themselves like so:

=== 2015-11-13 ===

The date line indicates that the times on all the following lines (regardless of whether or not --reverse is being used) up until the next date line take place on the indicated date. For example this output:

=== 2015-09-28 ===
be08dee9 13:18 jc (tag: v2.6.0) Git 2.6
=== 2015-09-21 ===
8d530c4d 13:26 jc (tag: v2.6.0-rc3) Git 2.6-rc3
904f6e7c 10:51 bn send-email: fix uninitialized var warning for $
=== 2015-09-20 ===
18a21c19 09:49 ps l10n: de.po: better language for one string
2e0f3663 09:49 rt l10n: de.po: translate 2 messages
5fc31c1f 09:44 tq l10n: Update and review Vietnamese translation

shows one commit on 2015-09-28, two commits on 2015-09-21 and three commits on 2015-09-20.

Note that a date line may appear more than once for the same date (this is especially common when using --graph with its default --topo-order).

The purpose of a date line is to indicate what date has been elided from the following lines, nothing more.

Examples

For example, running git log-compact --decorate --graph -n 17 v2.6.1 on the Git repository produces this output (which will be colorized on the terminal if color is enabled):

  === 2015-09-28 ===
* 22f698cb 19:19 jch (tag: v2.6.1) Git 2.6.1
*   3adc4ec7 19:16 jch Sync with v2.5.4
|\
| * 24358560 15:34 jch (tag: v2.5.4) Git 2.5.4
| *   11a458be 15:33 jch Sync with 2.4.10
| |\
| | * a2558fb8 15:30 jch (tag: v2.4.10) Git 2.4.10
| | *   6343e2f6 15:28 jch Sync with 2.3.10
| | |\
| | | * 18b58f70 15:26 jch (tag: v2.3.10) Git 2.3.10
| | | *   92cdfd21 14:59 jch Merge branch 'jk/xdiff-memory-limits
| | | |\
| | | | * 83c4d380 14:58 jk  merge-file: enforce MAX_XDIFF_SIZE o
| | | | * dcd1742e 14:57 jk  xdiff: reject files larger than ~1GB
| | | | * 3efb9880 14:57 jk  react to errors in xdi_diff
| | | * |   f2df3104 14:46 jch Merge branch 'jk/transfer-limit-re
| | | |\ \
| | | | | | === 2015-09-25 ===
| | | | * | b2581164 15:32 bb  http: limit redirection depth
| | | | * | f4113cac 15:30 bb  http: limit redirection to protoco
| | | | * | 5088d3b3 15:28 jk  transport: refactor protocol white
| | | | | |   === 2015-09-28 ===
| | | * | |   df37727a 14:33 jch Merge branch 'jk/transfer-limit-
| | | |\ \ \
| | | | |/ /
| | | | | /
| | | | |/
| | | |/|
| | | | | === 2015-09-23 ===
| | | | * 33cfccbb 11:35 jk  submodule: allow only certain protoc

The output will be colorized according to the same settings used to enable/ disable color for git log output.

Additionally, the color of the three new items (dates, times and initials) can be controlled with the color.log-compact.date, color.log-compact.time and color.log-compact.initials config options.

Running git log-compact --graph --max-parents=0 on the Git repository gives:

  === 2009-04-24 ===
*_0ca71b37_11:13 ap  basic options parsing and whatnot.
  === 2007-01-30 ===
*_16d6b8ab_15:16 sh  Initial import of a python script to import ch
  === 2006-11-06 ===
*_cb07fc2a_11:20 sop git-gui: Initial revision.
  === 2005-08-07 ===
*_161332a5_10:49 ks  first working version
  === 2005-04-11 ===
*_2744b234_23:46 lt  Start of early patch applicator tools for git.
  === 2005-05-08 ===
*_1db95b00_21:08 pm  Add initial version of gitk to the CVS reposit
  === 2005-04-07 ===
*_e83c5163_15:13 lt  Initial revision of "git", the information man

Notice the _ on either side of the hash identifying those commits as root commits. The _ will only appear on the left side of the hash if the selected output format would have normally included a space there. In --graph mode, all the spaces between the commit mark (e.g. *) and the hash are turned into _.

Running git log-compact --decorate --graph --no-merges -n 13 v2.6.1 on the Git repository results in this output:

  === 2015-09-28 ===
* 22f698cb 19:19 jch (tag: v2.6.1) Git 2.6.1
                     ..........
* 24358560 15:34 jch (tag: v2.5.4) Git 2.5.4
                     ..........
* a2558fb8 15:30 jch (tag: v2.4.10) Git 2.4.10
                     ..........
* 18b58f70 15:26 jch (tag: v2.3.10) Git 2.3.10
                     ..........
* 83c4d380 14:58 jk  merge-file: enforce MAX_XDIFF_SIZE on incomi
* dcd1742e 14:57 jk  xdiff: reject files larger than ~1GB
* 3efb9880 14:57 jk  react to errors in xdi_diff
|   === 2015-09-25 ===
| * b2581164 15:32 bb  http: limit redirection depth
| * f4113cac 15:30 bb  http: limit redirection to protocol-whitel
| * 5088d3b3 15:28 jk  transport: refactor protocol whitelist cod
| | === 2015-09-23 ===
| * 33cfccbb 11:35 jk  submodule: allow only certain protocols fo
| * a5adaced 11:35 jk  transport: add a protocol-whitelist enviro
|/
|   === 2015-09-28 ===
| * be08dee9 13:18 jch (tag: v2.6.0) Git 2.6

Notice how four linear breaks (..........) were automatically inserted to avoid parent child relationship confusion.

In non --graph mode, linear breaks are NOT automatically inserted. They must be requested with the usual --show-linear-break option.

Options

In addition to allowing all the normal git log options except for --notes, --format and --pretty (--oneline is allowed and silently ignored), the following additional options may be utilized:

  • --seconds
    include seconds in the time (i.e. HH:MM:SS instead of just HH:MM)

  • --minutes
    include minutes but not seconds in the time (i.e. HH:MM not HH:MM:SS)
    This is the default

  • --no-times
    omit the time field entirely

  • --two-initials
    only show at most two initials instead of the usual three
    This is the default if --initials=author,committer or --initials=committer,author is used.

  • --three-initials
    show at most three initials
    This is the default unless --initials=author,committer or --initials=committer,author is used.

  • --no-initials
    omit the initials field entirely

  • --commit-message
    when using --walk-reflogs show commit message not reflog message

  • --author-date
    force use of author dates and times
    The default is to use committer dates and times unless --author-date-order is in effect. This option forces author dates and times to always be used and overrides --committer-date.

  • --committer-date
    force use of committer dates and times
    The default is to use committer dates and times if --date-order or --topo-order is in effect or --author-date-order is NOT in effect. This option forces committer dates and times to always be used and overrides a previous --author-date option.

  • --initials=author
    show author initials
    This is the default behavior

  • --initials=committer
    show committer initials instead of author initials

  • --initials=author,committer
    show author and commiter initials separated by a /
    This changes the initials width default from three to two.

  • --initials=committer,author
    show commiter and author initials separated by a /
    This changes the initials width default from three to two.

  • --time-zone=zone
    set the TZ environment variable to zone
    This is an alterative to setting TZ before running git log-compact and will affect the time zone dates and times are displayed in.

  • --weekday
    show the weekday with the date

  • --no-weekday
    do not show the weekday with the date
    This is the default behavior

In addition to the above options, color output is controlled as normal for git log with the addition of color.log-compact.date, color.log-compact.time and color.log-compact.initials config options to alter the default colors for dates, times and initials respectively.

Furthermore, default options may be set in the log-compact.defaults config value and they will be treated as though they appeared at the very beginning of the git log-compact command line option list (e.g. git config log-compact.defaults "--abbrev=8 --seconds").