From 2187742d74f58bd51d7ee6cb20e39808ebb16676 Mon Sep 17 00:00:00 2001 From: John Haley Date: Wed, 20 Jan 2016 23:05:54 -0700 Subject: [PATCH] Add `mergeOptions` to `Repository#mergeBranches` --- lib/repository.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 8234ce083..31390f0ed 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -725,7 +725,6 @@ Repository.prototype.fetchAll = function( }); }; - /** * Merge a branch onto another branch * @@ -733,15 +732,18 @@ Repository.prototype.fetchAll = function( * @param {String|Ref} from * @param {Signature} signature * @param {Merge.PREFERENCE} mergePreference + * @param {MergeOptions} mergeOptions * @return {Oid|Index} A commit id for a succesful merge or an index for a * merge with conflicts */ Repository.prototype.mergeBranches = - function(to, from, signature, mergePreference) { + function(to, from, signature, mergePreference, mergeOptions) { var repo = this; var fromBranch; var toBranch; + mergePreference = mergePreference || NodeGit.Merge.PREFERENCE.NONE; + mergeOptions = normalizeOptions(mergeOptions, NodeGit.MergeOptions); signature = signature || repo.defaultSignature(); @@ -806,7 +808,12 @@ Repository.prototype.mergeBranches = }) .then(function(headRef) { updateHead = !!headRef && (headRef.name() === toBranch.name()); - return NodeGit.Merge.commits(repo, toCommitOid, fromCommitOid); + return NodeGit.Merge.commits( + repo, + toCommitOid, + fromCommitOid, + mergeOptions + ); }) .then(function(index) { // if we have conflicts then throw the index @@ -834,8 +841,8 @@ Repository.prototype.mergeBranches = [toCommitOid, fromCommitOid]); }) .then(function(commit) { - // // we've updated the checked out branch, so make sure we update - // // head so that our index isn't messed up + // we've updated the checked out branch, so make sure we update + // head so that our index isn't messed up if (updateHead) { return repo.getBranch(to) .then(function(branch) {