From: Phillip Wood <phillip.w...@dunelm.org.uk>

When the root commit was empty it was being pruned by the
--cherry-pick option passed to rev-parse. This is because when --onto
is omitted rebase creates an empty commit (which it later amends) for
the new root commit.

Signed-off-by: Phillip Wood <phillip.w...@dunelm.org.uk>
---
 git-rebase--interactive.sh | 7 ++++++-
 git-rebase.sh              | 1 +
 t/t3428-rebase-signoff.sh  | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 4ea54fc1c4..3ad74fc57c 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -894,7 +894,12 @@ then
        revisions=$upstream...$orig_head
        shortrevisions=$shortupstream..$shorthead
 else
-       revisions=$onto...$orig_head
+       if test -n "$squash_onto"
+       then
+               revisions=$orig_head
+       else
+               revisions=$onto...$orig_head
+       fi
        shortrevisions=$shorthead
 fi
 if test t != "$preserve_merges"
diff --git a/git-rebase.sh b/git-rebase.sh
index 40301756be..30b8eaf489 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -61,6 +61,7 @@ $(gettext 'Resolve all conflicts manually, mark them as 
resolved with
 You can instead skip this commit: run "git rebase --skip".
 To abort and get back to the state before "git rebase", run "git rebase 
--abort".')
 "
+squash_onto=
 unset onto
 unset restrict_revision
 cmd=
diff --git a/t/t3428-rebase-signoff.sh b/t/t3428-rebase-signoff.sh
index 2ff7f534e3..90ca6636d5 100755
--- a/t/t3428-rebase-signoff.sh
+++ b/t/t3428-rebase-signoff.sh
@@ -59,7 +59,7 @@ test_expect_success 'rebase --exec --signoff adds a sign-off 
line' '
        test_cmp expected-signed actual
 '
 
-test_expect_failure 'rebase --root --signoff adds a sign-off line' '
+test_expect_success 'rebase --root --signoff adds a sign-off line' '
        git commit --amend -m "first" &&
        git rebase --root --keep-empty --signoff &&
        git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual &&
-- 
2.16.2

Reply via email to