Created
April 17, 2021 09:33
-
-
Save matthiasbeyer/171ecfb8c6d75cd43c6beb426a254460 to your computer and use it in GitHub Desktop.
diff a branch to a base branch
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 | |
help() { | |
cat <<EOS | |
$0 [-h | --help] [base] [head] | |
Diff current branch (or [head], if passed) to [base] | |
EOS | |
} | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-h|--help) | |
help | |
exit 1 | |
;; | |
*) # unknown option | |
POSITIONAL+=("$1") # save it in an array for later | |
shift # past argument | |
;; | |
esac | |
done | |
set -- "${POSITIONAL[@]}" # restore positional parameters | |
. "$(git --exec-path)/git-sh-setup" | |
base_branch="$1" | |
head_branch="${2:-HEAD}" | |
echo "$base_branch" | |
echo "$head_branch" | |
exec git diff $(git merge-base "$base_branch" "$head_branch").."$head_branch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment