From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Michael Haggerty" <mhagger@alum.mit.edu>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
"Jeff King" <peff@peff.net>,
philipoakley@iee.org, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH/RFC] rebase: new convenient option to edit/reword/delete a single commit
Date: Sun, 9 Mar 2014 09:49:14 +0700 [thread overview]
Message-ID: <1394333354-16257-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <53159601.8020702@alum.mit.edu>
Prepare the todo list for you to edit/reword/delete the given commit.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Allowing multiple actions is a bit too much for my shell skills. I
don't really need it so I won't push it, but if somebody gives me a
sketch, I'll try to polish it.
--squash and --fixup would require two commits, making it a bit
awkward in option handling. Or is the fixup/squash always HEAD?
Documentation/git-rebase.txt | 11 +++++++++++
git-rebase--interactive.sh | 17 ++++++++++++++---
git-rebase.sh | 22 +++++++++++++++++++++-
3 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 2a93c64..becb749 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -13,6 +13,7 @@ SYNOPSIS
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
--root [<branch>]
'git rebase' --continue | --skip | --abort | --edit-todo
+'git rebase' [--edit | -E | --reword | -R | --delete | -D ] <commit-ish>
DESCRIPTION
-----------
@@ -356,6 +357,16 @@ unless the `--fork-point` option is specified.
user edit that list before rebasing. This mode can also be used to
split commits (see SPLITTING COMMITS below).
+-E=<commit>::
+--edit=<commit>::
+-R=<commit>::
+--reword=<commit>::
+-D=<commit>::
+--delete=<commit>::
+ Prepare the todo list to edit or reword or delete the
+ specified commit. Configuration variable `rebase.autostash` is
+ ignored.
+
-p::
--preserve-merges::
Instead of ignoring merges, try to recreate them.
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a1adae8..3ded4c7 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1040,9 +1040,20 @@ fi
has_action "$todo" ||
die_abort "Nothing to do"
-cp "$todo" "$todo".backup
-git_sequence_editor "$todo" ||
- die_abort "Could not execute editor"
+if test -n "$one_action"
+then
+ commit="`git rev-parse --short $one_commit`"
+ sed "1s/pick $commit /$one_action $commit /" "$todo" > "$todo.new" ||
+ die_abort "failed to update todo list"
+ grep "^$one_action $commit " "$todo.new" >/dev/null ||
+ die_abort "expected to find '$one_action $commit' line but did not"
+ mv "$todo.new" "$todo" ||
+ die_abort "failed to update todo list"
+else
+ cp "$todo" "$todo".backup
+ git_sequence_editor "$todo" ||
+ die_abort "Could not execute editor"
+fi
has_action "$todo" ||
die_abort "Nothing to do"
diff --git a/git-rebase.sh b/git-rebase.sh
index 5f6732b..2acffb4 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -32,6 +32,9 @@ verify allow pre-rebase hook to run
rerere-autoupdate allow rerere to update index with resolved conflicts
root! rebase all reachable commits up to the root(s)
autosquash move commits that begin with squash!/fixup! under -i
+E,edit=! generate todo list to edit this commit
+R,reword=! generate todo list to reword this commit's message
+D,delete=! generate todo list to delete this commit
committer-date-is-author-date! passed to 'git am'
ignore-date! passed to 'git am'
whitespace=! passed to 'git apply'
@@ -228,6 +231,7 @@ then
fi
test -n "$type" && in_progress=t
+one_action=
total_argc=$#
while test $# != 0
do
@@ -290,6 +294,7 @@ do
;;
--autostash)
autostash=true
+ explicit_autosquash=t
;;
--verbose)
verbose=t
@@ -335,6 +340,13 @@ do
--gpg-sign=*)
gpg_sign_opt="-S${1#--gpg-sign=}"
;;
+ --edit=*|--reword=*|--delete=*)
+ test -n "$one_action" && die "$(gettext "--edit, --reword or --delete cannot be used multiple times")"
+ interactive_rebase=explicit
+ one_action="${1%=*}"
+ one_action="${one_action#--}"
+ one_commit="${1#--*=}"
+ ;;
--)
shift
break
@@ -342,6 +354,7 @@ do
esac
shift
done
+test -n "$one_action" && test $# -gt 0 && usage
test $# -gt 2 && usage
if test -n "$cmd" &&
@@ -438,7 +451,14 @@ else
state_dir="$apply_dir"
fi
-if test -z "$rebase_root"
+if test -n "$one_action"
+then
+ upstream_name="$one_commit^"
+ upstream=$(peel_committish "${upstream_name}") ||
+ die "$(eval_gettext "invalid upstream \$upstream_name")"
+ upstream_arg="$upstream_name"
+ test -n "$explicit_autosquash" || autosquash=
+elif test -z "$rebase_root"
then
case "$#" in
0)
--
1.9.0.40.gaa8c3ea
next prev parent reply other threads:[~2014-03-09 2:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 13:01 [PATCH/RFC] rebase: new convenient option to edit a single commit Nguyễn Thái Ngọc Duy
2014-02-27 13:52 ` Matthieu Moy
2014-02-28 6:58 ` Jeff King
2014-02-28 7:34 ` Duy Nguyen
2014-02-28 7:38 ` Jeff King
2014-02-28 17:14 ` Philip Oakley
2014-03-02 2:53 ` [PATCH 0/3] rebase's convenient options Nguyễn Thái Ngọc Duy
2014-03-02 2:53 ` [PATCH 1/3] rev-parse: support OPT_NUMBER_CALLBACK in --parseopt Nguyễn Thái Ngọc Duy
2014-03-04 18:28 ` Junio C Hamano
2014-03-02 2:53 ` [PATCH 2/3] rebase: accept -<number> as another way of saying HEAD~<number> Nguyễn Thái Ngọc Duy
2014-03-02 8:37 ` Eric Sunshine
2014-03-02 8:45 ` Duy Nguyen
2014-03-02 8:53 ` Eric Sunshine
2014-03-02 8:55 ` Eric Sunshine
2014-03-02 15:55 ` Matthieu Moy
2014-03-03 9:16 ` Michael Haggerty
2014-03-03 9:37 ` Matthieu Moy
2014-03-03 10:04 ` Duy Nguyen
2014-03-03 10:11 ` David Kastrup
2014-03-03 10:12 ` Matthieu Moy
2014-03-03 10:13 ` Jeff King
2014-03-03 21:48 ` Junio C Hamano
2014-03-03 22:39 ` Matthieu Moy
2014-03-03 21:44 ` Junio C Hamano
2014-03-02 2:53 ` [PATCH 3/3] rebase: new convenient option to edit a single commit Nguyễn Thái Ngọc Duy
2014-03-02 9:04 ` Eric Sunshine
2014-03-02 9:09 ` Eric Sunshine
2014-03-03 10:10 ` Michael Haggerty
2014-03-03 10:15 ` Duy Nguyen
2014-03-03 10:37 ` David Kastrup
2014-03-03 20:28 ` Eric Sunshine
2014-03-04 2:08 ` Duy Nguyen
2014-03-04 8:59 ` Michael Haggerty
2014-03-04 10:24 ` Duy Nguyen
2014-03-04 13:11 ` Michael Haggerty
2014-03-04 18:37 ` Junio C Hamano
2014-03-09 2:49 ` Nguyễn Thái Ngọc Duy [this message]
2014-03-09 16:30 ` [PATCH/RFC] rebase: new convenient option to edit/reword/delete " Matthieu Moy
2014-03-10 8:30 ` Michael Haggerty
2014-03-10 8:41 ` Matthieu Moy
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=1394333354-16257-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
--cc=peff@peff.net \
--cc=philipoakley@iee.org \
--cc=sunshine@sunshineco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.