git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Ballard <kevin@sb.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Yann Dirson <dirson@bertin.fr>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Eric Raible <raible@nextest.com>, Kevin Ballard <kevin@sb.org>
Subject: [PATCHv3] git-rebase--interactive.sh: extend "edit" command to be more useful
Date: Wed, 24 Nov 2010 12:19:20 -0800	[thread overview]
Message-ID: <1290629960-60917-1-git-send-email-kevin@sb.org> (raw)
In-Reply-To: <20101110015327.GB1503@burratino>

Extend the "edit" command to simply stop for editing if no sha1 is
given or if the sha1 is equal to "-". This behaves the same as "x false"
but is a bit friendlier for the user.

Signed-off-by: Kevin Ballard <kevin@sb.org>
---

Two changes since the last patch:
* Picked up the extended explanation suggested by Jonathan Nieder.
  I left off the last line about "noop" as that doesn't seem related.
* If the line given is "edit - some comments", emit "some comments" when
  stopped. This is undocumented, so if anyone has any suggestions for how
  it should be documented I'm all ears. I'm also not sure if it should use
  the output format I selected now, or if it should just emit the comment
  in place of the commit summary (e.g. Stopped at $sha1... $comment).

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

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 5934b97..176f735 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -469,12 +469,29 @@ do_next () {
 		comment_for_reflog edit
 
 		mark_action_done
-		pick_one $sha1 ||
-			die_with_patch $sha1 "Could not apply $sha1... $rest"
-		echo "$sha1" > "$DOTEST"/stopped-sha
-		make_patch $sha1
+		comment=''
+		if test -n "$sha1" -a "$sha1" != "-"; then
+			pick_one $sha1 ||
+				die_with_patch $sha1 "Could not apply $sha1... $rest"
+			echo "$sha1" > "$DOTEST"/stopped-sha
+			make_patch $sha1
+		else
+			# we just want to exit to the shell
+			# we don't have a valid $sha1 or $rest, so recreate that
+			# save the original $rest to a comment for later
+			comment="$rest"
+			line=$(git rev-list --pretty=oneline -1 --abbrev-commit --abbrev=7 HEAD)
+			sha1="${line%% *}"
+			rest="${line#* }"
+			echo "$sha1" > "$DOTEST"/stopped-sha
+		fi
 		git rev-parse --verify HEAD > "$AMEND"
 		warn "Stopped at $sha1... $rest"
+		if test -n "$comment"; then
+			warn
+			warn "	$comment"
+			warn
+		fi
 		warn "You can amend the commit now, with"
 		warn
 		warn "	git commit --amend"
@@ -1016,11 +1033,14 @@ first and then run 'git rebase --continue' again."
 # Commands:
 #  p, pick = use commit
 #  r, reword = use commit, but edit the commit message
-#  e, edit = use commit, but stop for amending
+#  e, edit = use commit (if specified), but stop to amend/examine/test
 #  s, squash = use commit, but meld into previous commit
 #  f, fixup = like "squash", but discard this commit's log message
 #  x <cmd>, exec <cmd> = Run a shell command <cmd>, and stop if it fails
 #
+# The argument to edit is optional; if left out or equal to "-",
+# it means to stop to examine or amend the previous commit.
+#
 # If you remove a line here THAT COMMIT WILL BE LOST.
 # However, if you remove everything, the rebase will be aborted.
 #
-- 
1.7.3.2.488.gc5e8

  parent reply	other threads:[~2010-11-24 20:19 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04  5:17 [PATCH] git-rebase--interactive.sh: Add new command "shell" Kevin Ballard
2010-11-04  5:22 ` Kevin Ballard
2010-11-04  8:42 ` Matthieu Moy
2010-11-04  8:53   ` Kevin Ballard
2010-11-04  9:23     ` Ævar Arnfjörð Bjarmason
2010-11-04  9:25       ` Kevin Ballard
2010-11-04  9:27         ` Ævar Arnfjörð Bjarmason
2010-11-04 10:24     ` Johannes Sixt
2010-11-04  9:36 ` Erik Faye-Lund
2010-11-04  9:43   ` Kevin Ballard
2010-11-04 10:25     ` Yann Dirson
2010-11-04 10:40       ` Erik Faye-Lund
2010-11-04 17:04       ` Eric Raible
2010-11-04 17:34         ` Matthieu Moy
2010-11-04 17:43           ` Eric Raible
2010-11-04 18:10           ` Jonathan Nieder
2010-11-04 20:53             ` Yann Dirson
2010-11-04 21:05               ` Eric Raible
2010-11-04 22:01                 ` [PATCHv2] git-rebase--interactive.sh: extend "edit" command to be more useful Kevin Ballard
2010-11-04 21:33               ` [PATCH] git-rebase--interactive.sh: Add new command "shell" Kevin Ballard
2010-11-05  7:33               ` Johannes Sixt
2010-11-05  8:39                 ` Kevin Ballard
2010-11-08 18:31               ` Junio C Hamano
2010-11-08 21:49                 ` Kevin Ballard
2010-11-08 22:29                   ` Yann Dirson
2010-11-10  1:42                     ` Jonathan Nieder
2010-11-10  1:46                       ` Kevin Ballard
2010-11-10  1:56                         ` Jonathan Nieder
2010-11-10  7:43                       ` Yann Dirson
2010-11-10 16:00                         ` Matthieu Moy
2010-11-10  1:53                 ` Jonathan Nieder
2010-11-10  2:14                   ` Kevin Ballard
2010-11-24 20:19                   ` Kevin Ballard [this message]
2010-12-03  8:06                     ` [PATCHv3] git-rebase--interactive.sh: extend "edit" command to be more useful Jonathan Nieder
2010-12-03  8:16                       ` Kevin Ballard
2010-12-03  8:55                         ` Jonathan Nieder
2010-12-03  9:55                       ` Johannes Sixt
2010-12-03 10:00                         ` Jonathan Nieder
2010-12-03 10:14                           ` Kevin Ballard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290629960-60917-1-git-send-email-kevin@sb.org \
    --to=kevin@sb.org \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=dirson@bertin.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=raible@nextest.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).