1

I am using pygit2 to access that status of the repo

status = repo.status()

for filepath,flags in status.items():
    print ("path %s flags %d", filepath, flags)

I dont seem to be able to find any documentation on how to interpret the flags

Could someone point me in the rigth direction please

GrahamL
  • 243
  • 2
  • 15

2 Answers2

1

The documentation seems to be pretty clear on this:

Repository.status() → {str: int}

Reads the status of the repository and returns a dictionary with file paths as keys and status flags as values. See pygit2.GIT_STATUS_*.

And here you have em: https://github.com/libgit2/pygit2/blob/320ee5e733039d4a3cc952b287498dbc5737c353/src/pygit2.c#L312-L320

Community
  • 1
  • 1
Vampire
  • 35,631
  • 4
  • 76
  • 102
0

You'll need to extract the pygit2 status codes. Here's an example.

Output of git status for some unstaged commits:

On branch master
Changes not staged for commit:
    deleted:    deleted.txt
    modified:   modified.txt
Untracked files:
    added.txt

pygit2 status output

repo.status()
#{'added.txt': 128, 'deleted.txt': 512, 'modified.txt': 256}

Status codes from pygit2

from pygit2 import GIT_STATUS_WT_NEW, GIT_STATUS_WT_DELETED, GIT_STATUS_WT_MODIFIED
print("GIT_STATUS_WT_NEW", GIT_STATUS_WT_NEW)
print("GIT_STATUS_WT_DELETED", GIT_STATUS_WT_DELETED)
print("GIT_STATUS_WT_MODIFIED", GIT_STATUS_WT_MODIFIED)
#GIT_STATUS_WT_NEW 128
#GIT_STATUS_WT_DELETED 512
#GIT_STATUS_WT_MODIFIED 256

For staged commits, the relevant status codes are GIT_STATUS_INDEX_NEW, GIT_STATUS_INDEX_DELETED, GIT_STATUS_INDEX_MODIFIED, and so on.

Mark Teese
  • 651
  • 5
  • 16