-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
diffSummary is incorrect for the first commit #1035
Comments
This is my fix for now: const EMPTY_TREE = { hash: "4b825dc642cb6eb9a060e54bf8d69288fbee4904" }
const diffs = []
for (let i = all.length - 1; i > 0; i--) {
const isFirst = i === all.length - 1
const olderCommit = isFirst ? EMPTY_TREE : all[i]
const newerCommit = isFirst ? all[i] : all[i-1]
const diff = await fromRepo.diffSummary([olderCommit.hash, newerCommit.hash])
// Fix bug where diffSummary doesn't return correct values for the first commit
if (isFirst) {
diff.insertions = diff.changed
diff.deletions = 0
diff.files = diff.files.map(f => {
if (f.binary) {
return f
}
f.insertions = f.changes
f.deletions = 0
return f
})
}
diffs.push(diff)
} |
Hello, thank you for the detailed issue description! The cause of the problem is that there are files larger than For a diff between the empty tree commit and any other commit, you can avoid this by using the
|
When comparing the first commit with the empty tree to see what changes the first commit introduced it displays the "changes" correctly but additions/deletions are wrong.
Git Output:
git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 8a424bd942b041bc924989e8ab3c77a63e26826d
git-js Output:
The text was updated successfully, but these errors were encountered: