use chars like +,-,... for diff_delta_t in Patch.status

This commit is contained in:
Nico von Geyso 2013-05-06 13:29:37 +02:00
parent f972d99d5f
commit f572a8fb00
4 changed files with 5 additions and 14 deletions

View File

@ -62,7 +62,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
if (py_patch != NULL) {
py_patch->old_file_path = delta->old_file.path;
py_patch->new_file_path = delta->new_file.path;
py_patch->status = delta->status;
py_patch->status = git_diff_status_char(delta->status);
py_patch->similarity = delta->similarity;
py_patch->old_oid = git_oid_allocfmt(&delta->old_file.oid);
py_patch->new_oid = git_oid_allocfmt(&delta->new_file.oid);
@ -126,7 +126,7 @@ PyMemberDef Patch_members[] = {
MEMBER(Patch, new_file_path, T_STRING, "new file path"),
MEMBER(Patch, old_oid, T_STRING, "old oid"),
MEMBER(Patch, new_oid, T_STRING, "new oid"),
MEMBER(Patch, status, T_INT, "status"),
MEMBER(Patch, status, T_CHAR, "status"),
MEMBER(Patch, similarity, T_INT, "similarity"),
MEMBER(Patch, hunks, T_OBJECT, "hunks"),
{NULL}

View File

@ -329,15 +329,6 @@ moduleinit(PyObject* m)
ADD_CONSTANT_INT(m, GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED)
/* --break-rewrites=/M */
ADD_CONSTANT_INT(m, GIT_DIFF_FIND_AND_BREAK_REWRITES)
/* Flags for diff deltas */
ADD_CONSTANT_INT(m, GIT_DELTA_UNMODIFIED)
ADD_CONSTANT_INT(m, GIT_DELTA_ADDED)
ADD_CONSTANT_INT(m, GIT_DELTA_DELETED)
ADD_CONSTANT_INT(m, GIT_DELTA_MODIFIED)
ADD_CONSTANT_INT(m, GIT_DELTA_RENAMED)
ADD_CONSTANT_INT(m, GIT_DELTA_COPIED)
ADD_CONSTANT_INT(m, GIT_DELTA_IGNORED)
ADD_CONSTANT_INT(m, GIT_DELTA_UNTRACKED)
/* Config */
INIT_TYPE(ConfigType, NULL, PyType_GenericNew)

View File

@ -111,7 +111,7 @@ typedef struct {
const char * new_file_path;
char* old_oid;
char* new_oid;
unsigned status;
char status;
unsigned similarity;
} Patch;

View File

@ -219,9 +219,9 @@ class DiffTest(utils.BareRepoTestCase):
#~ Must pass GIT_DIFF_INCLUDE_UNMODIFIED if you expect to emulate
#~ --find-copies-harder during rename transformion...
diff = commit_a.tree.diff(commit_b.tree, GIT_DIFF_INCLUDE_UNMODIFIED)
self.assertAll(lambda x: x.status is not pygit2.GIT_DELTA_RENAMED, diff)
self.assertAll(lambda x: x.status != 'R', diff)
diff.find_similar()
self.assertAny(lambda x: x.status is pygit2.GIT_DELTA_RENAMED, diff)
self.assertAny(lambda x: x.status == 'R', diff)
if __name__ == '__main__':
unittest.main()