git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood@talktalk.net>
To: Git Mailing List <git@vger.kernel.org>
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH 2/2] rebase --root -k: fix when root commit is empty
Date: Thu, 15 Mar 2018 10:59:40 +0000	[thread overview]
Message-ID: <e17efcc9-63c2-5c88-e74b-c9205e42d6ad@talktalk.net> (raw)
In-Reply-To: <20180314111127.14217-2-phillip.wood@talktalk.net>

On 14/03/18 11:11, Phillip Wood wrote:
> From: Phillip Wood <phillip.wood@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.wood@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"

On reflection I'm not sure this is the best way to fix the problem. This
is a specific instance of a wider problem where rebase -k does not
preserve empty commits if there is an empty commit upstream (see
t3421:rebase -i --keep-empty keeps empty even if already in upstream). I
think the way to solve it is to get two lists of revs, the first with
--cherry-pick and the second without and use all the commits from the
first list and the empty ones from the second. I'll have a look and send
a reroll.

> 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 &&
> 


  parent reply	other threads:[~2018-03-15 10:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 11:11 [PATCH 1/2] rebase: support --signoff with implicit rebase Phillip Wood
2018-03-14 11:11 ` [PATCH 2/2] rebase --root -k: fix when root commit is empty Phillip Wood
2018-03-15 10:28   ` Johannes Schindelin
2018-03-15 10:59   ` Phillip Wood [this message]
2018-03-14 17:48 ` [PATCH 1/2] rebase: support --signoff with implicit rebase Junio C Hamano
2018-03-15 10:11   ` Johannes Schindelin
2018-03-15 10:18 ` Johannes Schindelin
2018-03-15 10:55   ` Phillip Wood
2018-03-16 12:36     ` Johannes Schindelin
2018-03-20 11:10 ` [PATCH v2 0/3] rebase: extend --signoff support Phillip Wood
2018-03-20 11:10   ` [PATCH v2 1/3] " Phillip Wood
2018-03-20 11:10   ` [PATCH v2 2/3] rebase -p: error out if --signoff is given Phillip Wood
2018-03-20 11:10   ` [PATCH v2 3/3] rebase --keep-empty: always use interactive rebase Phillip Wood
2018-03-20 16:08     ` Johannes Schindelin
2018-03-20 18:44       ` Phillip Wood

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e17efcc9-63c2-5c88-e74b-c9205e42d6ad@talktalk.net \
    --to=phillip.wood@talktalk.net \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    --subject='Re: [PATCH 2/2] rebase --root -k: fix when root commit is empty' \
    /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

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).