-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgit-l
executable file
·37 lines (32 loc) · 863 Bytes
/
git-l
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
34
35
36
37
#!/usr/bin/env bash
#
# git-l
#
# License: MIT
# Copyright (c) 2012 Lennart C. L. Kats
set -e
if [ "$1" == "" ]; then
BRANCH=HEAD
else
BRANCH=$1
shift
fi
if echo $BRANCH | grep '\.\.' >/dev/null; then
LOG=`git log --oneline --first-parent $BRANCH "$@" | head -n 21`
elif ! git remote | grep -iE '^origin$' >/dev/null; then
LOG=`git log --oneline --first-parent $BRANCH "$@" | head -n 21`
else
LOG=`git log --oneline --first-parent origin/master..$BRANCH "$@" | head -n 21`
fi
if [ "$LOG" == "" ] &&
(echo $BRANCH | grep -iE '^(master|origin/master)$' >/dev/null ||
(echo $BRANCH | grep -iE '^HEAD$' >/dev/null && [ "`git-get-branch 2>/dev/null`" == "master" ]))
then
LOG=`git log --oneline --first-parent $BRANCH "$@" | head -n 21`
fi
if [ `echo "$LOG" | wc -l` -gt 20 ]; then
echo "$LOG" | head -n 20
echo ...
else
echo "$LOG"
fi