libgit2 / libgit2/pygit2

how to diff one file in working dir against a Blob?

Open
#604 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

pygit2 version python3-pygit2-0.23.3-2.fc23.x86_64

I cannot figure out how I can get a diff for only one file.

How do I arrange to have pygit2 return the diff of a Blob against the working dir file?

I looked at calling diff_to_working on a new Index(), but that fails because the new Index() does not
self._repo filled in.

TreeBuilder() seems is unable to help as it requires putting tree objects into the repo to allow
for the folder structure, for example to diff Source/file.py. needs a tree for Source. I clearly
do not want to be writting files into the repo to do a diff.

Did I miss something in API?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the diff_to_working and Index APIs mentioned in the issue, along with how pygit2 represents a Blob and working-directory file. Determine whether an existing API supports this comparison without creating repository tree objects; done means identifying or specifying a supported path for a single-file Blob-to-working-tree diff.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.