From: "Michael S. Tsirkin" <mst@redhat.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH RFC] rebase: add --revisions flag
Date: Tue, 8 Dec 2009 16:47:42 +0200 [thread overview]
Message-ID: <20091208144740.GA30830@redhat.com> (raw)
Add --revisions flag to rebase, so that it can be used
to apply an arbitrary range of commits on top
of a current branch.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
I've been wishing for this functionality for a while now,
so here goes. This isn't yet properly documented and I didn't
write a test, but the patch seems to work fine for me.
Any early flames/feedback?
git-rebase.sh | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index b121f45..d99d04b 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -3,12 +3,13 @@
# Copyright (c) 2005 Junio C Hamano.
#
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [--revisions <revision range>] [<upstream>|--root] [<branch>] [--quiet | -q]'
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
It then attempts to create a new commit for each commit from the original
-<branch> that does not exist in the <upstream> branch.
+<branch> that does not exist in the <upstream> branch, or for
+each commit matching <revision range> when the --revisions options is provided.
It is possible that a merge failure will prevent this process from being
completely automatic. You will have to resolve any such merge failure
@@ -41,6 +42,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\".
To restore the original branch and stop rebasing run \"git rebase --abort\".
"
unset newbase
+unset revisions
strategy=recursive
do_merge=
dotest="$GIT_DIR"/rebase-merge
@@ -291,6 +293,11 @@ do
newbase="$2"
shift
;;
+ --revisions)
+ test 2 -le "$#" || usage
+ revisions="$2"
+ shift
+ ;;
-M|-m|--m|--me|--mer|--merg|--merge)
do_merge=t
;;
@@ -459,12 +466,24 @@ case "$#" in
esac
orig_head=$branch
+if test -z "$revisions"
+then
+ if test -n "$rebase_root"
+ then
+ revisions="$onto..$orig_head"
+ else
+ revisions="$upstream..$orig_head"
+ fi
+ mb=$(git merge-base "$onto" "$branch")
+else
+ mb=""
+fi
+
# Now we are rebasing commits $upstream..$branch (or with --root,
# everything leading up to $branch) on top of $onto
# Check if we are already based on $onto with linear history,
# but this should be done only when upstream and onto are the same.
-mb=$(git merge-base "$onto" "$branch")
if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
# linear history?
! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null
@@ -489,10 +508,10 @@ if test -n "$diffstat"
then
if test -n "$verbose"
then
- echo "Changes from $mb to $onto:"
+ echo "Changes $revisions:"
fi
# We want color (if set), but no pager
- GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
+ GIT_PAGER='' git diff --stat --summary "$revisions"
fi
# If the $onto is a proper descendant of the tip of the branch, then
@@ -504,13 +523,6 @@ then
exit 0
fi
-if test -n "$rebase_root"
-then
- revisions="$onto..$orig_head"
-else
- revisions="$upstream..$orig_head"
-fi
-
if test -z "$do_merge"
then
git format-patch -k --stdout --full-index --ignore-if-in-upstream \
--
1.6.6.rc1.43.gf55cc
next reply other threads:[~2009-12-08 14:50 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-08 14:47 Michael S. Tsirkin [this message]
2009-12-08 16:08 ` [PATCH RFC] rebase: add --revisions flag Björn Steinbrink
2009-12-08 16:11 ` Michael S. Tsirkin
2009-12-08 16:41 ` Björn Steinbrink
2009-12-08 16:49 ` Michael S. Tsirkin
2009-12-08 19:13 ` Björn Steinbrink
2009-12-08 16:14 ` Michael S. Tsirkin
2009-12-08 16:37 ` Björn Steinbrink
2009-12-08 16:44 ` Michael S. Tsirkin
2009-12-08 19:11 ` Björn Steinbrink
2009-12-08 20:00 ` Michael S. Tsirkin
2009-12-09 13:19 ` Björn Steinbrink
2009-12-09 14:02 ` Michael S. Tsirkin
2009-12-09 4:51 ` Miles Bader
2009-12-08 20:22 ` Junio C Hamano
2009-12-08 20:29 ` Sverre Rabbelier
2009-12-09 5:30 ` Christian Couder
2009-12-09 6:52 ` Christian Couder
2009-12-09 9:08 ` Sverre Rabbelier
2009-12-09 8:47 ` Peter Krefting
2009-12-09 9:37 ` Michael S. Tsirkin
2009-12-09 10:52 ` Peter Krefting
2009-12-09 11:22 ` Björn Steinbrink
2009-12-09 11:48 ` Andreas Schwab
2009-12-09 12:06 ` Björn Steinbrink
2009-12-09 12:07 ` Michael S. Tsirkin
2009-12-09 13:06 ` Björn Steinbrink
2009-12-09 19:46 ` Junio C Hamano
2009-12-10 7:43 ` Björn Steinbrink
2009-12-10 17:20 ` Junio C Hamano
2009-12-11 11:07 ` Björn Steinbrink
2009-12-09 13:20 ` Peter Krefting
2009-12-09 13:41 ` Björn Steinbrink
2009-12-10 8:43 ` Peter Krefting
2009-12-10 11:08 ` Björn Steinbrink
2009-12-09 10:38 ` Michael S. Tsirkin
2009-12-09 10:55 ` Matthieu Moy
2009-12-09 13:30 ` Matthieu Moy
2009-12-09 13:45 ` Michael S. Tsirkin
2009-12-09 14:01 ` Björn Steinbrink
2009-12-09 14:12 ` Michael S. Tsirkin
2009-12-09 20:10 ` Junio C Hamano
2009-12-13 22:47 ` David Kågedal
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=20091208144740.GA30830@redhat.com \
--to=mst@redhat.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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