#!/bin/sh
set -e

usage () {
    cat <<'EOF'
usage: git show-skipped [-qh] <file> [<file> ...]

Lists all files that are skipped from the index.

Options:
-q    Be quiet (just return a non-zero exit code when files are skipped)
-h    Show this help
EOF
}

quiet=0
while getopts qh flag; do
    case "$flag" in
        q) quiet=1;;
        h) usage; exit 0;;
    esac
done
shift $(($OPTIND - 1))

list_skipped () {
    git ls-files -v | grep "^S" | cut -c3-
}

if [ $quiet -eq 0 ]; then
    list_skipped
else 
    num_changed=$(list_skipped | wc -l)
    test "$num_changed" -eq 0
fi
