git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix git rebase --continue to work with touched files
@ 2010-07-27 10:06 David D. Kilzer
  2010-07-27 10:16 ` Johannes Schindelin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David D. Kilzer @ 2010-07-27 10:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, David D. Kilzer

When performing a non-interactive rebase, sometimes
"git rebase --continue" will fail if an unmodified file is
touched in the working directory:

    You must edit all merge conflicts and then
    mark them as resolved using git add

This is caused by "git diff-files" reporting a difference
between the index and the filesystem:

    :100644 100644 d00491...... 000000...... M	file

The fix is to run "git update-index --refresh" before
"git diff-files" as is done in git-rebase--interactive.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
---
The reason for the while loop in the test is that this bug only
reproduces about half of the time on my Mac Pro with Mac OS X
10.6.4.  I used 4 loops to make sure the test fails without the
fix.

I also put the test in a separate file since t3400-rebase.sh
changed a lot in e877a4c, and to make it clear what is required
to reproduce the bug.

 git-rebase.sh              |    1 +
 t/t3418-rebase-continue.sh |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
 create mode 100755 t/t3418-rebase-continue.sh

diff --git a/git-rebase.sh b/git-rebase.sh
index ab4afa7..2d88742 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -208,6 +208,7 @@ do
 		test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
 			die "No rebase in progress?"
 
+		git update-index --ignore-submodules --refresh &&
 		git diff-files --quiet --ignore-submodules || {
 			echo "You must edit all merge conflicts and then"
 			echo "mark them as resolved using git add"
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
new file mode 100755
index 0000000..435560c
--- /dev/null
+++ b/t/t3418-rebase-continue.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+test_description='git rebase --continue should work with touched files'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	echo 1 >F1 &&
+	git add F1 &&
+	git commit -m "commit: new file F1" &&
+
+	echo 2 >F2 &&
+	git add F2 &&
+	git commit -m "commit: new file F2" &&
+
+	git checkout -b topic HEAD^ &&
+
+	echo 22 > F2 &&
+	git add F2 &&
+	git commit -m "commit: new file F2 on topic branch" &&
+
+	git checkout master
+'
+
+
+test_expect_success 'rebase --continue works with touched file' '
+	count=1
+	while test "$count" -le 4
+	do
+		git branch topic$count topic &&
+		test_must_fail git rebase --onto master master topic$count &&
+		echo "Resolved" >F2 &&
+		git add F2 &&
+		touch F1 &&
+		git rebase --continue || exit 1
+		count=$(($count + 1))
+	done
+'
+
+test_done
-- 
1.7.1.1.36.g07b1c

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

* Re: [PATCH] Fix git rebase --continue to work with touched files
  2010-07-27 10:06 [PATCH] Fix git rebase --continue to work with touched files David D. Kilzer
@ 2010-07-27 10:16 ` Johannes Schindelin
  2010-07-27 10:20 ` Ævar Arnfjörð Bjarmason
  2010-07-27 19:53 ` Johannes Sixt
  2 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2010-07-27 10:16 UTC (permalink / raw)
  To: David D. Kilzer; +Cc: git

Hi,

On Tue, 27 Jul 2010, David D. Kilzer wrote:

> When performing a non-interactive rebase, sometimes
> "git rebase --continue" will fail if an unmodified file is
> touched in the working directory:
> 
>     You must edit all merge conflicts and then
>     mark them as resolved using git add
> 
> This is caused by "git diff-files" reporting a difference
> between the index and the filesystem:
> 
>     :100644 100644 d00491...... 000000...... M	file
> 
> The fix is to run "git update-index --refresh" before
> "git diff-files" as is done in git-rebase--interactive.
> 
> Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>

ACK!

... and thanks!
Dscho

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

