◐ Shell
clean mode source ↗

Remove `git_commit_tree` which duplicates `commit.getTree()` by rcjsuen · Pull Request #1267 · nodegit/nodegit

Shouldnt that pointer be a nodegit commit object which then gets unwrapped?

No, as the wrapped git_commit object is already the thing that's calling the function.

Current libgit2 API:

var result = git_commit_tree(tree_out, commit)

Current NodeGit API:

// generated version
var result = commit.tree(tree_out)
// custom one written in lib/commit.js
commit.getTree().then(function(tree) {
  // use the tree
});

So as you can see, the generated NodeGit API already knows what the commit object is because that's the object that's calling the tree(tree_out) prototype function. However, it's asking for an actual pointer object to "output" the tree into which doesn't make that much sense in NodeGit's object-oriented API and merely duplicates the functionality of the custom one.

I guess there are technically three (or more?) things we can do here.

  1. Remove the generated tree(tree_out) function as originally suggested.
  2. Remove the custom getTree() function and fix the generated tree(tree_out) function to be a simple tree() promise callback.
  3. Generate tree(tree_out) function privately but don't expose it into the public API and then replace the internal implementation of the custom getTree() function to delegate to the generated tree(tree_out) function.