X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-sh-setup.sh;h=aa16b8356507e4e669ee5c4cb4b5a667942d559e;hb=eb9cb55b944796374402ab4e2639300dc9b0b409;hp=ae031a1375e9c674d80b9fa3d3d3b76780deaf9f;hpb=b3ff808b714fd8fc5e4d2770720398e5dc7d27f9;p=git.git diff --git a/git-sh-setup.sh b/git-sh-setup.sh index ae031a137..aa16b8356 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -145,6 +145,35 @@ 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 /{