Skip to content

Commit

Permalink
rebase: improve error messages about dirty state
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 11, 2008
1 parent 71fe945 commit 07e62b7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07e62b7

Please sign in to comment.