* Re: [PATCH] Fix git rebase --continue to work with touched files
  2010-07-27 10:06 [PATCH] Fix git rebase --continue to work with touched files David D. Kilzer
  2010-07-27 10:16 ` Johannes Schindelin
@ 2010-07-27 10:20 ` Ævar Arnfjörð Bjarmason
  2010-07-27 19:53 ` Johannes Sixt
  2 siblings, 0 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-07-27 10:20 UTC (permalink / raw)
  To: David D. Kilzer; +Cc: git, Johannes Schindelin

On Tue, Jul 27, 2010 at 10:06, David D. Kilzer <ddkilzer@kilzer.net> wrote:
> +test_expect_success 'setup' '
> +       echo 1 >F1 &&
> +       git add F1 &&
> +       git commit -m "commit: new file F1" &&
> +
> +       echo 2 >F2 &&
> +       git add F2 &&
> +       git commit -m "commit: new file F2" &&

Use test_commit for these:

    test_commit "commit: new file F1" F1 1 &&
    test_commit "commit: new file F2" F2 2 &&
    ...

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

* Re: [PATCH] Fix git rebase --continue to work with touched files
  2010-07-27 10:06 [PATCH] Fix git rebase --continue to work with touched files David D. Kilzer
  2010-07-27 10:16 ` Johannes Schindelin
  2010-07-27 10:20 ` Ævar Arnfjörð Bjarmason
@ 2010-07-27 19:53 ` Johannes Sixt
  2010-07-27 21:29   ` David D. Kilzer
  2 siblings, 1 reply; 5+ messages in thread
From: Johannes Sixt @ 2010-07-27 19:53 UTC (permalink / raw)
  To: David D. Kilzer; +Cc: git, Johannes Schindelin

On Dienstag, 27. Juli 2010, David D. Kilzer wrote:
> +test_expect_success 'rebase --continue works with touched file' '
> +	count=1
> +	while test "$count" -le 4
> +	do
> +		git branch topic$count topic &&
> +		test_must_fail git rebase --onto master master topic$count &&
> +		echo "Resolved" >F2 &&
> +		git add F2 &&
> +		touch F1 &&
> +		git rebase --continue || exit 1

exit from a test is a big no-no. But I think you can reproduce the issue 
reliably and get rid of the entire loop if you use test-chmtime instead of 
touch:

		test-chmtime =-60 F1 &&

i.e. set the modification time back one minute.

> +		count=$(($count + 1))
> +	done
> +'
> +
> +test_done

-- Hannes

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

* Re: [PATCH] Fix git rebase --continue to work with touched files
  2010-07-27 19:53 ` Johannes Sixt
@ 2010-07-27 21:29   ` David D. Kilzer
  0 siblings, 0 replies; 5+ messages in thread
From: David D. Kilzer @ 2010-07-27 21:29 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Johannes Schindelin

On Tue, July 27, 2010 at 12:53:36 PM, Johannes Sixt wrote:
 
> On Dienstag, 27. Juli 2010, David D. Kilzer wrote:
> > +test_expect_success  'rebase --continue works with touched file' '
> > +     count=1
> > +    while test "$count" -le 4
> >  +    do
> > +        git branch  topic$count topic &&
> > +         test_must_fail git rebase --onto master master topic$count &&
> >  +        echo "Resolved" >F2 &&
> >  +        git add F2 &&
> >  +        touch F1 &&
> >  +        git rebase --continue || exit  1
> 
> exit from a test is a big no-no. But I think you can reproduce the  issue 
> reliably and get rid of the entire loop if you use test-chmtime  instead of 
> touch:
> 
>         test-chmtime  =-60 F1 &&
> 
> i.e. set the modification time back one  minute.


That works great!  Thanks!

Dave

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

end of thread, other threads:[~2010-07-27 21:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27 10:06 [PATCH] Fix git rebase --continue to work with touched files David D. Kilzer
2010-07-27 10:16 ` Johannes Schindelin
2010-07-27 10:20 ` Ævar Arnfjörð Bjarmason
2010-07-27 19:53 ` Johannes Sixt
2010-07-27 21:29   ` David D. Kilzer

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).