Add DiffHunk.header

Commes from PR #346
This commit is contained in:
J. David Ibáñez
2015-03-30 17:36:11 +02:00
parent ca39a65054
commit da98890bd1
2 changed files with 5 additions and 0 deletions

View File

@@ -121,6 +121,8 @@ wrap_diff_hunk(git_patch *patch, size_t idx)
py_hunk->old_lines = hunk->old_lines; py_hunk->old_lines = hunk->old_lines;
py_hunk->new_start = hunk->new_start; py_hunk->new_start = hunk->new_start;
py_hunk->new_lines = hunk->new_lines; py_hunk->new_lines = hunk->new_lines;
py_hunk->header = to_unicode_n((const char *) &hunk->header,
hunk->header_len, NULL, NULL);
py_hunk->lines = PyList_New(lines_in_hunk); py_hunk->lines = PyList_New(lines_in_hunk);
for (j = 0; j < lines_in_hunk; ++j) { for (j = 0; j < lines_in_hunk; ++j) {
@@ -497,6 +499,7 @@ cleanup:
static void static void
DiffHunk_dealloc(DiffHunk *self) DiffHunk_dealloc(DiffHunk *self)
{ {
Py_CLEAR(self->header);
Py_CLEAR(self->lines); Py_CLEAR(self->lines);
PyObject_Del(self); PyObject_Del(self);
} }
@@ -506,6 +509,7 @@ PyMemberDef DiffHunk_members[] = {
MEMBER(DiffHunk, old_lines, T_INT, "Old lines."), MEMBER(DiffHunk, old_lines, T_INT, "Old lines."),
MEMBER(DiffHunk, new_start, T_INT, "New start."), MEMBER(DiffHunk, new_start, T_INT, "New start."),
MEMBER(DiffHunk, new_lines, T_INT, "New lines."), MEMBER(DiffHunk, new_lines, T_INT, "New lines."),
MEMBER(DiffHunk, header, T_OBJECT, "Header."),
MEMBER(DiffHunk, lines, T_OBJECT, "Lines."), MEMBER(DiffHunk, lines, T_OBJECT, "Lines."),
{NULL} {NULL}
}; };

View File

@@ -140,6 +140,7 @@ typedef struct {
int old_lines; int old_lines;
int new_start; int new_start;
int new_lines; int new_lines;
PyObject *header;
} DiffHunk; } DiffHunk;
typedef struct { typedef struct {