-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-list
executable file
·33 lines (33 loc) · 1.27 KB
/
git-list
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
33
# git list : a very compact log of recent commits
#
# for best results make a .mailmap file with shortened names for everyone
#
# examples:
# git list
# git list 30
# git list somebranch
# git list somebranch 5
# git list 30 develop..somebranch
#
if [ "$1" -eq "$1" 2> /dev/null ]; then
N=$1
B="${@:2}"
elif [ "$2" -eq "$2" 2> /dev/null ]; then
N=$2
B=$1
else
N='12'
B="$@"
if git describe $B > /dev/null 2>&1; then
# Show at least all the divergent commits (if fewer than 30)
MIN=$(($(git log --oneline origin..${B:-@} | wc -l) + 1)) # note: origin refers to origin's HEAD, not current branch's upstream
N=$(( $N < $MIN ? $MIN > 30 ? 30 : $MIN : $N ))
fi
fi
if [[ $FIRST_PARENT == true ]]; then # used by git-line
git log -n $N --pretty="%h %C(blue)%<(7)%aN%Creset %s %C(green)#&%p %C(cyan)%d%Creset" --decorate-refs-exclude='refs/remotes/*/HEAD' --color=always --first-parent $B \
| sed 's/#&[^ ]* *//' # works with the format string to delete the first parent hash
else
git log -n $N --pretty="%h %C(blue)%<(7)%aN%Creset %s %C(green)#&%p#& %C(cyan)%d%Creset" --decorate-refs-exclude='refs/remotes/*/HEAD' --color=always $B \
| sed 's/#&[^ ]*#&//' | sed 's/#&//g' # works with the format string to delete the parent hash if there's only one parent
fi