7
$\begingroup$

How can I retrieve the list of files that were changed in a commit using GitLink?

I can open a repo like this:

repo = GitOpen["~/Repos/GitLink"]

Now I can get the list of commits:

commits = GitRange[repo, "HEAD"];

I can examine the state of the repository at a certain commit using GitExpandTree:

GitExpandTree[commits[[1]]]

enter image description here

In principle, I could take two commits, expand all subtrees, then check which blobs have a differing "SHA" property. This sounds complicated and I am sure there is a simple, direct way. Unfortunately, I cannot find it.


Note: I know that this could be done by running the external git executable, but I would like to know if it can be done using GitLink directly.

$\endgroup$
5
$\begingroup$

GitLink`Private`gitDiffTrees seems to do the job:

GitLink`Private`gitDiffTrees[
  ToGitObject[repo, "HEAD"]["Tree"],
  ToGitObject[repo, "HEAD^1"]["Tree"]
]

{ list of files }

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.