{"thread":{"id":"16662","subject":"[PATCH] rebase: improve error messages about dirty state","startedAt":"2008-12-10T09:25:19Z","lastAt":"2008-12-10T09:25:19Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"97478","messageId":"20081210092518.GA14424@coredump.intra.peff.net","threadId":"16662","inReplyTo":null,"subject":"[PATCH] rebase: improve error messages about dirty state","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-12-10T09:25:19Z","receivedAt":"2008-12-10T09:25:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"If you have unstaged changes in your working tree and try to\nrebase, you will get the cryptic \"foo: needs update\"\nmessage, but nothing else.  If you have staged changes, you\nget \"your index is not up-to-date\".\n\nLet's improve this situation in two ways:\n\n - for unstaged changes, let's also tell them we are\n   canceling the rebase, and why (in addition to the \"needs\n   update\" lines)\n\n - for the staged changes case, let's use language that is a\n   little more clear to the user: their index contains\n   uncommitted changes\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI am cleaning up some old branches, and I think this is worth applying.\nIt came out of a \"rebase's error message is confusing\" thread back in\nApril:\n\n  http://thread.gmane.org/gmane.comp.version-control.git/78698\n\nIt would be nice also to say \"foo: locally modified\" instead of \"foo:\nneeds update\" but the REFRESH_SAY_CHANGED functionality isn't exposed\nvia the command line.\n\n git-rebase.sh |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex ea7720d..ebd4df3 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -332,11 +332,14 @@ else\n fi\n \n # The tree must be really really clean.\n-git update-index --ignore-submodules --refresh || exit\n+if ! git update-index --ignore-submodules --refresh; then\n+\techo >&2 \"cannot rebase: you have unstaged changes\"\n+\texit 1\n+fi\n diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)\n case \"$diff\" in\n-?*)\techo \"cannot rebase: your index is not up-to-date\"\n-\techo \"$diff\"\n+?*)\techo >&2 \"cannot rebase: your index contains uncommitted changes\"\n+\techo >&2 \"$diff\"\n \texit 1\n \t;;\n esac\n-- \n1.6.1.rc2.15.g7752a\n"}]}