git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase
@ 2007-07-08  2:01 Johannes Schindelin
  2007-07-08  4:40 ` Johannes Schindelin
  2007-07-12 22:26 ` Alex Riesen
  0 siblings, 2 replies; 9+ messages in thread
From: Johannes Schindelin @ 2007-07-08  2:01 UTC (permalink / raw)
  To: git, gitster


Non-interactive rebase requires the working tree to be clean, but
applies what is in the index without requiring the user to do it
herself.  Imitate that, but (since we are interactive, after all)
fire up an editor with the commit message.

It also fixes a subtle bug: a forgotten "continue" was removed, which
led to an infinite loop when continuing without remaining patches.

Both issues noticed by Frank Lichtenheld.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-rebase--interactive.sh    |   25 ++++++++++++++++---------
 t/t3404-rebase-interactive.sh |   16 +++++++++++++++-
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 0c2a969..67f2ee2 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -59,6 +59,10 @@ make_patch () {
 }
 
 die_with_patch () {
+	test -f "$DOTEST"/message ||
+		git cat-file commit $sha1 | sed "1,/^$/d" > "$DOTEST"/message
+	test -f "$DOTEST"/author-script ||
+		get_author_ident_from_commit $sha1 > "$DOTEST"/author-script
 	make_patch "$1"
 	die "$2"
 }
@@ -140,10 +144,7 @@ pick_one_preserving_merges () {
 			if ! git merge $STRATEGY -m "$msg" $new_parents
 			then
 				echo "$msg" > "$GIT_DIR"/MERGE_MSG
-				warn Error redoing merge $sha1
-				warn
-				warn After fixup, please use
-				die "$author_script git commit"
+				die Error redoing merge $sha1
 			fi
 			;;
 		*)
@@ -154,11 +155,12 @@ pick_one_preserving_merges () {
 }
 
 do_next () {
+	test -f "$DOTEST"/message && rm "$DOTEST"/message
+	test -f "$DOTEST"/author-script && rm "$DOTEST"/author-script
 	read command sha1 rest < "$TODO"
 	case "$command" in
 	\#|'')
 		mark_action_done
-		continue
 		;;
 	pick)
 		comment_for_reflog pick
@@ -201,6 +203,7 @@ do_next () {
 		git cat-file commit $sha1 | sed -e '1,/^$/d' >> "$MSG"
 		git reset --soft HEAD^
 		author_script=$(get_author_ident_from_commit $sha1)
+		echo "$author_script" > "$DOTEST"/author-script
 		case $failed in
 		f)
 			# This is like --amend, but with a different message
@@ -212,10 +215,6 @@ do_next () {
 			cp "$MSG" "$GIT_DIR"/MERGE_MSG
 			warn
 			warn "Could not apply $sha1... $rest"
-			warn "After you fixed that, commit the result with"
-			warn
-			warn "  $(echo $author_script | tr '\012' ' ') \\"
-			warn "	  git commit -F \"$GIT_DIR\"/MERGE_MSG -e"
 			die_with_patch $sha1 ""
 		esac
 		;;
@@ -265,6 +264,14 @@ do
 
 		test -d "$DOTEST" || die "No interactive rebase running"
 
+		# commit if necessary
+		git rev-parse --verify HEAD > /dev/null &&
+		git update-index --refresh &&
+		git diff-files --quiet &&
+		! git diff-index --cached --quiet HEAD &&
+		. "$DOTEST"/author-script &&
+		git commit -F "$DOTEST"/message -e
+
 		require_clean_work_tree
 		do_rest
 		;;
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 883cf29..c251336 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -63,7 +63,10 @@ test_expect_success 'setup' '
 
 cat > fake-editor.sh << EOF
 #!/bin/sh
-test "\$1" = .git/COMMIT_EDITMSG && exit
+test "\$1" = .git/COMMIT_EDITMSG && {
+	test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1"
+	exit
+}
 test -z "\$FAKE_LINES" && exit
 grep -v "^#" < "\$1" > "\$1".tmp
 rm "\$1"
@@ -181,6 +184,7 @@ test_expect_success 'preserve merges with -p' '
 	echo C > file1 &&
 	test_tick &&
 	git commit -m K file1 &&
+	test_tick &&
 	git rebase -i -p --onto branch1 master &&
 	test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) &&
 	test $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&
