123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/bin/sh
- commit=$1
- die () {
- echo >&2 "$*"
- exit 1
- }
- if ! git update-index -q --ignore-submodules --refresh
- then
- die "Up-to-date check failed"
- fi
- if ! git diff-files --quiet --ignore-submodules --
- then
- die "Working directory has unstaged changes"
- fi
- if git cat-file -e HEAD 2>/dev/null
- then
- head=HEAD
- else
- head=$(git hash-object -t tree --stdin </dev/null)
- fi
- if ! git diff-index --quiet --cached --ignore-submodules $head --
- then
- die "Working directory has staged changes"
- fi
- if ! git read-tree -u -m "$commit"
- then
- die "Could not update working tree to new HEAD"
- fi
|