libgit2 / libgit2/pygit2

repo.status() appears to be broken?

Open
#684 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm running repo.status().items() in a pre-commit hook using the -a flag (git commit -a -m "Test"), and I get a result that looks like this:

[('config/git_hooks/pre-commit', 256), ('bin/run_flake8', 256)]

If I run git status in that same process, I get:

On branch ops_1331_fix
Your branch is ahead of 'origin/ops_1331_fix' by 2 commits.
  (use "git push" to publish your local commits)
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   bin/run_flake8
    modified:   config/git_hooks/pre-commit

In other words, pygit2 is reporting those files as not being staged, and git is reporting them as being staged. Why the discrepancy?

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 reproducing the discrepancy with repo.status().items() in the pre-commit hook while using git commit -a, then compare its result with git status for the two listed files. Read the pygit2 status API and the related libgit2 behavior; done means explaining why staged files receive status 256 and correcting the mismatch if it is a bug.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.