Thread (24 messages) flat view 24 messages, 5 authors, 2016-06-15

Re: [PATCH 2/3] rebase: accept -<number> as another way of saying HEAD~<number>

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:00:09

On Sat, Mar 1, 2014 at 9:53 PM, Nguyễn Thái Ngọc Duy [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
diff --git a/git-rebase.sh b/git-rebase.sh
index 5f6732b..33face1 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -342,6 +346,11 @@ do
        esac
        shift
 done
+if [ -n "$NUM" ]
With the exception of one errant "if [...]", git-rebase.sh uniformly
uses "if test ...".
quoted hunk ↗ jump to hunk
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help