@@ -188,4 +192,14 @@ test_expect_success 'preserve merges with -p' '
 	test $(git show HEAD~2:file1) = B
 '
 
+test_expect_success '--continue tries to commit' '
+	test_tick &&
+	! git rebase -i --onto new-branch1 HEAD^ &&
+	echo resolved > file1 &&
+	git add file1 &&
+	FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
+	test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) &&
+	git show HEAD | grep chouette
+'
+
 test_done
-- 
1.5.3.rc0.2712.g125b7f

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

* Re: [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase
  2007-07-08  2:01 [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase Johannes Schindelin
@ 2007-07-08  4:40 ` Johannes Schindelin
  2007-07-12 22:26 ` Alex Riesen
  1 sibling, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2007-07-08  4:40 UTC (permalink / raw)
  To: git, gitster

Hi,

On Sun, 8 Jul 2007, Johannes Schindelin wrote:

> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 0c2a969..67f2ee2 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
>
> [...]
>
> @@ -265,6 +264,14 @@ do
>  
>  		test -d "$DOTEST" || die "No interactive rebase running"
>  
> +		# commit if necessary
> +		git rev-parse --verify HEAD > /dev/null &&
> +		git update-index --refresh &&
> +		git diff-files --quiet &&
> +		! git diff-index --cached --quiet HEAD &&
> +		. "$DOTEST"/author-script &&
> +		git commit -F "$DOTEST"/message -e
> +

Oh well. For this to work, there has to be a line

		export GIT_AUTHOR_NAME GIT_AUTHOR_NAME GIT_AUTHOR_DATE &&

before the "git commit" line, I think.

Ciao,
Dscho

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

* Re: [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase
  2007-07-08  2:01 [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase Johannes Schindelin
  2007-07-08  4:40 ` Johannes Schindelin
@ 2007-07-12 22:26 ` Alex Riesen
  2007-08-01 15:57   ` Johannes Schindelin
  1 sibling, 1 reply; 9+ messages in thread
From: Alex Riesen @ 2007-07-12 22:26 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster

Johannes Schindelin, Sun, Jul 08, 2007 04:01:29 +0200:
> Non-interactive rebase requires the working tree to be clean, but
> applies what is in the index without requiring the user to do it
> herself.  Imitate that, but (since we are interactive, after all)
> fire up an editor with the commit message.

Could we also have "git rebase <base> <branch>"?
I find it useful when I have many branches to rebase:

    ~/project @master$ git rebase master branch1
    ~/project @branch1$ git rebase master branch2
    ~/project @branch2$ git rebase master branch3
    ...

Otherwise one have to, for example, "git checkout branch1" first,
and only then run rebase-interactive. Checkout is not very pleasant
operation on windows if you have many files (well, nothing is pleasant
there, but this one have to be done often). Rebase-interactive is
*very* slow there, but I just could not part with it after having
tried it once :)

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

* Re: [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase
  2007-07-12 22:26 ` Alex Riesen
@ 2007-08-01 15:57   ` Johannes Schindelin
  2007-08-01 21:45     ` Alex Riesen
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2007-08-01 15:57 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git, gitster

Hi,

On Fri, 13 Jul 2007, Alex Riesen wrote:

> Johannes Schindelin, Sun, Jul 08, 2007 04:01:29 +0200:
> > Non-interactive rebase requires the working tree to be clean, but
> > applies what is in the index without requiring the user to do it
> > herself.  Imitate that, but (since we are interactive, after all)
> > fire up an editor with the commit message.
> 
> Could we also have "git rebase <base> <branch>"?

Don't we do that already?  AFAICT it is already in the synopsis, ever 
since rebase -i was introduced into the "next" branch, on June 25...

Ciao,
Dscho

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

* Re: [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase
  2007-08-01 15:57   ` Johannes Schindelin
@ 2007-08-01 21:45     ` Alex Riesen
  2007-08-01 22:31       ` [PATCH] rebase -i: fix for optional [branch] parameter Johannes Schindelin
  2007-08-01 22:32       ` [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base Alex Riesen
  0 siblings, 2 replies; 9+ messages in thread
From: Alex Riesen @ 2007-08-01 21:45 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster

Johannes Schindelin, Wed, Aug 01, 2007 17:57:25 +0200:
> On Fri, 13 Jul 2007, Alex Riesen wrote:
> > Johannes Schindelin, Sun, Jul 08, 2007 04:01:29 +0200:
> > > Non-interactive rebase requires the working tree to be clean, but
> > > applies what is in the index without requiring the user to do it
> > > herself.  Imitate that, but (since we are interactive, after all)
> > > fire up an editor with the commit message.
> > 
> > Could we also have "git rebase <base> <branch>"?
> 
> Don't we do that already?  AFAICT it is already in the synopsis, ever 
> since rebase -i was introduced into the "next" branch, on June 25...
> 

Err... "git rebase -i <base> <branch>"

Does not work, just checked:

    $ git rebase -i base branch
    /usr/local/bin/git-rebase--interactive: 482: cannot create /home/user/projects/tmp/.git/.dotest-merge/output: Directory nonexistent
    cat: /home/user/projects/tmp/.git/.dotest-merge/output: No such file or directory
    Invalid branchname: branch

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

* [PATCH] rebase -i: fix for optional [branch] parameter
  2007-08-01 21:45     ` Alex Riesen
@ 2007-08-01 22:31       ` Johannes Schindelin
  2007-08-01 22:32       ` [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base Alex Riesen
  1 sibling, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2007-08-01 22:31 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git, gitster


When calling "git rebase -i <upstream> <branch>", git should switch
to <branch> first.  This worked before, but I broke it by my
"Shut git rebase -i up" patch.

Fix that, and add a test to make sure that it does not break again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Wed, 1 Aug 2007, Alex Riesen wrote:

	> Johannes Schindelin, Wed, Aug 01, 2007 17:57:25 +0200:
	> > On Fri, 13 Jul 2007, Alex Riesen wrote:
	> >
	> > > Could we also have "git rebase <base> <branch>"?
	> > 
	> > Don't we do that already?  AFAICT it is already in the 
	> > synopsis, ever since rebase -i was introduced into the "next" 
	> > branch, on June 25...
	> > 
	> 
	> Err... "git rebase -i <base> <branch>"
	> 
	> Does not work, just checked:
	> 
	>     $ git rebase -i base branch
	>     /usr/local/bin/git-rebase--interactive: 482: cannot create /home/user/projects/tmp/.git/.dotest-merge/output: Directory nonexistent
	>     cat: /home/user/projects/tmp/.git/.dotest-merge/output: No such file or directory
	>     Invalid branchname: branch

	Sorry...

 git-rebase--interactive.sh    |    2 +-
 t/t3404-rebase-interactive.sh |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d3addd4..bdec462 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -405,6 +405,7 @@ do
 
 		require_clean_work_tree
 
+		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 		if test ! -z "$2"
 		then
 			output git show-ref --verify --quiet "refs/heads/$2" ||
@@ -418,7 +419,6 @@ do
 
 		test -z "$ONTO" && ONTO=$UPSTREAM
 
-		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 		: > "$DOTEST"/interactive || die "Could not mark as interactive"
 		git symbolic-ref HEAD > "$DOTEST"/head-name ||
 			die "Could not get HEAD"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index dc436d7..a9b552f 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -98,6 +98,14 @@ test_expect_success 'no changes are a nop' '
 	test $(git rev-parse I) = $(git rev-parse HEAD)
 '
 
+test_expect_success 'test the [branch] option' '
+	git checkout -b dead-end &&
+	git rm file6 &&
+	git commit -m "stop here" &&
+	git rebase -i F branch2 &&
+	test $(git rev-parse I) = $(git rev-parse HEAD)
+'
+
 test_expect_success 'rebase on top of a non-conflicting commit' '
 	git checkout branch1 &&
 	git tag original-branch1 &&
-- 
1.5.3.rc3.112.gf60b6

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

* [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base
  2007-08-01 21:45     ` Alex Riesen
  2007-08-01 22:31       ` [PATCH] rebase -i: fix for optional [branch] parameter Johannes Schindelin
@ 2007-08-01 22:32       ` Alex Riesen
  2007-08-01 22:36         ` Johannes Schindelin
  1 sibling, 1 reply; 9+ messages in thread
From: Alex Riesen @ 2007-08-01 22:32 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Junio C Hamano

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 git-rebase--interactive.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Alex Riesen, Wed, Aug 01, 2007 23:45:56 +0200:
>     $ git rebase -i base branch
>     /usr/local/bin/git-rebase--interactive: 482: cannot create /home/user/projects/tmp/.git/.dotest-merge/output: Directory nonexistent
>     cat: /home/user/projects/tmp/.git/.dotest-merge/output: No such file or directory
>     Invalid branchname: branch

Oh... Sometimes I can *very* slow. I believe it is as simple as that

 git-rebase--interactive.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 061cd0a..b42dee8 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -404,6 +404,7 @@ do
 		esac
 
 		require_clean_work_tree
+		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 
 		if test ! -z "$2"
 		then
@@ -418,7 +419,6 @@ do
 
 		test -z "$ONTO" && ONTO=$UPSTREAM
 
-		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 		: > "$DOTEST"/interactive || die "Could not mark as interactive"
 		git symbolic-ref HEAD > "$DOTEST"/head-name ||
 			die "Could not get HEAD"
-- 
1.5.3.rc3.123.ge9877

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

* Re: [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base
  2007-08-01 22:32       ` [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base Alex Riesen
@ 2007-08-01 22:36         ` Johannes Schindelin
  2007-08-01 22:40           ` Alex Riesen
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2007-08-01 22:36 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git, Junio C Hamano

Hi,

On Thu, 2 Aug 2007, Alex Riesen wrote:

> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 061cd0a..b42dee8 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -404,6 +404,7 @@ do
>  		esac
>  
>  		require_clean_work_tree
> +		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
>  
>  		if test ! -z "$2"
>  		then
> @@ -418,7 +419,6 @@ do
>  
>  		test -z "$ONTO" && ONTO=$UPSTREAM
>  
> -		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
>  		: > "$DOTEST"/interactive || die "Could not mark as interactive"
>  		git symbolic-ref HEAD > "$DOTEST"/head-name ||
>  			die "Could not get HEAD"

Heh.  I take that as an ACK from you to my patch?  Mine has a test case, 
too ;-)

Ciao,
Dscho

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

* Re: [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base
  2007-08-01 22:36         ` Johannes Schindelin
@ 2007-08-01 22:40           ` Alex Riesen
  0 siblings, 0 replies; 9+ messages in thread
From: Alex Riesen @ 2007-08-01 22:40 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Junio C Hamano

Johannes Schindelin, Thu, Aug 02, 2007 00:36:58 +0200:
> On Thu, 2 Aug 2007, Alex Riesen wrote:
> >  		require_clean_work_tree
> > +		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
> 
> Heh.  I take that as an ACK from you to my patch?  Mine has a test case, 
> too ;-)

ACK, indeed 8)

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

end of thread, other threads:[~2007-08-01 22:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-08  2:01 [PATCH 1/3] rebase -i: handle --continue more like non-interactive rebase Johannes Schindelin
2007-07-08  4:40 ` Johannes Schindelin
2007-07-12 22:26 ` Alex Riesen
2007-08-01 15:57   ` Johannes Schindelin
2007-08-01 21:45     ` Alex Riesen
2007-08-01 22:31       ` [PATCH] rebase -i: fix for optional [branch] parameter Johannes Schindelin
2007-08-01 22:32       ` [PATCH] Fix rebase interactive to allow specifying branch to rebase along with the base Alex Riesen
2007-08-01 22:36         ` Johannes Schindelin
2007-08-01 22:40           ` Alex Riesen

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