Bug: Merge commit lost during interactive rebase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
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@xxxxxxxxx>
Date:   Wed Dec 18 09:52:54 2019 +0000

    commit on master

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@xxxxxxxxx>
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@xxxxxxxxx>
Date:   Wed Dec 18 09:53:03 2019 +0000

    Merge branch 'branch2'

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

    commit on master

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

    commit on branch2

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@xxxxxxxxx>
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@xxxxxxxxx>
Date:   Wed Dec 18 09:53:43 2019 +0000

    commit after merge

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

    Merge branch 'branch2'

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

    commit on master

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

    commit on branch2

commit 39f2f9b13feb0c1a4b6173cf179b45576fca9b96
Author: root <valentina.finocchiaro@xxxxxxxxx>
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@xxxxxxxxx>
Date:   Wed Dec 18 09:50:30 2019 +0000

    commit on branch2

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

    commit on master

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

    first commit


Thanks and Best Regards,
Valentina




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux