twosigma / git-meta

Repository for the git-meta project -- build your own monorepo using Git submodules
http://twosigma.github.io/git-meta
BSD 3-Clause "New" or "Revised" License
219 stars 50 forks source link

workAroundLibgit2MergeBug to skip creating synthetic ancestor if ance… #818

Closed shijinglu closed 3 years ago

shijinglu commented 3 years ago

…stor has the same sha as theirs.

In the submoudle_change.js, submodule change with same sha is forbidden, as I qoute:

    /**
     * Creat a new `Changed` object having the specified `oldSha` and `newSha`
     * values.  The behavior is undefined if `oldSha === newSha`
    ....
     */
    constructor(oldSha, newSha, ourSha) {
        assert.notEqual(oldSha, newSha);

However, workAroundLibgit2MergeBug routine can still create this "empty" change object with same newSha as the oldSha.

Let's add a logic to exlude that edge cases

shijinglu commented 3 years ago

I would like to see a test here, if possible.

Tested it with two sigma's proprietary monorepo, could not find a way to replicate that test case here. But the change is pretty safe. The worst case senario is that workAroundLibgit2MergeBug is skipped and user is left with submodule add-add conflict. In that case, use can just resolve the submodule conflict manually.