Last active
May 26, 2022 19:51
-
-
Save groyoh/4683375df4bcad8ae31e9abdbe3a2d4d to your computer and use it in GitHub Desktop.
`git stat` command
This file contains hidden or 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
| #!/bin/sh | |
| # | |
| # To be placed in a directory that's present in $PATH. | |
| usage() { | |
| cat <<EOF | |
| Usage: git stat [OPTIONS] [--] [<commit>] | |
| Options: | |
| -h,--help show this help | |
| EOF | |
| } | |
| arg="" | |
| params=() | |
| while (( "$#" )); do | |
| case "$1" in | |
| -h|-\?|--help) usage; exit 0 ;; | |
| --) | |
| shift | |
| while (( "$#" )); do | |
| params+=("$1") | |
| shift | |
| done | |
| ;; | |
| -*|--*=) echo "unsupported option $1" >&2; exit 1 ;; | |
| *) params+=("$1"); shift ;; | |
| esac | |
| done | |
| if [ "${#params[@]}" -eq 0 ]; then | |
| params+=("HEAD") | |
| fi | |
| if [ "${#params[@]}" -ne 1 ]; then | |
| usage | |
| exit 1 | |
| fi | |
| ref=$params | |
| ignores="" | |
| if [ -f $HOME/.gitstatignore ]; then | |
| ignores=$(< $HOME/.gitstatignore tr '\n' '\0' | xargs -0 -I{} echo :\!{} | tr '\n' ' ') | |
| fi | |
| git diff $ref --shortstat -- . $ignores |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment