git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 9, 2010, 14:36 UTC
Message-ID
<20101109143601.GB18960@burratino>
In-Reply-To
<AANLkTi=2q1-1zmR=JquN75DP9sGGuPVkAu4mVs1U9DZo@mail.gmail.com>
Sverre Rabbelier wrote:
> And then here you smash my hopes that you were suggesting we stop
> asking the user to mess around in the .git directory :(. After all, if
> we let that rm be handled by some 'git rebase' mode, it could also
> unlock any branches it has locked.

Well, I think that is worth doing, too. It's just that it's hard to change existing practices and much easier to change the tools to keep supporting them.

I don't think the manual advertises .git/rebase-merge anywhere. I have witnessed people succumbing to the temptation to delete it when another rebase fails.

Maybe "git rebase" should have a --override-rebase-in-progress option? The following is simpler, sort of imitating the "git bisect reset" command. With it applied, if you do

	git rebase --abort HEAD

then the rebase will abort without changing the current HEAD (yes, I know this interface is stupid; please feel free to pick it up and do better).

Other practices worth abstracting away:
	- Reading .git/rebase-merge/patch and
	  .git/rebase-merge/message when a patch had conflicts
	- Checking for the existence of .git/rebase-merge in $PS1
	  prompt
	- Tweaking .git/rebase-merge/todo to reflect a change of plan
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 30e5c0e..3a587a1 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -227,6 +227,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
 --abort::
 	Restore the original branch and abort the rebase operation.
 
+--abort HEAD::
+	Abort the rebase operation, without changing the current branch.
+
 --skip::
 	Restart the rebasing process by skipping the current patch.
 
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a27952d..2e1c074 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -772,6 +772,14 @@ first and then run 'git rebase --continue' again."
 		do_rest
 		;;
 	--abort)
+		if test "$2" = HEAD
+		then
+			shift
+			is_standalone "$@" || usage
+			get_saved_options
+			rm -rf "$DOTEST"
+			exit
+		fi
 		is_standalone "$@" || usage
 		get_saved_options
 		comment_for_reflog abort
diff --git a/git-rebase.sh b/git-rebase.sh
index e5df23b..0f88a00 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -273,6 +273,11 @@ do
 		test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
 			die "No rebase in progress?"
 
+		if test "$2" = HEAD
+		then
+			rm -r "$dotest"
+			exit
+		fi
 		git rerere clear
 		if test -d "$dotest"
 		then
Previous: Sverre RabbelierNext: Nguyen Thai Ngoc Duy
Message 8 of 12 in “commit: do not switch branch during a rebase unless -f is given”
  1. commit: do not switch branch during a rebase unless -f is givenNguyễn Thái Ngọc Duy, Sep 28, 2010
  2. checkout: do not switch branch during a rebase unless -f is givenNguyễn Thái Ngọc Duy, Sep 28, 2010
  3. Jonathan NiederSep 28, 2010
  4. Nguyen Thai Ngoc DuySep 28, 2010
  5. Nguyen Thai Ngoc DuyNov 9, 2010
  6. Jonathan NiederNov 9, 2010
  7. Sverre RabbelierNov 9, 2010
  8. Jonathan NiederNov 9, 2010
  9. Nguyen Thai Ngoc DuyNov 9, 2010
  10. Jonathan NiederNov 9, 2010
  11. Junio C HamanoSep 28, 2010
  12. Sverre RabbelierSep 28, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.