Skip to content

Commit 36ee76e

Browse files
committed
Document GIT_STATUS_
Fixes #509
1 parent da41096 commit 36ee76e

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
- Drop support for PyPy3 7.2
1111

1212
- Documentation
13+
`#509 <https://github.com/libgit2/pygit2/issues/509>`_
1314
`#752 <https://github.com/libgit2/pygit2/issues/752>`_
1415
`#1037 <https://github.com/libgit2/pygit2/issues/1037>`_
1516

1617
- ``Repository.__init__(...)`` now takes flags eg ``GIT_REPOSITORY_OPEN_BARE``,
17-
new ``GIT_REPOSITORY_OPEN_*`` constants
18-
`#1044 <https://github.com/libgit2/pygit2/pull/1044>`_
18+
new ``GIT_REPOSITORY_OPEN_*`` constants
19+
`#1044 <https://github.com/libgit2/pygit2/pull/1044>`_
20+
1921

2022
1.3.0 (2020-09-18)
2123
-------------------------

docs/index_file.rst

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,44 @@ The IndexEntry type
5454
Status
5555
====================
5656

57-
.. automethod:: pygit2.Repository.status
58-
.. automethod:: pygit2.Repository.status_file
57+
.. autoclass:: pygit2.Repository
58+
:members: status_file
59+
:noindex:
60+
61+
.. automethod:: Repository.status
62+
63+
Example, inspect the status of the repository::
64+
65+
from pygit2 import GIT_STATUS_CURRENT
66+
status = repo.status()
67+
for filepath, flags in status.items():
68+
if flags != GIT_STATUS_CURRENT:
69+
print("Filepath %s isn't clean" % filepath)
70+
71+
This is the list of status flags for a single file::
72+
73+
GIT_STATUS_CURRENT
74+
GIT_STATUS_INDEX_NEW
75+
GIT_STATUS_INDEX_MODIFIED
76+
GIT_STATUS_INDEX_DELETED
77+
GIT_STATUS_INDEX_RENAMED
78+
GIT_STATUS_INDEX_TYPECHANGE
79+
GIT_STATUS_WT_NEW
80+
GIT_STATUS_WT_MODIFIED
81+
GIT_STATUS_WT_DELETED
82+
GIT_STATUS_WT_TYPECHANGE
83+
GIT_STATUS_WT_RENAMED
84+
GIT_STATUS_WT_UNREADABLE
85+
GIT_STATUS_IGNORED
86+
GIT_STATUS_CONFLICTED
87+
88+
A combination of these values will be returned to indicate the status of a
89+
file. Status compares the working directory, the index, and the current HEAD
90+
of the repository. The `GIT_STATUS_INDEX` set of flags represents the status
91+
of file in the index relative to the HEAD, and the `GIT_STATUS_WT` set of flags
92+
represent the status of the file in the working directory relative to the
93+
index.
5994

60-
Inspect the status of the repository::
61-
62-
>>> from pygit2 import GIT_STATUS_CURRENT
63-
>>> status = repo.status()
64-
>>> for filepath, flags in status.items():
65-
... if flags != GIT_STATUS_CURRENT:
66-
... print("Filepath %s isn't clean" % filepath)
6795

6896

6997
Checkout

0 commit comments

Comments
 (0)