Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am looking to get only the diff of a file changed from a git repo. Right now, I am using gitpython to actually get the commit objects and the files of git changes, but I want to do a dependency analysis on only the parts of the file changed. Is there any way to get the git diff from git python? Or am I going to have to compare each of the files by reading line by line?

share|improve this question
add comment

1 Answer

Git does not store the diffs, as you have noticed. Given two blobs (before and after a change), you can use Python's difflib module to compare the data.

share|improve this answer
 
The repo I am working on only has one master branch. If I am trying to get two blobs, how do i get a second one to compare the before change? –  user1816561 Nov 19 at 16:15
 
Sorry, just another question. So beyond trying to get both the a blob and b blob and understanding what those are, will those blobs actually give me the content of the file changed? –  user1816561 Nov 19 at 17:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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