Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List modified files for a commit #59

Closed
ghost opened this issue Sep 9, 2011 · 8 comments
Closed

List modified files for a commit #59

ghost opened this issue Sep 9, 2011 · 8 comments

Comments

@ghost
Copy link

ghost commented Sep 9, 2011

Hi,
How to, with a specific commit, get a list of modified files?

Thanks

@tclem
Copy link
Member

tclem commented Sep 9, 2011

You might take a look at https://github.com/nulltoken/libgit2sharp/commits/topic/status. This functionality is currently a WIP.

@tclem tclem closed this as completed Sep 9, 2011
@nulltoken
Copy link
Member

@renald full Diff is not available yet. However, provided all you want is a list of list of new/modified/removed files between two commits, you might more or less achieve your goal with the following recipe:

  • retreive two commits (A and B)
  • recursively walk their tree entries
  • compare tree entries by type, name and, for blobs, by oids
    • same oids, same names -> no change
    • same oids, different names -> renamed
    • same name, different oids -> modified
    • similarly you should be able to detect added and removed files

If you're after the list of modified files one is about to commit, then @tclem hint is the way to follow. I hope it won't be long before it gets merged.

Hope this helps.

@Rdot
Copy link

Rdot commented Dec 10, 2012

Hello - Has this issue been added to the libgit2sharp source?

I want to get just the files modified during a commit, something like the git command

git show --pretty="format:" --name-only sha.

Thanks,

@nulltoken
Copy link
Member

@Rdot Maybe this test would fit your need.

It demonstrates how to compare two commit trees, and, more specifically, the current Head against its parent.

Of course, by peeking at the others tests in the file, you'll see that you can compare any couple of Trees within the boundary of the Repository.

@Rdot
Copy link

Rdot commented Dec 10, 2012

@nulltoken Very awesome, exactly what I needed. Thanks for the link 👍

@bashtavenko
Copy link

This is nice, but how can get the number of lines added, deleted modified for the given sha? (git show -w -C -shortstat ..)

@nulltoken
Copy link
Member

@StanBPublic We try to keep the tracker for issues and features. Could you please direct this question to StackOverflow (there's a libgit2sharp tag). We'll be happy to answer you there.

@ColinNg
Copy link

ColinNg commented Dec 6, 2017

Hi, I think the original question isn't actually answered.
The Hitchhiker's guide on [git-log-name-status] (https://github.com/libgit2/libgit2sharp/wiki/git-log-name-status) returns a different list of files than what I get through:
git log --name-only 0138ef5..899809f
It also takes a LOT longer than git log --name-only (instant) vs. 20.633 seconds.
I have also tried StackOverflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants