git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Wong <andrew.kw.w@gmail.com>
To: git@vger.kernel.org
Cc: Andrew Wong <andrew.kw.w@gmail.com>
Subject: [PATCH 3/4] rebase -i: Teach "--edit-todo" action
Date: Mon, 17 Sep 2012 21:28:09 -0400	[thread overview]
Message-ID: <1347931690-20625-4-git-send-email-andrew.kw.w@gmail.com> (raw)
In-Reply-To: <1347931690-20625-1-git-send-email-andrew.kw.w@gmail.com>

This allows users to edit the todo file while they're stopped in the
middle of an interactive rebase. When this action is executed, all
comments from the original todo file are stripped, and new help messages
are appended to the end.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 Documentation/git-rebase.txt |  5 ++++-
 git-rebase--interactive.sh   | 17 +++++++++++++++++
 git-rebase.sh                | 13 +++++++++++--
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index fd535b0..da067ec 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -12,7 +12,7 @@ SYNOPSIS
 	[<upstream>] [<branch>]
 'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
 	--root [<branch>]
-'git rebase' --continue | --skip | --abort
+'git rebase' --continue | --skip | --abort | --edit-todo
 
 DESCRIPTION
 -----------
@@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
 --skip::
 	Restart the rebasing process by skipping the current patch.
 
+--edit-todo::
+	Edit the todo list during an interactive rebase.
+
 -m::
 --merge::
 	Use merging strategies to rebase.  When the recursive (default) merge
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 4d57e50..2b8f2a9 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -792,6 +792,23 @@ skip)
 
 	do_rest
 	;;
+edit-todo)
+	sed -e '/^#/d' < "$todo" > "$todo".new
+	mv -f "$todo".new "$todo"
+	append_todo_help
+	cat >> "$todo" << EOF
+#
+# You are editing the todo file of an ongoing interactive rebase.
+# To continue rebase after editing, run:
+#     git rebase --continue
+#
+EOF
+
+	git_sequence_editor "$todo" ||
+		die "Could not execute editor"
+
+	exit
+	;;
 esac
 
 git var GIT_COMMITTER_IDENT >/dev/null ||
diff --git a/git-rebase.sh b/git-rebase.sh
index e6b43a2..b2f1c76 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -8,7 +8,7 @@ OPTIONS_KEEPDASHDASH=
 OPTIONS_SPEC="\
 git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
 git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
-git-rebase --continue | --abort | --skip
+git-rebase --continue | --abort | --skip | --edit-todo
 --
  Available options are
 v,verbose!         display a diffstat of what changed upstream
@@ -38,6 +38,7 @@ C=!                passed to 'git apply'
 continue!          continue
 abort!             abort and check out the original branch
 skip!              skip current patch and continue
+edit-todo!         edit the todo list during an interactive rebase
 "
 . git-sh-setup
 . git-sh-i18n
@@ -190,7 +191,7 @@ do
 	--verify)
 		ok_to_skip_pre_rebase=
 		;;
-	--continue|--skip|--abort)
+	--continue|--skip|--abort|--edit-todo)
 		test $total_argc -eq 2 || usage
 		action=${1##--}
 		;;
@@ -306,6 +307,11 @@ then
 	fi
 fi
 
+if test "$action" = "edit-todo" && test "$type" != "interactive"
+then
+	die "$(gettext "The --edit-todo action can only be used during interactive rebase.")"
+fi
+
 case "$action" in
 continue)
 	# Sanity check
@@ -338,6 +344,9 @@ abort)
 	rm -r "$state_dir"
 	exit
 	;;
+edit-todo)
+	run_specific_rebase
+	;;
 esac
 
 # Make sure no rebase is in progress
-- 
1.7.12.318.g79683ba.dirty

  parent reply	other threads:[~2012-09-18  2:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10 16:14 [RFC] Add "edit" action for interactive rebase? Andrew Wong
2012-09-10 16:14 ` [PATCH] rebase -i: Teach "--edit" action Andrew Wong
2012-09-10 16:25   ` Matthieu Moy
2012-09-10 16:46     ` Andrew Wong
2012-09-10 16:54       ` Jeff King
2012-09-10 18:36         ` Johannes Sixt
2012-09-10 18:46           ` Jeff King
2012-09-10 19:33             ` Andrew Wong
2012-09-10 19:57               ` Junio C Hamano
2012-09-10 21:17                 ` Andrew Wong
2012-09-15 20:08                   ` [PATCH 0/3] rebase -i: Teach "--edit-todo" Andrew Wong
2012-09-15 20:08                     ` [PATCH 1/3] rebase -i: Refactor help messages for todo file Andrew Wong
2012-09-15 20:08                     ` [PATCH 2/3] rebase -i: Teach "--edit-todo" action Andrew Wong
2012-09-16  6:54                       ` Junio C Hamano
2012-09-16 15:49                         ` Andrew Wong
2012-09-18  6:56                           ` Junio C Hamano
2012-09-15 20:08                     ` [PATCH 3/3] rebase -i: Add tests for "--edit-todo" Andrew Wong
2012-09-16  6:58                       ` Junio C Hamano
2012-09-16 15:17                         ` [PATCH v2 1/3] rebase -i: Refactor help messages for todo file Andrew Wong
2012-09-16 15:17                           ` [PATCH v2 2/3] rebase -i: Teach "--edit-todo" action Andrew Wong
2012-09-17  6:11                             ` Martin von Zweigbergk
2012-09-18  1:28                               ` [PATCH v3 0/4] " Andrew Wong
2012-09-18  1:28                                 ` [PATCH 1/4] rebase usage: subcommands can not be combined with -i Andrew Wong
2012-09-18  1:28                                 ` [PATCH 2/4] rebase -i: Refactor help messages for todo file Andrew Wong
2012-09-18  1:28                                 ` Andrew Wong [this message]
2012-09-18  1:28                                 ` [PATCH 4/4] rebase -i: Add tests for "--edit-todo" Andrew Wong
2012-09-18  4:58                                   ` Martin von Zweigbergk
2012-09-18  5:23                                     ` Andrew Wong
2012-09-18  5:37                                       ` Martin von Zweigbergk
2012-09-19  6:43                                 ` [PATCH 5/4] rebase -i: suggest using --edit-todo to fix an unknown instruction Johannes Sixt
2012-09-19 19:52                                   ` Junio C Hamano
2012-09-16 15:17                           ` [PATCH v2 3/3] rebase -i: Add tests for "--edit-todo" Andrew Wong
2012-09-10 18:28 ` [RFC] Add "edit" action for interactive rebase? Johannes Sixt
2012-09-10 20:13   ` Andrew Wong

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=1347931690-20625-4-git-send-email-andrew.kw.w@gmail.com \
    --to=andrew.kw.w@gmail.com \
    --cc=git@vger.kernel.org \
    /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).