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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Dec 10, 2008 at 04:25 UTC
07e62b733fad4236371a8cd6abc32409fb1fb87d
1 file changed
+6
-3
git-rebase.sh
+6
-3
@@ -332,11 +332,14 @@ else
332
fi
333
334
# 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
339
diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
340
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"
343
exit 1
344
;;
345
esac