Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 38 lines (32 sloc) 863 Bytes
#!/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