git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Inconsistancy with `git rebase --preserve-merges`
       [not found] <v9k9hyJjfgQYYIczd9NqrjSdyOyxwqEB0iWyQ_TZCnobCZZoZ8_v6WB4KcWyW5xxRPdDUyEqEYfXylOnGI57CtK9KegMgp_0bz_5RrIIhHY=@pm.me>
@ 2020-02-24 14:10 ` Robin Moussu
  2020-02-24 18:36   ` Kevin Daudt
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Moussu @ 2020-02-24 14:10 UTC (permalink / raw)
  To: git@vger.kernel.org

Hi. I noticed that the position of the `--preserve-merges` option of
`git rebase` is significant (I think it shouldn't).

The following snippet doesn't preserve the merges:
```
$ git rebase --preserve-merges -i 412f07a~
pick 412f07a Work on dev branch
pick c6efccd Work on master branch
pick 71c8c37 Some work after the merge
```

Whereas this one does what I expect:
```
$ git rebase -i 412f07a~ --preserve-merges
pick 412f07a Work on dev branch
pick 616064c Merge branch 'master' into dev
pick 71c8c37 Some work after the merge
```

For reference:
```
$ git log --graph --oneline
* 71c8c37      (HEAD -> dev) Some work after the merge
*   616064c    Merge branch 'master' into dev
|\
| *   c6efccd  Work on master branch
| *   ... (more work on master)
* |   412f07a  Work on dev branch
* |   ... (more work on dev)
|/
* 4ee50cb Common ancestor
```

Step to reproduce:
```
mkdir temp
cd temp
git init
git commit --allow-empty -m 'Common ancestor'
git checkout -b dev
git commit --allow-empty -m 'Work on dev branch'
git tag some_commit
git checkout master
git commit --allow-empty -m 'Work on master branch'
git checkout dev
git merge master -m 'Merge branch 'master' into dev'
git commit --allow-empty -m 'Some work after the merge'
```
Then you will see that
    git rebase -i some_commit --preserve-merges
and
    git rebase --preserve-merges  -i some_commit
don't have the same output.

I am using git version 2.21.1 on Fedora 30.

Robin.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Inconsistancy with `git rebase --preserve-merges`
  2020-02-24 14:10 ` Inconsistancy with `git rebase --preserve-merges` Robin Moussu
@ 2020-02-24 18:36   ` Kevin Daudt
  2020-02-24 21:35     ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Daudt @ 2020-02-24 18:36 UTC (permalink / raw)
  To: Robin Moussu; +Cc: git@vger.kernel.org

On Mon, Feb 24, 2020 at 02:10:07PM +0000, Robin Moussu wrote:
> Hi. I noticed that the position of the `--preserve-merges` option of
> `git rebase` is significant (I think it shouldn't).
> 
> The following snippet doesn't preserve the merges:
> ```
> $ git rebase --preserve-merges -i 412f07a~
> pick 412f07a Work on dev branch
> pick c6efccd Work on master branch
> pick 71c8c37 Some work after the merge
> ```
> 
> Whereas this one does what I expect:
> ```
> $ git rebase -i 412f07a~ --preserve-merges
> pick 412f07a Work on dev branch
> pick 616064c Merge branch 'master' into dev
> pick 71c8c37 Some work after the merge
> ```
> 
> For reference:
> ```
> $ git log --graph --oneline
> * 71c8c37      (HEAD -> dev) Some work after the merge
> *   616064c    Merge branch 'master' into dev
> |\
> | *   c6efccd  Work on master branch
> | *   ... (more work on master)
> * |   412f07a  Work on dev branch
> * |   ... (more work on dev)
> |/
> * 4ee50cb Common ancestor
> ```
> 
> Step to reproduce:
> ```
> mkdir temp
> cd temp
> git init
> git commit --allow-empty -m 'Common ancestor'
> git checkout -b dev
> git commit --allow-empty -m 'Work on dev branch'
> git tag some_commit
> git checkout master
> git commit --allow-empty -m 'Work on master branch'
> git checkout dev
> git merge master -m 'Merge branch 'master' into dev'
> git commit --allow-empty -m 'Some work after the merge'
> ```
> Then you will see that
>     git rebase -i some_commit --preserve-merges
> and
>     git rebase --preserve-merges  -i some_commit
> don't have the same output.
> 
> I am using git version 2.21.1 on Fedora 30.
> 
> Robin.
> 

Can you try `--rebase-merges` instead? Since v2.22.0 `--preseve-merges`
is officially deprecated, but even before that it was already known to
have flaws.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Inconsistancy with `git rebase --preserve-merges`
  2020-02-24 18:36   ` Kevin Daudt
@ 2020-02-24 21:35     ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-02-24 21:35 UTC (permalink / raw)
  To: Kevin Daudt; +Cc: Robin Moussu, git@vger.kernel.org

Kevin Daudt <me@ikke.info> writes:

>> $ git rebase --preserve-merges -i 412f07a~
>
> Can you try `--rebase-merges` instead? Since v2.22.0 `--preseve-merges`
> is officially deprecated, but even before that it was already known to
> have flaws.

The options to "rebase" command seem to follow the usual "last one
wins" pattern.  There is a single opts->type field, and upon seeing
--preserve-merges, the field gets assigned REBASE_PRESERVE_MERGES,
and then when the command line option parser sees "-i", the field
gets overwritten by assigning REBASE_INTERACTIVE.  So

    git rebase --preserve-merges -i 412f07a~
    git rebase -i 412f07a~

both should do the same thing.

I suspect that "--rebase-merges -i" may hide the real issue (which
is "the command line option parsing of rebase is messy"), but it may
deserve to be cleaned up, now that the result of "rewrite it in C"
efforts seems to have sufficiently stablized.

What to clean-up?  There could be two-and-half ways to view it:

 * The options should follow the usual "last one wins" pattern; if
   we take this stance, what happens with "--rebase-merges -i" is
   buggy and "--preserve-merges -i" that behaves as a mere "-i" is
   doing the right thing.  The part of the command line parser that
   implements "--rebase-merges" should be fixed so that its effect
   gets reverted when "-i" is seen later.

 * The options "--rebase-merges" and "--perserve-merges" (there may
   be others) and "--interactive" should be mutually exclusive; if
   we take this stance, we should error out when we see two or more
   of them on the command line.

 * The options "--rebase-merges" and "--preserve-merges" (there may
   be others) should be mutually exclusive or "last one wins", but
   "--interactive" can be combined with them to make them
   interactive.

I am not sure which one is the best.  The impression I got from the
current state of the code is that it started from "last one wins",
and the code wanted to transition to "--interactive makes other
options go interactive" but hasn't done a good job by leaving loose
ends (like what we saw with "--preserve-merges"), so perhaps the
last one is what we want to aim as a long term solution?  I dunno.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-24 21:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <v9k9hyJjfgQYYIczd9NqrjSdyOyxwqEB0iWyQ_TZCnobCZZoZ8_v6WB4KcWyW5xxRPdDUyEqEYfXylOnGI57CtK9KegMgp_0bz_5RrIIhHY=@pm.me>
2020-02-24 14:10 ` Inconsistancy with `git rebase --preserve-merges` Robin Moussu
2020-02-24 18:36   ` Kevin Daudt
2020-02-24 21:35     ` Junio C Hamano

Code repositories for project(s) associated with this public 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).