Skip to content

Instantly share code, notes, and snippets.

@kuvaldini
Created August 10, 2022 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuvaldini/9f163ccbcf84681a7ec8d8a254f78044 to your computer and use it in GitHub Desktop.
Save kuvaldini/9f163ccbcf84681a7ec8d8a254f78044 to your computer and use it in GitHub Desktop.
Git extended log
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment