Import fails if merge is enabled

Bug #1625876 reported by Mathieu Gagné
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Status tracked in Trunk
Fix Released
Fix Released
Darragh Bailey

Bug Description

I don't know how to describe the problem yet or identify the root cause.
I just know how to check if an import went well. (thanks to electrofelix on IRC #git-upstream)

This bug is a placeholder so we can track progress and add details later as we discover them.

How I can reproduce the problem on my side:

  git-upstream import upstream-version

After import process is completed, the following output aren't identical:

  git rev-parse master^{tree}
  git rev-parse master^2^{tree}

I can however import just fine by running the import and finish steps separately:

  git-upstream import --no-merge upstream-version
  git-upstream import --finish --into master --import-branch import/upstream-version upstream-version

At this point, output of both git rev-parse commands are identical.

Mathieu Gagné (mgagne)
description: updated
description: updated
Changed in git-upstream:
importance: Undecided → Critical
assignee: nobody → Darragh Bailey (dbailey-k)
Revision history for this message
Darragh Bailey (dbailey-k) wrote :

With the patch added to fix the logging options, and a local repo that exhibited the same issue, I've managed to work out what is happening.

The problem is that when a conflict occurs during a non-interactive import, when finish is called, the tree will be in a detached state and should ensure to use the current HEAD revision instead of the import branch (which will be still at the original state as the rebase has not performed it's post-steps). To do this, the finish() method sets a variable target_sha to contain either the import branch or the current HEAD sha1.

Unfortunately some of the code in the finish() method is still referencing import_branch instead of the correct variable target_sha.

The fix is relatively easy, it's the test case to catch this in the future that is trickier to implement. Basically need to simulate an import with a conflict during rebase and then complete the import and check the resulting state.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to git-upstream (master)

Fix proposed to branch: master

Changed in git-upstream:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to git-upstream (master)

Submitter: Jenkins
Branch: master

commit a24debcbf8ca835cb6a9170065b5702a3963fa54
Author: Darragh Bailey <email address hidden>
Date: Mon Sep 19 18:44:23 2016 +0100

    Ensure correct mode of git-rebase executed

    When not using interactive mode, ensure that git rebase is called as a
    subprocess to ensure git-upstream can switch the final branch to the
    merged result after completion of the import.

    Only where interactive mode is enabled should the branch remain on the
    import branch after running to completion and leave it to the user to
    switch to the target branch, as otherwise git-rebase will throw an

    Change-Id: I633a371775b5a177c76529a49b44fb841d9c1332
    Related-Bug: #1625876

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Submitter: Jenkins
Branch: master

commit 54d48766ae177f2d8d75704962f4e90cc35fb95d
Author: Darragh Bailey <email address hidden>
Date: Wed Sep 28 12:12:12 2016 +0100

    Always have rebase perform finish

    To ensure consistent behaviour around encountering conflicts whether in
    interactive mode or not, or whether there are changes to be carried or
    not, always have rebase perform the finish step whenever the merge
    behaviour is enabled.

    Change-Id: I8f72ebb9fb0fa9fff4943e732cbf4f7d33672837
    Related-Bug: #1625876

Changed in git-upstream:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to git-upstream (master)

Submitter: Jenkins
Branch: master

commit 47092a9b63185ed50119bd6d510c5843a3c57d86
Author: Darragh Bailey <email address hidden>
Date: Fri Sep 30 11:09:31 2016 +0100

    Fix finish merge to ensure correct contents

    Make sure to use the same variable for all git commands in the finish
    phase as this has already been set to the correct branch or sha1
    depending on whether the currently in a rebase or not.

    In certain cases the finish steps were not using the correct references
    to merge and read-tree resulting in the final merge containing the
    wrong tree contents.

    Add test to cover the conflict and manual resolve case, as well as
    adding a check to the other tests for testing the resulting merge
    contains the correct contents.

    Change-Id: I2fb870ad685b7ca2543c896bb2af4410a32373d0
    Closes-Bug: #1625876

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.