git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] Make the rebase edit mode really end up in an edit state
@ 2009-01-15  0:27 Anders Melchiorsen
  2009-01-15  0:43 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 55+ messages in thread
From: Anders Melchiorsen @ 2009-01-15  0:27 UTC (permalink / raw)
  To: git; +Cc: gitster, Johannes.Schindelin

Previously, the interactive rebase edit mode placed the user after the
commit in question. That was awkward because a commit is supposedly
immutable. Thus, she was forced to use "git commit --amend" for her
changes.

To improve on this UI, we now issue "git reset --soft HEAD^" before
exiting to the user. This puts the changes in the index, editable in
the Git sense. It also makes sure that a pre-filled editor is fired up
when doing "git rebase --continue", in case the user just wanted to
fix the commit message.

The revised UI is close to the situation in a merge/rebase conflict,
and thus familiar to the user.

Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---


I always have a hard time figuring out what to do during an
interactive rebase. Recently, it dawned on me that the reason is that
I have to do different things: one thing when editing on purpose, and
a different thing when resolving a conflict. So my fingers never learn.

With this change, I propose to make the UI more uniform. I think that
the new way is more intuitive, too, if you will agree that a Git UI
can be intuitive.

As I expect this to not be acceptable due to compatibility concerns, I
have not tested it much. The patch is mostly to catch some attention,
but I will be happy to complete it if there is interest in the change.

It was surprising for me to find the needed code already present. Now
I know that I do not have to do "git commit --amend", it will happen
automatically if I add some files. That trick alone is worth the time
that I have spent on this :-).


Cheers,
Anders.


 Documentation/git-rebase.txt |   10 ++++------
 git-rebase--interactive.sh   |   29 ++++++++---------------------
 2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 32f0f12..3442a68 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -320,9 +320,8 @@ not look at them but at the commit names ("deadbee" and "fa1afe1" in this
 example), so do not delete or edit the names.
 
 By replacing the command "pick" with the command "edit", you can tell
-'git-rebase' to stop after applying that commit, so that you can edit
-the files and/or the commit message, amend the commit, and continue
-rebasing.
+'git-rebase' to stop after applying that commit. You are free to make
+further modifications before you continue rebasing.
 
 If you want to fold two or more commits into one, replace the command
 "pick" with "squash" for the second and subsequent commit.  If the
@@ -375,9 +374,8 @@ add other commits.  This can be used to split a commit into two:
 
 - Mark the commit you want to split with the action "edit".
 
-- When it comes to editing that commit, execute `git reset HEAD^`.  The
-  effect is that the HEAD is rewound by one, and the index follows suit.
-  However, the working tree stays the same.
+- When it comes to editing that commit, execute `git reset`.  The effect
+  is that the changes in the commit are now only in the working tree.
 
 - Now add the changes to the index that you want to have in the first
   commit.  You can use `git add` (possibly interactively) or
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index bdec43c..0fe678f 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -274,7 +274,7 @@ peek_next_command () {
 
 do_next () {
 	rm -f "$DOTEST"/message "$DOTEST"/author-script \
-		"$DOTEST"/amend || exit
+		|| exit
 	read command sha1 rest < "$TODO"
 	case "$command" in
 	'#'*|'')
@@ -294,13 +294,13 @@ do_next () {
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
 		make_patch $sha1
-		git rev-parse --verify HEAD > "$DOTEST"/amend
+		git reset --soft HEAD^ ||
+			die "Cannot rewind the HEAD"
 		warn "Stopped at $sha1... $rest"
-		warn "You can amend the commit now, with"
 		warn
-		warn "	git commit --amend"
-		warn
-		warn "Once you are satisfied with your changes, run"
+		warn "You can edit the commit now. When you are satisfied,"
+		warn "mark the corrected paths with 'git add <paths>', and"
+		warn "then run"
 		warn
 		warn "	git rebase --continue"
 		warn
@@ -442,22 +442,9 @@ do
 		else
 			. "$DOTEST"/author-script ||
 				die "Cannot find the author identity"
-			amend=
-			if test -f "$DOTEST"/amend
-			then
-				amend=$(git rev-parse --verify HEAD)
-				test "$amend" = $(cat "$DOTEST"/amend) ||
-				die "\
-You have uncommitted changes in your working tree. Please, commit them
-first and then run 'git rebase --continue' again."
-				git reset --soft HEAD^ ||
-				die "Cannot rewind the HEAD"
-			fi
 			export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
-			git commit --no-verify -F "$DOTEST"/message -e || {
-				test -n "$amend" && git reset --soft $amend
+			git commit --no-verify -F "$DOTEST"/message -e ||
 				die "Could not commit staged changes."
-			}
 		fi
 
 		require_clean_work_tree
@@ -590,7 +577,7 @@ first and then run 'git rebase --continue' again."
 #
 # Commands:
 #  p, pick = use commit
-#  e, edit = use commit, but stop for amending
+#  e, edit = use commit, but stop for editing
 #  s, squash = use commit, but meld into previous commit
 #
 # If you remove a line here THAT COMMIT WILL BE LOST.
-- 
1.6.0.2.514.g23abd3

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

end of thread, other threads:[~2009-01-18  1:25 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15  0:27 [RFC PATCH] Make the rebase edit mode really end up in an edit state Anders Melchiorsen
2009-01-15  0:43 ` Junio C Hamano
2009-01-15  2:49   ` Boyd Stephen Smith Jr.
2009-01-15  4:10     ` Miles Bader
2009-01-15  5:00       ` Boyd Stephen Smith Jr.
2009-01-15  6:13       ` Junio C Hamano
2009-01-15 12:24       ` Johannes Schindelin
2009-01-15 15:35   ` SZEDER Gábor
2009-01-15 22:09     ` Junio C Hamano
2009-01-15 22:20       ` Sverre Rabbelier
2009-01-15 22:59         ` SZEDER Gábor
2009-01-16  0:11           ` Björn Steinbrink
2009-01-16  1:34             ` Johannes Schindelin
2009-01-18  1:24             ` Anders Melchiorsen
2009-01-16  1:09           ` Junio C Hamano
2009-01-16 12:10             ` Johannes Schindelin
2009-01-15  0:49 ` Stephan Beyer
2009-01-15  0:53 ` Johannes Schindelin
2009-01-15  7:35   ` Johannes Sixt
2009-01-15 10:01     ` Johan Herland
2009-01-15 11:52       ` Sverre Rabbelier
2009-01-15 12:36         ` Johannes Schindelin
2009-01-15 12:44           ` Adeodato Simó
2009-01-15 13:41             ` Johannes Schindelin
2009-01-15 13:41               ` Sverre Rabbelier
2009-01-15 13:57                 ` Stephan Beyer
2009-01-15 14:02                   ` Johannes Schindelin
2009-01-15 13:43               ` Adeodato Simó
2009-01-15 12:45           ` Sverre Rabbelier
2009-01-15 13:42             ` Johannes Schindelin
2009-01-15 13:56               ` Sverre Rabbelier
2009-01-15 16:59             ` Junio C Hamano
2009-01-15 17:16               ` Sverre Rabbelier
2009-01-15 18:21               ` Johannes Schindelin
2009-01-15 18:46                 ` Johan Herland
2009-01-15 18:53                   ` Anders Melchiorsen
2009-01-15 19:28                     ` Johannes Schindelin
2009-01-15 19:27                   ` Wincent Colaiuta
2009-01-15 20:26                     ` Jay Soffian
2009-01-15 21:58                       ` Wincent Colaiuta
2009-01-16  9:50                       ` Johan Herland
2009-01-16 10:27                         ` Anders Melchiorsen
2009-01-16 10:58                           ` Johan Herland
2009-01-16 12:42                             ` SZEDER Gábor
2009-01-16 12:57                               ` Johannes Schindelin
2009-01-16 13:27                                 ` SZEDER Gábor
2009-01-16 14:28                                   ` Wincent Colaiuta
2009-01-16 13:12                         ` Sverre Rabbelier
2009-01-16 17:26                           ` Stephan Beyer
2009-01-16 21:06                             ` Johannes Schindelin
2009-01-15 12:52           ` Pieter de Bie
2009-01-15 12:55             ` Sverre Rabbelier
2009-01-15 12:57           ` Pieter de Bie
2009-01-15 13:46             ` Björn Steinbrink
2009-01-15 13:54         ` Johan Herland

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