File: git-log-pretty-since.sh

package info (click to toggle)
neovim 0.1.7-4%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 39,060 kB
  • sloc: ansic: 176,052; python: 2,091; awk: 709; sh: 528; perl: 374; makefile: 295; exp: 33; ruby: 8
file content (32 lines) | stat: -rwxr-xr-x 804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash

# Shows a log with changes grouped next to their merge-commit.
#
# Parameters:
#   $1    "since" commit
#   $2    "inverse match" regex pattern

set -e
set -u
set -o pipefail

__SINCE=$1
__INVMATCH=$2

is_merge_commit() {
  git rev-parse $1 >/dev/null 2>&1 \
    || { echo "ERROR: invalid commit: $1"; exit 1; }
  git log $1^2 >/dev/null 2>&1 && return 0 || return 1
}

for commit in $(git log --format='%H' --first-parent "$__SINCE"..HEAD); do
  if is_merge_commit ${commit} ; then
      if [ -z "$__INVMATCH" ] || ! git log --oneline ${commit}^1..${commit}^2 \
           | grep -E "$__INVMATCH" >/dev/null 2>&1 ; then
        git log -1 --oneline ${commit}
        git log --format='    %h %s' ${commit}^1..${commit}^2
      fi
  else
    git log -1 --oneline ${commit}
  fi
done