X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=git-sh-setup.sh;h=aa16b8356507e4e669ee5c4cb4b5a667942d559e;hb=a66cee2edeb503cb7a589ff9d9efa75dc8f0fedc;hp=6131670860514c215a6b9b7417dd05c3124e81b4;hpb=9db41eba4259126dbe1c68e2207d342d11f14745;p=thirdparty%2Fgit.git diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 6131670860..aa16b83565 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -145,23 +145,49 @@ require_work_tree () { die "fatal: $0 cannot be used without a working tree." } +require_clean_work_tree () { + git rev-parse --verify HEAD >/dev/null || exit 1 + git update-index -q --ignore-submodules --refresh + err=0 + + if ! git diff-files --quiet --ignore-submodules + then + echo >&2 "Cannot $1: You have unstaged changes." + err=1 + fi + + if ! git diff-index --cached --quiet --ignore-submodules HEAD -- + then + if [ $err = 0 ] + then + echo >&2 "Cannot $1: Your index contains uncommitted changes." + else + echo >&2 "Additionally, your index contains uncommitted changes." + fi + err=1 + fi + + if [ $err = 1 ] + then + test -n "$2" && echo >&2 "$2" + exit 1 + fi +} + get_author_ident_from_commit () { pick_author_script=' /^author /{ s/'\''/'\''\\'\'\''/g h s/^author \([^<]*\) <[^>]*> .*$/\1/ - s/'\''/'\''\'\'\''/g s/.*/GIT_AUTHOR_NAME='\''&'\''/p g s/^author [^<]* <\([^>]*\)> .*$/\1/ - s/'\''/'\''\'\'\''/g s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p g s/^author [^<]* <[^>]*> \(.*\)$/\1/ - s/'\''/'\''\'\'\''/g s/.*/GIT_AUTHOR_DATE='\''&'\''/p q @@ -209,5 +235,20 @@ case $(uname -s) in find () { /usr/bin/find "$@" } + is_absolute_path () { + case "$1" in + [/\\]* | [A-Za-z]:*) + return 0 ;; + esac + return 1 + } ;; +*) + is_absolute_path () { + case "$1" in + /*) + return 0 ;; + esac + return 1 + } esac