How to efficiently generating the diffstat?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 408
- Avg merge
- 2d 57m
- Merged PRs (30d)
- 7
Description
Hi,
I need some help to efficiently generating the diffstat. I would like to get the number of lines added and deleted from one commit to another, like the following command does:
git log --stat
I wrote the following code, but it is pretty slow.
for raw_parent in self.__raw_commit.parents:
diff = self.__raw_commit.tree.diff_to_tree(raw_parent.tree)
self._stats.insertions += diff.stats.insertions
self._stats.deletions += diff.stats.deletions
self._stats.files_changed += diff.stats.files_changed
Do you know a better way to capture this information?
Best regards,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python loop over self.__raw_commit.parents and the tree.diff_to_tree and diff.stats entry points, then compare its goal with git log --stat. Determine whether pygit2 or libgit2 exposes a more efficient way to obtain insertions, deletions, and files changed; done means the approach is identified and produces equivalent diffstat values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100