4

In git we can use following command to achieve it:

git merge branch_name --strategy-option theirs

But I couldn't figure out a way in nodegit: http://www.nodegit.org/api/repository/#mergeBranches

 repo.mergeBranches("master.min", "master", null, merge.PREFERENCE.FASTFORWARD_ONLY);

A file favor enum is present

http://www.nodegit.org/api/merge/#FILE_FAVOR

But repo.mergeBranches() expects PREFERENCE enum. How do I pass FILE_FAVOR enum for merge.

Edit: Adding a tracking issue:

https://github.com/nodegit/nodegit/issues/858

adnan kamili
  • 8,967
  • 7
  • 65
  • 125

2 Answers2

1

For now (January 2015), you don't.

The way Repository.prototype.mergeBranches (lib/repository.js#L730-L745) is implemented, it doesn't take into account any FILE_FAVOR option (used by their vendored libgit2).

That could be the topic of a PR (Pull Request) similar to PR 633 (which introduced the options --no-ff and --ff-only)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

You cannot using the repo.mergeBranches function as of now (although I'll make an issue so we can fix that), but if you look at the source for repo.mergeBranches, you can see how we call into nodegit.merge more directly (mergebranches is a js convenience wrapper), which does take a mergeoptions allowing you to pass file preference and other enums (as of jan 2016).

MaxK
  • 424
  • 3
  • 9