1

Having fetched commits from origin/master with nodegit, is there any way to detect that the local repository has diverged from the origin?

Basically I'm after a way to do the equivalent of the command line...

$ git status
On branch master
Your branch and 'origin/master' have diverged

I have tried using repo.getStatus().then(...), but it resolves to an empty list.

Rob Agar
  • 12,337
  • 5
  • 48
  • 63
  • I guess it's encoded in error code. Can you check error code? – 0andriy Feb 14 '20 at 17:08
  • no, I get nothing from the repo.fetchAll method - it resolves to void – Rob Agar Feb 14 '20 at 17:29
  • 1
    `git status` is overloaded on the command-line and includes additional information (eg, ahead/behind count). But that's not part of the repository's status, which is really just a union of the diff of the index to the head and the workdir to the index. You want the information about the local branch vs the upstream to get ahead/behind count. NodeGit may wrap git_graph_ahead_behind, which is the easiest way to get this information https://github.com/libgit2/libgit2/blob/e6cdd17c846648aa8e1e025fa1988475886a551e/include/git2/graph.h#L37 If not, you can diff your branch with the upstream. – Edward Thomson Feb 20 '20 at 14:06

0 Answers0