Last active
July 6, 2022 16:50
-
-
Save kuvaldini/eacc97de2cd30d45a0487e1eb9c4ec4a to your computer and use it in GitHub Desktop.
Git nice log extended
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
var_is_unset(){ | |
declare -rn var=$1 | |
test -z ${var+x} | |
} | |
while test $# -gt 0 ;do | |
case $1 in | |
-*) args+=("$1") ;; | |
*) | |
if test -n "${args[0]:-}" ;then | |
args+=("$1") | |
elif var_is_unset head ;then | |
head="$1" | |
elif var_is_unset devel ;then | |
devel="$1" | |
else | |
args+=("$1") | |
fi | |
esac | |
shift | |
done | |
head=${head:-HEAD} | |
devel=${devel:-develop} | |
git rev-parse $head'@{u}' >/dev/null && | |
headup=$head'@{u}' || true | |
last_merge=$(git rev-list --merges $devel...$head | tail -1) | |
test -n "$last_merge" && | |
{ | |
base=$(git merge-base $last_merge^1 $last_merge^2) #$devel) | |
}||{ | |
base=$(git merge-base $head $devel) | |
} | |
git branch -f BASE $base | |
#trap 'git branch -d BASE >/dev/null' EXIT | |
# base=$(git merge-base --all $head $devel | tail -1) | |
# base=$(git merge-base --all $headup $base | tail -1) | |
# git branch -f BASE $base | |
# if test $(git rev-parse $base) = $(git rev-parse $devel) ;then | |
# not="--not $base^@" | |
# else | |
# not="--not $base" | |
# fi | |
not="--not $base" | |
#git config alias.nl "log --graph --decorate --date=human --pretty=format:'%C(yellow bold)%h %C(green dim)%ad %C(blue)%an %C(auto)%s %d'" | |
git nl $head ${headup:-} $devel $not "${args[@]}" --boundary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
curl https://gist.githubusercontent.com/kuvaldini/eacc97de2cd30d45a0487e1eb9c4ec4a/raw/995ad8dd1d4ff4f0329d2067ce26cdc423df1023/git-nlx >/usr/local/bin/git-nlx | |
chmod +x /usr/local/bin/git-nlx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment