All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug: Merge commit lost during interactive rebase
@ 2019-12-18 22:04 Valentina Finocchiaro
  2019-12-19  1:25 ` Thomas Braun
  0 siblings, 1 reply; 2+ messages in thread
From: Valentina Finocchiaro @ 2019-12-18 22:04 UTC (permalink / raw)
  To: git

Hi,

this is to report a bug found during interactive rebase.

Bug description

Scenario:
- New commit on top of a Merge Commit.
- Dropping last commit during interactive rebase.
- Merge Commit is lost in history

Steps to reproduce this bug with “git version 2.18.1” on Centos8:

[root@a86e2b632fc2 git-bug-rebase]# git --version
git version 2.18.1

# Creating git repo

[root@a86e2b632fc2 /]# mkdir git-bug-rebase
[root@a86e2b632fc2 /]# cd git-bug-rebase/
[root@a86e2b632fc2 git-bug-rebase]# git init
Initialized empty Git repository in /git-bug-rebase/.git/

# Adding stuff on master branch and first commit

[root@a86e2b632fc2 git-bug-rebase]# touch file1
[root@a86e2b632fc2 git-bug-rebase]# git add .
[root@a86e2b632fc2 git-bug-rebase]# git commit -m "first commit"
[master (root-commit) 39f2f9b] first commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file1
[root@a86e2b632fc2 git-bug-rebase]# git log
commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96 (HEAD -> master)
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:49:21 2019 +0000

    first commit
[root@a86e2b632fc2 git-bug-rebase]# git branch
* master

# Creating another branch: branch2, checkout on it and commit changes

[root@a86e2b632fc2 git-bug-rebase]# git branch branch2
[root@a86e2b632fc2 git-bug-rebase]# git branch
  branch2
* master
[root@a86e2b632fc2 git-bug-rebase]# git checkout branch2
Switched to branch 'branch2'
[root@a86e2b632fc2 git-bug-rebase]# touch file-branch-2
[root@a86e2b632fc2 git-bug-rebase]# git add .
[root@a86e2b632fc2 git-bug-rebase]# git commit -m "commit on branch2"
[branch2 786f836] commit on branch2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file-branch-2

# Checkout on master and commit something else

[root@a86e2b632fc2 git-bug-rebase]# git checkout master
Switched to branch 'master'
[root@a86e2b632fc2 git-bug-rebase]# touch file3
[root@a86e2b632fc2 git-bug-rebase]# git add .
[root@a86e2b632fc2 git-bug-rebase]# git commit -m "commit on master"
[master e3a957d] commit on master
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file3
[root@a86e2b632fc2 git-bug-rebase]# git log
commit e3a957d99401101b9e2805c2b59459123b2c1883 (HEAD -> master)
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:52:54 2019 +0000

    commit on master

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:49:21 2019 +0000

    first commit

# Merge two branches:

[root@a86e2b632fc2 git-bug-rebase]# git merge branch2
Merge made by the 'recursive' strategy.
 file-branch-2 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file-branch-2

[root@a86e2b632fc2 git-bug-rebase]# git log
commit 9329daf43321d1b797652abf87106134ca516929 (HEAD -> master)
Merge: e3a957d 786f836
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:53:03 2019 +0000

    Merge branch 'branch2'

commit e3a957d99401101b9e2805c2b59459123b2c1883
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:52:54 2019 +0000

    commit on master

commit 786f836d941c101cb952aa008d10246cb0638e46 (branch2)
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:50:30 2019 +0000

    commit on branch2

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:49:21 2019 +0000

    first commit

# Commit something after merge commit:

[root@a86e2b632fc2 git-bug-rebase]# touch file-after-merge
[root@a86e2b632fc2 git-bug-rebase]# git add .
[root@a86e2b632fc2 git-bug-rebase]# git commit -m "commit after merge"
[master 1f33710] commit after merge
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file-after-merge

[root@a86e2b632fc2 git-bug-rebase]# git log
commit 1f33710d6f011bb123cd947f82a004812b71f804 (HEAD -> master)
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:53:43 2019 +0000

    commit after merge

commit 9329daf43321d1b797652abf87106134ca516929
Merge: e3a957d 786f836
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:53:03 2019 +0000

    Merge branch 'branch2'

commit e3a957d99401101b9e2805c2b59459123b2c1883
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:52:54 2019 +0000

    commit on master

commit 786f836d941c101cb952aa008d10246cb0638e46 (branch2)
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:50:30 2019 +0000

    commit on branch2

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:49:21 2019 +0000

    first commit

# Delete last commit through interactive rebase (merge commit is not
shown on list):

[root@a86e2b632fc2 git-bug-rebase]# git rebase -i HEAD~3
Successfully rebased and updated refs/heads/master.
[root@a86e2b632fc2 git-bug-rebase]# git status
On branch master
nothing to commit, working tree clean

# Merge commit is lost:

[root@a86e2b632fc2 git-bug-rebase]# git log
commit 82a34e8b224d8fa9434cc484ed153b519ffa32a5 (HEAD -> master)
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:50:30 2019 +0000

    commit on branch2

commit e3a957d99401101b9e2805c2b59459123b2c1883
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:52:54 2019 +0000

    commit on master

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@gmail.com>
Date:   Wed Dec 18 09:49:21 2019 +0000

    first commit


Thanks and Best Regards,
Valentina

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

* Re: Bug: Merge commit lost during interactive rebase
  2019-12-18 22:04 Bug: Merge commit lost during interactive rebase Valentina Finocchiaro
@ 2019-12-19  1:25 ` Thomas Braun
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Braun @ 2019-12-19  1:25 UTC (permalink / raw)
  To: Valentina Finocchiaro, git

On 18.12.2019 23:04, Valentina Finocchiaro wrote:

Hi Valentina,

see the --preserve-merges parameter, in newer versions called
--rebase-merges, for git rebase. This avoids the default behaviour of
dropping the merge commit.

Thomas

> this is to report a bug found during interactive rebase.
> 
> Bug description
> 
> Scenario:
> - New commit on top of a Merge Commit.
> - Dropping last commit during interactive rebase.
> - Merge Commit is lost in history
> 
> Steps to reproduce this bug with “git version 2.18.1” on Centos8:
> 
> [root@a86e2b632fc2 git-bug-rebase]# git --version
> git version 2.18.1
> 
> # Creating git repo
> 
> [root@a86e2b632fc2 /]# mkdir git-bug-rebase
> [root@a86e2b632fc2 /]# cd git-bug-rebase/
> [root@a86e2b632fc2 git-bug-rebase]# git init
> Initialized empty Git repository in /git-bug-rebase/.git/
> 
> # Adding stuff on master branch and first commit
> 
> [root@a86e2b632fc2 git-bug-rebase]# touch file1
> [root@a86e2b632fc2 git-bug-rebase]# git add .
> [root@a86e2b632fc2 git-bug-rebase]# git commit -m "first commit"
> [master (root-commit) 39f2f9b] first commit
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 file1
> [root@a86e2b632fc2 git-bug-rebase]# git log
> commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96 (HEAD -> master)
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:49:21 2019 +0000
> 
>     first commit
> [root@a86e2b632fc2 git-bug-rebase]# git branch
> * master
> 
> # Creating another branch: branch2, checkout on it and commit changes
> 
> [root@a86e2b632fc2 git-bug-rebase]# git branch branch2
> [root@a86e2b632fc2 git-bug-rebase]# git branch
>   branch2
> * master
> [root@a86e2b632fc2 git-bug-rebase]# git checkout branch2
> Switched to branch 'branch2'
> [root@a86e2b632fc2 git-bug-rebase]# touch file-branch-2
> [root@a86e2b632fc2 git-bug-rebase]# git add .
> [root@a86e2b632fc2 git-bug-rebase]# git commit -m "commit on branch2"
> [branch2 786f836] commit on branch2
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 file-branch-2
> 
> # Checkout on master and commit something else
> 
> [root@a86e2b632fc2 git-bug-rebase]# git checkout master
> Switched to branch 'master'
> [root@a86e2b632fc2 git-bug-rebase]# touch file3
> [root@a86e2b632fc2 git-bug-rebase]# git add .
> [root@a86e2b632fc2 git-bug-rebase]# git commit -m "commit on master"
> [master e3a957d] commit on master
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 file3
> [root@a86e2b632fc2 git-bug-rebase]# git log
> commit e3a957d99401101b9e2805c2b59459123b2c1883 (HEAD -> master)
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:52:54 2019 +0000
> 
>     commit on master
> 
> commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:49:21 2019 +0000
> 
>     first commit
> 
> # Merge two branches:
> 
> [root@a86e2b632fc2 git-bug-rebase]# git merge branch2
> Merge made by the 'recursive' strategy.
>  file-branch-2 | 0
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 file-branch-2
> 
> [root@a86e2b632fc2 git-bug-rebase]# git log
> commit 9329daf43321d1b797652abf87106134ca516929 (HEAD -> master)
> Merge: e3a957d 786f836
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:53:03 2019 +0000
> 
>     Merge branch 'branch2'
> 
> commit e3a957d99401101b9e2805c2b59459123b2c1883
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:52:54 2019 +0000
> 
>     commit on master
> 
> commit 786f836d941c101cb952aa008d10246cb0638e46 (branch2)
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:50:30 2019 +0000
> 
>     commit on branch2
> 
> commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:49:21 2019 +0000
> 
>     first commit
> 
> # Commit something after merge commit:
> 
> [root@a86e2b632fc2 git-bug-rebase]# touch file-after-merge
> [root@a86e2b632fc2 git-bug-rebase]# git add .
> [root@a86e2b632fc2 git-bug-rebase]# git commit -m "commit after merge"
> [master 1f33710] commit after merge
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 file-after-merge
> 
> [root@a86e2b632fc2 git-bug-rebase]# git log
> commit 1f33710d6f011bb123cd947f82a004812b71f804 (HEAD -> master)
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:53:43 2019 +0000
> 
>     commit after merge
> 
> commit 9329daf43321d1b797652abf87106134ca516929
> Merge: e3a957d 786f836
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:53:03 2019 +0000
> 
>     Merge branch 'branch2'
> 
> commit e3a957d99401101b9e2805c2b59459123b2c1883
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:52:54 2019 +0000
> 
>     commit on master
> 
> commit 786f836d941c101cb952aa008d10246cb0638e46 (branch2)
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:50:30 2019 +0000
> 
>     commit on branch2
> 
> commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:49:21 2019 +0000
> 
>     first commit
> 
> # Delete last commit through interactive rebase (merge commit is not
> shown on list):
> 
> [root@a86e2b632fc2 git-bug-rebase]# git rebase -i HEAD~3
> Successfully rebased and updated refs/heads/master.
> [root@a86e2b632fc2 git-bug-rebase]# git status
> On branch master
> nothing to commit, working tree clean
> 
> # Merge commit is lost:
> 
> [root@a86e2b632fc2 git-bug-rebase]# git log
> commit 82a34e8b224d8fa9434cc484ed153b519ffa32a5 (HEAD -> master)
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:50:30 2019 +0000
> 
>     commit on branch2
> 
> commit e3a957d99401101b9e2805c2b59459123b2c1883
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:52:54 2019 +0000
> 
>     commit on master
> 
> commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
> Author: root <valentina.finocchiaro@gmail.com>
> Date:   Wed Dec 18 09:49:21 2019 +0000
> 
>     first commit
> 
> 
> Thanks and Best Regards,
> Valentina
> 


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

end of thread, other threads:[~2019-12-19  1:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 22:04 Bug: Merge commit lost during interactive rebase Valentina Finocchiaro
2019-12-19  1:25 ` Thomas Braun

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.