Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additions and deletions for patch. #275

Merged
merged 1 commit into from Oct 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/diff.c
Expand Up @@ -63,7 +63,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
const git_diff_delta* delta; const git_diff_delta* delta;
const git_diff_range* range; const git_diff_range* range;
git_diff_patch* patch = NULL; git_diff_patch* patch = NULL;
size_t i, j, hunk_amounts, lines_in_hunk, line_len, header_len; size_t i, j, hunk_amounts, lines_in_hunk, line_len, header_len, additions, deletions;
const char* line, *header; const char* line, *header;
char line_origin; char line_origin;
int err; int err;
Expand All @@ -84,6 +84,9 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
py_patch->old_oid = git_oid_allocfmt(&delta->old_file.oid); py_patch->old_oid = git_oid_allocfmt(&delta->old_file.oid);
py_patch->new_oid = git_oid_allocfmt(&delta->new_file.oid); py_patch->new_oid = git_oid_allocfmt(&delta->new_file.oid);


git_diff_patch_line_stats(NULL, &additions, &deletions, patch);
py_patch->additions = additions;
py_patch->deletions = deletions;


hunk_amounts = git_diff_patch_num_hunks(patch); hunk_amounts = git_diff_patch_num_hunks(patch);
py_patch->hunks = PyList_New(hunk_amounts); py_patch->hunks = PyList_New(hunk_amounts);
Expand Down Expand Up @@ -152,6 +155,8 @@ PyMemberDef Patch_members[] = {
MEMBER(Patch, status, T_CHAR, "status"), MEMBER(Patch, status, T_CHAR, "status"),
MEMBER(Patch, similarity, T_INT, "similarity"), MEMBER(Patch, similarity, T_INT, "similarity"),
MEMBER(Patch, hunks, T_OBJECT, "hunks"), MEMBER(Patch, hunks, T_OBJECT, "hunks"),
MEMBER(Patch, additions, T_INT, "additions"),
MEMBER(Patch, deletions, T_INT, "deletions"),
{NULL} {NULL}
}; };


Expand Down
2 changes: 2 additions & 0 deletions src/types.h
Expand Up @@ -113,6 +113,8 @@ typedef struct {
char* new_oid; char* new_oid;
char status; char status;
unsigned similarity; unsigned similarity;
unsigned additions;
unsigned deletions;
} Patch; } Patch;


typedef struct { typedef struct {
Expand Down