merge-recursive: don't segfault while handling rename clashes
[gitweb.git] / git-rebase.sh
index 023a6dc94a48f7abf2801359ad68d40909e9b6aa..ebd4df3a0e821ddcfd1eabfcaac17f854e172a85 100755 (executable)
@@ -332,11 +332,14 @@ else
 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
@@ -365,10 +368,10 @@ case "$#" in
        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