src/utils/branches.js
function merge(repoState, driver, from, into, options = {}) {
    options = Object.assign({
        fetch: true
    }, options);

    let updatedInto; // closure

    return driver.merge(from, into, {
        message: options.message
    }) // Can fail here with ERRORS.CONFLICT
    .then(function updateInto(mergeCommit) {
        if (!mergeCommit) {
            // Was a no op
            return repoState;
        } else {
            updatedInto = into.merge({ commit: mergeCommit });
            repoState = repoState.updateBranch(into, updatedInto);
            // invalidate working state
            return RepoUtils.updateWorkingState(repoState, into, null);
        }
    })
    .then(function fetchTree(repositoryState) {
        if (!options.fetch) {
            return repositoryState;
        } else {
            return RepoUtils.fetchTree(repositoryState, driver, updatedInto);
        }
    });
}
function merge(repoState, driver, from, into, options = {}) {
    options = Object.assign({
        fetch: true
    }, options);

    let updatedInto; // closure

    return driver.merge(from, into, {
        message: options.message
    }) // Can fail here with ERRORS.CONFLICT
    .then(function updateInto(mergeCommit) {
        if (!mergeCommit) {
            // Was a no op
            return repoState;
        } else {
            updatedInto = into.merge({ commit: mergeCommit });
            repoState = repoState.updateBranch(into, updatedInto);
            // invalidate working state
            return RepoUtils.updateWorkingState(repoState, into, null);
        }
    })
    .then(function fetchTree(repositoryState) {
        if (!options.fetch) {
            return repositoryState;
        } else {
            return RepoUtils.fetchTree(repositoryState, driver, updatedInto);
        }
    });
}
Merge a branch/commit into a branch, and update that branch's tree.
@param {RepositoryState} repoState
@param {Driver} driver
@param {Branch | SHA} from The branch to merge from, or a commit SHA
@param {Branch} into The branch to merge into, receives the new
commit. Must be clean
@param {String} [options.message] Merge commit message
@param {Boolean} [options.fetch=true] Fetch the updated tree on `into` branch ?
@return {Promise<RepositoryState, ERRORS.CONFLICT>} Fails with
CONFLICT error if automatic merge is not possible