How to get diff of one file with libgit2?

Is there a function equivalent to git diff FILE in libgit2 ? In other words, how to get diff efficiently for a single file without having libgit2 to view other files in the working directory?

+4
source share
1 answer

git diff FILE display the changes you made regarding the index.

This can be achieved using the libgit2 function git_diff_index_to_workdir() .

This function takes the git_diff_options structure as a parameter into which you can specify pathspec or a list of pathspec types that you are particularly interested in.

Additional Information:

+5
source

Source: https://habr.com/ru/post/1480915/


All Articles