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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/env bash
usage() {
echo 1>&2 "usage: git missing [<first branch>] <second branch> [<git log options>] [[--] <path>...]"
}
if [ "${#}" -lt 1 ]
then
usage
exit 1
fi
declare -a git_log_args=()
declare -a branches=()
declare -a pathspec=()
declare parse_path=false
for arg in "$@" ; do
if [[ $parse_path == true ]]; then
pathspec+=("$@")
break
fi
case "$arg" in
--)
parse_path=true
;;
--*)
git_log_args+=( "$arg" )
;;
*)
branches+=( "$arg" )
;;
esac
done
firstbranch=
secondbranch=
if [ ${#branches[@]} -eq 2 ]
then
firstbranch="${branches[0]}"
secondbranch="${branches[1]}"
elif [ ${#branches[@]} -eq 1 ]
then
secondbranch="${branches[0]}"
else
echo >&2 "error: at least one branch required"
exit 1
fi
git log "${git_log_args[@]}" "$firstbranch"..."$secondbranch" --format="%m %h %s" --left-right -- "${pathspec[@]}"
|