Skip to content

Commit 07e62b7

Browse files
peffgitster
authored andcommitted
rebase: improve error messages about dirty state
If you have unstaged changes in your working tree and try to rebase, you will get the cryptic "foo: needs update" message, but nothing else. If you have staged changes, you get "your index is not up-to-date". Let's improve this situation in two ways: - for unstaged changes, let's also tell them we are canceling the rebase, and why (in addition to the "needs update" lines) - for the staged changes case, let's use language that is a little more clear to the user: their index contains uncommitted changes Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71fe945 commit 07e62b7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

git-rebase.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,14 @@ else
332332
fi
333333

334334
# The tree must be really really clean.
335-
git update-index --ignore-submodules --refresh || exit
335+
if ! git update-index --ignore-submodules --refresh; then
336+
echo >&2 "cannot rebase: you have unstaged changes"
337+
exit 1
338+
fi
336339
diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
337340
case "$diff" in
338-
?*) echo "cannot rebase: your index is not up-to-date"
339-
echo "$diff"
341+
?*) echo >&2 "cannot rebase: your index contains uncommitted changes"
342+
echo >&2 "$diff"
340343
exit 1
341344
;;
342345
esac

0 commit comments

Comments
 (0)