From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "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 2/3] rebase: accept -<number> as another way of saying HEAD~<number>
Date: Sun, 2 Mar 2014 09:53:13 +0700 [thread overview]
Message-ID: <1393728794-29566-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1393728794-29566-1-git-send-email-pclouds@gmail.com>
This is "rev-list style", where people can do "git rev-list -3" in
addition to "git rev-list HEAD~3". A lot of commands are driven by the
revision machinery and also accept this form. This addition to rebase
is just for convenience.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/git-rebase.txt | 3 +++
git-rebase.sh | 9 +++++++++
t/t3400-rebase.sh | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 2a93c64..52c3561 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -223,6 +223,9 @@ As a special case, you may use "A\...B" as a shortcut for the
merge base of A and B if there is exactly one merge base. You can
leave out at most one of A and B, in which case it defaults to HEAD.
+-<number>::
+ Specify <upstream> as "HEAD~<number>".
+
<upstream>::
Upstream branch to compare against. May be any valid commit,
not just an existing branch name. Defaults to the configured
diff --git a/git-rebase.sh b/git-rebase.sh
index 5f6732b..33face1 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,7 @@ 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
+-NUM equivalent of HEAD~<NUM>
"
. git-sh-setup
. git-sh-i18n
@@ -335,6 +336,9 @@ do
--gpg-sign=*)
gpg_sign_opt="-S${1#--gpg-sign=}"
;;
+ -NUM=*)
+ NUM="${1#-NUM=}"
+ ;;
--)
shift
break
@@ -342,6 +346,11 @@ do
esac
shift
done
+if [ -n "$NUM" ]
+then
+ test $# -gt 0 && usage
+ set -- "$@" "HEAD~$NUM"
+fi
test $# -gt 2 && usage
if test -n "$cmd" &&
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 6d94b1f..11db7ea 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -215,4 +215,10 @@ test_expect_success 'rebase commit with an ancient timestamp' '
grep "author .* 34567 +0600$" actual
'
+test_expect_success 'rebase -<number>' '
+ git reset --hard &&
+ test_must_fail git rebase -2 HEAD^^ &&
+ git rebase -2
+'
+
test_done
--
1.9.0.40.gaa8c3ea
next prev parent reply other threads:[~2014-03-02 2:54 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 ` Nguyễn Thái Ngọc Duy [this message]
2014-03-02 8:37 ` [PATCH 2/3] rebase: accept -<number> as another way of saying HEAD~<number> 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 ` [PATCH/RFC] rebase: new convenient option to edit/reword/delete " Nguyễn Thái Ngọc Duy
2014-03-09 16:30 ` 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=1393728794-29566-3-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=philipoakley@iee.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 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.