GitPython "blame" does not give me all changed lines
<p>I am using GitPython. Below I print the total number of lines changed in a specific commit: <code>f092795fe94ba727f7368b63d8eb1ecd39749fc4</code>:</p>

<pre><code>from git import Repo

repo = Repo("C:/Users/shiro/Desktop/lucene-solr/")

sum_lines = 0
for blame_commit, lines_list in repo.blame('HEAD', 'lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java'):
    if blame_commit.hexsha == 'f092795fe94ba727f7368b63d8eb1ecd39749fc4':
        sum_lines += len(lines_list)
print sum_lines
</code></pre>

<p>The output is 38. However, if you simply go to <a href="https://github.com/apache/lucene-solr/commit/f092795fe94ba727f7368b63d8eb1ecd39749fc4" rel="nofollow">https://github.com/apache/lucene-solr/commit/f092795fe94ba727f7368b63d8eb1ecd39749fc4</a> and look at the commit yourself for file <code>/lucene/analysis/Analyzer.java</code>, the actual number of lines changed is not 38 but it is 47. Some lines are completely missing.</p>

<p>Why am I getting a wrong value ?</p>

<p><code>git blame</code> tells you which commit last changed each line in a given file.</p>

<p>You're not counting the number of lines changed in that commit, but rather the number of lines in the file at your current HEAD that were last modified by that specific commit.</p>

<p>Changing <code>HEAD</code> to <code>f092795fe94ba727f7368b63d8eb1ecd39749fc4</code> should give you the result you expect.</p>

<pre><code>$ git blame f092795fe94ba727f7368b63d8eb1ecd39749fc4 ./lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java | grep f092795 | wc -l
47
$ git blame master ./lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java | grep f092795 | wc -l
38
</code></pre>

python git gitpython