X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-sh-setup.sh;h=5aa62dda15d1c24d0b01845ded4c8bc15e98bf8a;hb=92b7ba16b7605f70cac845d4a8d0162392ac0223;hp=3c325fd1339608d681d3485aa37647d9ac734037;hpb=9269df96105dff5ecc137b598ac7664d218ac6be;p=git.git diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 3c325fd13..5aa62dda1 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -16,9 +16,40 @@ die() { exit 1 } -usage() { - die "Usage: $0 $USAGE" -} +if test -n "$OPTIONS_SPEC"; then + usage() { + exec "$0" -h + } + + parseopt_extra= + [ -n "$OPTIONS_KEEPDASHDASH" ] && + parseopt_extra="--keep-dashdash" + + eval "$( + echo "$OPTIONS_SPEC" | + git rev-parse --parseopt $parseopt_extra -- "$@" || + echo exit $? + )" +else + usage() { + die "Usage: $0 $USAGE" + } + + if [ -z "$LONG_USAGE" ] + then + LONG_USAGE="Usage: $0 $USAGE" + else + LONG_USAGE="Usage: $0 $USAGE + +$LONG_USAGE" + fi + + case "$1" in + -h|--h|--he|--hel|--help) + echo "$LONG_USAGE" + exit + esac +fi set_reflog_action() { if [ -z "${GIT_REFLOG_ACTION:+set}" ] @@ -91,26 +122,11 @@ get_author_ident_from_commit () { LANG=C LC_ALL=C sed -ne "$pick_author_script" } -if [ -z "$LONG_USAGE" ] -then - LONG_USAGE="Usage: $0 $USAGE" -else - LONG_USAGE="Usage: $0 $USAGE - -$LONG_USAGE" -fi - -case "$1" in - -h|--h|--he|--hel|--help) - echo "$LONG_USAGE" - exit -esac - # Make sure we are in a valid repository of a vintage we understand. if [ -z "$SUBDIRECTORY_OK" ] then : ${GIT_DIR=.git} - GIT_DIR=$(GIT_DIR="$GIT_DIR" git rev-parse --git-dir) || { + test -z "$(git rev-parse --show-cdup)" || { exit=$? echo >&2 "You need to run this command from the toplevel of the working tree." exit $exit