git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pull --rebase: exit early when the working directory is dirty
@ 2008-05-21 11:32 Johannes Schindelin
  2008-05-21 12:04 ` Andreas Ericsson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johannes Schindelin @ 2008-05-21 11:32 UTC (permalink / raw)
  To: git, gitster


When rebasing fails during "pull --rebase", you cannot just clean up the
working directory and call "pull --rebase" again, since the remote branch
was already fetched.

Therefore, die early when the working directory is dirty.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-pull.sh     |    5 +++++
 t/t5520-pull.sh |   18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index bf0c298..9a9e764 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -107,6 +107,11 @@ error_on_no_merge_candidates () {
 }
 
 test true = "$rebase" && {
+	git update-index --refresh &&
+	git diff-files --quiet &&
+        git diff-index --cached --quiet HEAD -- ||
+	die "refusing to pull with rebase: your working tree is not up-to-date"
+
 	. git-parse-remote &&
 	origin="$1"
 	test -z "$origin" && origin=$(get_default_remote)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 9484129..997b2db 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -92,4 +92,22 @@ test_expect_success '--rebase with rebased upstream' '
 
 '
 
+test_expect_success 'pull --rebase dies early with dirty working directory' '
+
+	git update-ref refs/remotes/me/copy copy^ &&
+	COPY=$(git rev-parse --verify me/copy) &&
+	git rebase --onto $COPY copy &&
+	git config branch.to-rebase.remote me &&
+	git config branch.to-rebase.merge refs/heads/copy &&
+	git config branch.to-rebase.rebase true &&
+	echo dirty >> file &&
+	git add file &&
+	test_must_fail git pull &&
+	test $COPY = $(git rev-parse --verify me/copy) &&
+	git checkout HEAD -- file &&
+	git pull &&
+	test $COPY != $(git rev-parse --verify me/copy)
+
+'
+
 test_done
-- 
1.5.5.1.497.ga63a5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pull --rebase: exit early when the working directory is dirty
  2008-05-21 11:32 [PATCH] pull --rebase: exit early when the working directory is dirty Johannes Schindelin
@ 2008-05-21 12:04 ` Andreas Ericsson
  2008-05-21 13:31 ` Jan Krüger
  2008-05-21 15:11 ` Geert Bosch
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Ericsson @ 2008-05-21 12:04 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster

Johannes Schindelin wrote:
> When rebasing fails during "pull --rebase", you cannot just clean up the
> working directory and call "pull --rebase" again, since the remote branch
> was already fetched.
> 
> Therefore, die early when the working directory is dirty.


Funny stuff. I helped a co-worker with just exactly this issue less than
ten minutes ago, so, fwiw:
Liked-by: Andreas Ericsson <ae@op5.se>

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pull --rebase: exit early when the working directory is dirty
  2008-05-21 11:32 [PATCH] pull --rebase: exit early when the working directory is dirty Johannes Schindelin
  2008-05-21 12:04 ` Andreas Ericsson
@ 2008-05-21 13:31 ` Jan Krüger
  2008-05-21 15:11 ` Geert Bosch
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Krüger @ 2008-05-21 13:31 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster

Hi,

> When rebasing fails during "pull --rebase", you cannot just clean up
> the working directory and call "pull --rebase" again, since the
> remote branch was already fetched.
> 
> Therefore, die early when the working directory is dirty.

Good idea.

> +	git update-index --refresh &&
> +	git diff-files --quiet &&
> +        git diff-index --cached --quiet HEAD -- ||
> +	die "refusing to pull with rebase: your working tree is not
> up-to-date"

Perhaps the "up-to-date" should be changed to something else, following
the recent discussion about the "up-to-date" message in checkout (but
here we don't have to worry about breaking anything else). In that case,
I'd suggest:

"Refusing to pull with rebase: your working tree has uncommitted
changes"

-- 
Best regards
Jan Krüger <jk@jk.gs>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pull --rebase: exit early when the working directory is dirty
  2008-05-21 11:32 [PATCH] pull --rebase: exit early when the working directory is dirty Johannes Schindelin
  2008-05-21 12:04 ` Andreas Ericsson
  2008-05-21 13:31 ` Jan Krüger
@ 2008-05-21 15:11 ` Geert Bosch
  2 siblings, 0 replies; 4+ messages in thread
From: Geert Bosch @ 2008-05-21 15:11 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster


On May 21, 2008, at 07:32, Johannes Schindelin wrote:
> When rebasing fails during "pull --rebase", you cannot just clean up  
> the
> working directory and call "pull --rebase" again, since the remote  
> branch
> was already fetched.
>
> Therefore, die early when the working directory is dirty.
Much nicer indeed to die early on errors, as we also can
generally give better error messages.
> +	die "refusing to pull with rebase: your working tree is not up-to- 
> date"

I thought we'd prefer saying:
               "refusing to pull with rebase: your working tree has  
local changes"

   -Geert

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-21 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21 11:32 [PATCH] pull --rebase: exit early when the working directory is dirty Johannes Schindelin
2008-05-21 12:04 ` Andreas Ericsson
2008-05-21 13:31 ` Jan Krüger
2008-05-21 15:11 ` Geert Bosch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).