Permalink
Browse files

Allow normal merge to operates on bare and half opened repos

  • Loading branch information...
shijinglu committed Feb 5, 2019
1 parent b1e6513 commit a745816076a95fcf136a9d55e9f09806638e64a0
@@ -107,12 +107,14 @@ exports.executeableSubcommand = co.wrap(function *(args) {

const colors = require("colors");

const MergeUtil = require("../util/merge_util");
const GitUtil = require("../util/git_util");
const Hook = require("../util/hook");
const UserError = require("../util/user_error");
const MergeUtil = require("../util/merge_util");
const MergeCommon = require("../util/merge_common");
const GitUtil = require("../util/git_util");
const Hook = require("../util/hook");
const Open = require("../util/open");
const UserError = require("../util/user_error");

const MODE = MergeUtil.MODE;
const MODE = MergeCommon.MODE;
let mode = MODE.NORMAL;

if (args.ff + args.continue + args.abort + args.no_ff + args.ff_only > 1) {
@@ -167,8 +169,12 @@ Merge of '${commitName}'
return GitUtil.editMessage(repo, message);
};
const commit = yield repo.getCommit(commitish.id());
const result =
yield MergeUtil.merge(repo, commit, mode, args.message, editMessage);
const result = yield MergeUtil.merge(repo,
commit,
mode,
Open.SUB_OPEN_OPTION.ALLOW_BARE,
args.message,
editMessage);
if (null !== result.errorMessage) {
throw new UserError(result.errorMessage);
}
@@ -88,17 +88,19 @@ exports.executeableSubcommand = co.wrap(function *(args) {

const colors = require("colors");

const MergeBareUtil = require("../util/merge_bare_util");
const MergeUtil = require("../util/merge_util");
const MergeCommon = require("../util/merge_common");
const GitUtil = require("../util/git_util");
const Hook = require("../util/hook");
const Open = require("../util/open");
const UserError = require("../util/user_error");

const repo = yield GitUtil.getCurrentRepo();
const mode = args.no_ff ?
MergeBareUtil.MODE.NORMAL :
MergeBareUtil.MODE.FORCE_COMMIT;
let ourCommitName = args.ourCommit;
let theirCommitName = args.theirCommit;
MergeCommon.MODE.NORMAL :
MergeCommon.MODE.FORCE_COMMIT;
let ourCommitName = args.ourCommit[0];
let theirCommitName = args.theirCommit[0];
if (null === ourCommitName || null === theirCommitName) {
throw new UserError("Two commits must be given.");
}
@@ -117,11 +119,12 @@ Could not resolve ${colors.red(theirCommitName)} to a commit.`);

const ourCommit = yield repo.getCommit(ourCommitish.id());
const theirCommit = yield repo.getCommit(theirCommitish.id());
const result = yield MergeBareUtil.merge(repo,
ourCommit,
theirCommit,
mode,
args.message);
const result = yield MergeUtil.merge(repo,
ourCommit,
theirCommit,
mode,
Open.SUB_OPEN_OPTION.FORCE_BARE,
args.message);
if (null !== result.errorMessage) {
throw new UserError(result.errorMessage);
}
@@ -236,7 +236,8 @@ Could not find ${colors.red(metaCommittish)} in the meta-repo.`);

const subName = paths[0];
const opener = new Open.Opener(repo, null);
const subRepo = yield opener.getSubrepo(subName, false);
const subRepo = yield opener.getSubrepo(subName,
Open.SUB_OPEN_OPTION.FORCE_OPEN);
const metaCommit = yield repo.getCommit(metaAnnotated.id());

// Now that we have an open submodule, we can attempt to resolve
@@ -75,7 +75,8 @@ exports.addSubmodule = co.wrap(function *(repo, url, filename, importArg) {
repo,
filename,
url,
templatePath);
templatePath,
false);
if (null === importArg) {
return subRepo; // RETURN
}
@@ -116,7 +116,9 @@ exports.changeSubmodules = co.wrap(function *(repo,
yield rmrf(name);
}
else if (yield opener.isOpen(name)) {
const subRepo = yield opener.getSubrepo(name, false);
const subRepo =
yield opener.getSubrepo(name,
Open.SUB_OPEN_OPTION.FORCE_OPEN);
yield fetcher.fetchSha(subRepo, name, sub.sha);
const commit = yield subRepo.getCommit(sub.sha);
yield GitUtil.setHeadHard(subRepo, commit);
@@ -446,7 +448,8 @@ exports.pickSubs = co.wrap(function *(metaRepo, opener, metaIndex, subs) {
};
const fetcher = yield opener.fetcher();
const pickSub = co.wrap(function *(name) {
const repo = yield opener.getSubrepo(name, false);
const repo = yield opener.getSubrepo(name,
Open.SUB_OPEN_OPTION.FORCE_OPEN);
const change = subs[name];
const commitText = "(" + GitUtil.shortSha(change.oldSha) + ".." +
GitUtil.shortSha(change.newSha) + "]";
@@ -1021,7 +1021,9 @@ exports.getAmendStatus = co.wrap(function *(repo, options) {
old = new Submodule(commit.url, commit.sha);
}
}
const getRepo = () => opener.getSubrepo(name, false);
const getRepo =
() => opener.getSubrepo(name,
Open.SUB_OPEN_OPTION.FORCE_OPEN);

const result = yield exports.getSubmoduleAmendStatus(currentSub,
old,
Oops, something went wrong.

0 comments on commit a745816

Please sign in to comment.