c# - LibGit2Sharp Find what files were updated/added/deleted after pull -


after running repo.network.pull() command want able see files added repository, altered in repository , removed repository. need file path of file , if add/update or delete.

is there easy way this? i've tried looking diff.compare() i'm not sure if right way it.

libgit2sharp 0.21.0.176

here libgit2 example of walking current commit tree , getting files changed , type of change.

git version:

git log --name-status --pretty=oneline  1d9d4bb881f97f5d3b67741a893f238e7221e2b1 updated readme fork info m       readme.md 58cc5c41963d5ff68556476158c9c0c2499e061c update makefile pe32+ (platform:x64) assemblies m       makefile m       readme.md a7823c1c0a737c5218d33691f98828c78d52130b fix makefile 64-bit native lib , add readme.md m       makefile       readme.md ea7e6722f67569cb9d7a433ff2c036fc630d8561 update solution files. m       mono-curses.csproj m       mono-curses.sln 05dbe6e18895d1037ce333b0a1f652eeae3f8b33 fix resize handling. m       attrib.c m       gui.cs 

libgit2 version:

    var repo = new libgit2sharp.repository ("/your/repo/path");     foreach (commit commit in repo.commits) {         foreach (var parent in commit.parents) {             console.writeline ("{0} | {1}", commit.sha, commit.messageshort);             foreach (treeentrychanges change in repo.diff.compare<treechanges>(parent.tree,             commit.tree)) {                 console.writeline ("{0} : {1}", change.status, change.path);             }         }     } 

output:

1d9d4bb881f97f5d3b67741a893f238e7221e2b1 | updated readme fork info modified : readme.md 58cc5c41963d5ff68556476158c9c0c2499e061c | update makefile pe32+ (platform:x64) assemblies modified : makefile modified : readme.md a7823c1c0a737c5218d33691f98828c78d52130b | fix makefile 64-bit native lib , add readme.md modified : makefile added : readme.md ea7e6722f67569cb9d7a433ff2c036fc630d8561 | update solution files. modified : mono-curses.csproj modified : mono-curses.sln 05dbe6e18895d1037ce333b0a1f652eeae3f8b33 | fix resize handling. modified : attrib.c modified : gui.cs 

in directly answering question, grab first commit commits enumerator , compare tree parents (could more 1 parent due merge) vs. example of looping commits in current branch.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -