fi
# The tree must be really really clean.
-git update-index --ignore-submodules --refresh || exit
+if ! git update-index --ignore-submodules --refresh; then
+ echo >&2 "cannot rebase: you have unstaged changes"
+ exit 1
+fi
diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
case "$diff" in
-?*) echo "cannot rebase: your index is not up-to-date"
- echo "$diff"
+?*) echo >&2 "cannot rebase: your index contains uncommitted changes"
+ echo >&2 "$diff"
exit 1
;;
esac
switch_to="$2"
if git show-ref --verify --quiet -- "refs/heads/$2" &&
- branch=$(git rev-parse --verify "refs/heads/$2" 2>/dev/null)
+ branch=$(git rev-parse -q --verify "refs/heads/$2")
then
head_name="refs/heads/$2"
- elif branch=$(git rev-parse --verify "$2" 2>/dev/null)
+ elif branch=$(git rev-parse -q --verify "$2")
then
head_name="detached HEAD"
else