src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.9k stars 540 forks source link

Get diff of first commit #868

Open davidwartell opened 6 years ago

davidwartell commented 6 years ago

Trying to iterate all commits for a repository and unable to get diff of first commit which has no parents.

Try loading tree by hash 4b825dc642cb6eb9a060e54bf8d69288fbee4904 and that is not found. What do I call patch against to get a diff of first commit? e.g. helpMe.Patch(firstCommit)

git-python supports this for example with NULL_TREE

smola commented 6 years ago

As far as I know, this is not supported yet, unless you manually create an empty tree that can be fed to patch. We could provide such tree as a variable or modify Patch/DiffTree to allow nil.

markhuge commented 5 years ago

Was there any more discussion on this elsewhere, or another pattern that achieves the same result?