{"thread":{"id":"13597","subject":"[PATCH] pull --rebase: exit early when the working directory is dirty","startedAt":"2008-05-21T11:32:16Z","lastAt":"2008-05-21T15:11:20Z","messageCount":4,"participants":["Johannes Schindelin","Andreas Ericsson","Jan Krüger","Geert Bosch"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77381","messageId":"alpine.DEB.1.00.0805211230290.30431@racer","threadId":"13597","inReplyTo":null,"subject":"[PATCH] pull --rebase: exit early when the working directory is dirty","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-21T11:32:16Z","receivedAt":"2008-05-21T11:32:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen rebasing fails during \"pull --rebase\", you cannot just clean up the\nworking directory and call \"pull --rebase\" again, since the remote branch\nwas already fetched.\n\nTherefore, die early when the working directory is dirty.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-pull.sh     |    5 +++++\n t/t5520-pull.sh |   18 ++++++++++++++++++\n 2 files changed, 23 insertions(+), 0 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex bf0c298..9a9e764 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -107,6 +107,11 @@ error_on_no_merge_candidates () {\n }\n \n test true = \"$rebase\" && {\n+\tgit update-index --refresh &&\n+\tgit diff-files --quiet &&\n+        git diff-index --cached --quiet HEAD -- ||\n+\tdie \"refusing to pull with rebase: your working tree is not up-to-date\"\n+\n \t. git-parse-remote &&\n \torigin=\"$1\"\n \ttest -z \"$origin\" && origin=$(get_default_remote)\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex 9484129..997b2db 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -92,4 +92,22 @@ test_expect_success '--rebase with rebased upstream' '\n \n '\n \n+test_expect_success 'pull --rebase dies early with dirty working directory' '\n+\n+\tgit update-ref refs/remotes/me/copy copy^ &&\n+\tCOPY=$(git rev-parse --verify me/copy) &&\n+\tgit rebase --onto $COPY copy &&\n+\tgit config branch.to-rebase.remote me &&\n+\tgit config branch.to-rebase.merge refs/heads/copy &&\n+\tgit config branch.to-rebase.rebase true &&\n+\techo dirty >> file &&\n+\tgit add file &&\n+\ttest_must_fail git pull &&\n+\ttest $COPY = $(git rev-parse --verify me/copy) &&\n+\tgit checkout HEAD -- file &&\n+\tgit pull &&\n+\ttest $COPY != $(git rev-parse --verify me/copy)\n+\n+'\n+\n test_done\n-- \n1.5.5.1.497.ga63a5\n"},{"id":"77382","messageId":"48340FE6.90902@op5.se","threadId":"13597","inReplyTo":"alpine.DEB.1.00.0805211230290.30431@racer","subject":"Re: [PATCH] pull --rebase: exit early when the working directory is dirty","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-05-21T12:04:54Z","receivedAt":"2008-05-21T12:04:54Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> When rebasing fails during \"pull --rebase\", you cannot just clean up the\n> working directory and call \"pull --rebase\" again, since the remote branch\n> was already fetched.\n> \n> Therefore, die early when the working directory is dirty.\n\n\nFunny stuff. I helped a co-worker with just exactly this issue less than\nten minutes ago, so, fwiw:\nLiked-by: Andreas Ericsson <ae@op5.se>\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"77384","messageId":"20080521153110.059bc6a3@neuron","threadId":"13597","inReplyTo":"alpine.DEB.1.00.0805211230290.30431@racer","subject":"Re: [PATCH] pull --rebase: exit early when the working directory is dirty","fromName":"Jan Krüger","fromEmail":"jk@jk.gs","sentAt":"2008-05-21T13:31:10Z","receivedAt":"2008-05-21T13:31:10Z","isPatch":true,"sender":{"key":"jk@jk.gs","avatar":"https://avatars.githubusercontent.com/u/1774?v=4"},"body":"Hi,\n\n> When rebasing fails during \"pull --rebase\", you cannot just clean up\n> the working directory and call \"pull --rebase\" again, since the\n> remote branch was already fetched.\n> \n> Therefore, die early when the working directory is dirty.\n\nGood idea.\n\n> +\tgit update-index --refresh &&\n> +\tgit diff-files --quiet &&\n> +        git diff-index --cached --quiet HEAD -- ||\n> +\tdie \"refusing to pull with rebase: your working tree is not\n> up-to-date\"\n\nPerhaps the \"up-to-date\" should be changed to something else, following\nthe recent discussion about the \"up-to-date\" message in checkout (but\nhere we don't have to worry about breaking anything else). In that case,\nI'd suggest:\n\n\"Refusing to pull with rebase: your working tree has uncommitted\nchanges\"\n\n-- \nBest regards\nJan Krüger <jk@jk.gs>\n"},{"id":"77394","messageId":"626F2244-15CE-481C-A8F5-D6744F06D46F@adacore.com","threadId":"13597","inReplyTo":"alpine.DEB.1.00.0805211230290.30431@racer","subject":"Re: [PATCH] pull --rebase: exit early when the working directory is dirty","fromName":"Geert Bosch","fromEmail":"bosch@adacore.com","sentAt":"2008-05-21T15:11:20Z","receivedAt":"2008-05-21T15:11:20Z","isPatch":true,"sender":{"key":"bosch@adacore.com","avatar":null},"body":"\nOn May 21, 2008, at 07:32, Johannes Schindelin wrote:\n> When rebasing fails during \"pull --rebase\", you cannot just clean up  \n> the\n> working directory and call \"pull --rebase\" again, since the remote  \n> branch\n> was already fetched.\n>\n> Therefore, die early when the working directory is dirty.\nMuch nicer indeed to die early on errors, as we also can\ngenerally give better error messages.\n> +\tdie \"refusing to pull with rebase: your working tree is not up-to- \n> date\"\n\nI thought we'd prefer saying:\n               \"refusing to pull with rebase: your working tree has  \nlocal changes\"\n\n   -Geert\n"}]}