I am trying to follow these instructions to perform a cherry-pick in a bare repository. This is what I ended up with:
async cherryPickWithMessage(localBranch: string, commit: string, message: string) {
const theirCommit = await this.repo.getCommit(commit);
const ourCommit = await this.repo.getBranchCommit(localBranch);
const base = await Git.Merge.base(this.repo, theirCommit.id(), ourCommit.id());
// nodegit has a bug that causes .parent() to return a "partial" commit that
// cannot be used for subsequent operations such as .getTree(). See
// https://github.com/nodegit/nodegit/pull/1110.
const baseTreeId = await theirCommit.parent(0).then(c => c.treeId());
const baseTree = await this.repo.getTree(baseTreeId);
const theirTree = await theirCommit.getTree();
const ourTree = await ourCommit.getTree();
// This does not work.
const index = await Git.Merge.trees(this.repo, baseTree, ourTree, theirTree, null);
const newTreeId = await index.writeTree();
const ownCommitterSignature = theirCommit.committer(); // TODO
return await this.repo.createCommit(localBranch, theirCommit.author(), ownCommitterSignature, message, newTreeId, [ourCommit]).then(id => id.tostrS());
}
The critical point is calling Git.Merge.trees. The documentation says that the fifth parameter is optional:
the merge tree options (or null for defaults)
However, when passing the options as described above, this error is thrown (which might be a bug):
Error: MergeOptions opts is required.
at F:\node-cq\node_modules\nodegit-promise\lib\node-extensions.js:24:20
at tryCallTwo (F:\node-cq\node_modules\nodegit-promise\lib\core.js:45:5)
at doResolve (F:\node-cq\node_modules\nodegit-promise\lib\core.js:173:13)
at new Promise (F:\node-cq\node_modules\nodegit-promise\lib\core.js:65:3)
at Function.trees (F:\node-cq\node_modules\nodegit-promise\lib\node-extensions.js:19:12)
at LG2Repository.<anonymous> (F:\node-cq\lib\local-git\libgit2.ts:42:35)
at Generator.next (<anonymous>)
at fulfilled (F:\node-cq\lib\local-git\libgit2.ts:4:58)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
I tried passing an empty object {} as the opts parameter, which causes a CRT assertion (which - I assume - is definitely a bug):

Is there a proper way to use this API without triggering an assertion or error?
I am trying to follow these instructions to perform a cherry-pick in a bare repository. This is what I ended up with:
The critical point is calling
Git.Merge.trees. The documentation says that the fifth parameter is optional:However, when passing the options as described above, this error is thrown (which might be a bug):
I tried passing an empty object
{}as theoptsparameter, which causes a CRT assertion (which - I assume - is definitely a bug):Is there a proper way to use this API without triggering an assertion or error?