Skip to content

Loading…

Add additions and deletions for patch. #275

Merged
merged 1 commit into from

2 participants

@xtao

Add additions and deletions for patch.

@jdavid jdavid merged commit c6d2a65 into libgit2:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 30, 2013
  1. @xtao
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +6 −1 src/diff.c
  2. +2 −0 src/types.h
View
7 src/diff.c
@@ -63,7 +63,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
const git_diff_delta* delta;
const git_diff_range* range;
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;
char line_origin;
int err;
@@ -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->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);
py_patch->hunks = PyList_New(hunk_amounts);
@@ -152,6 +155,8 @@ PyMemberDef Patch_members[] = {
MEMBER(Patch, status, T_CHAR, "status"),
MEMBER(Patch, similarity, T_INT, "similarity"),
MEMBER(Patch, hunks, T_OBJECT, "hunks"),
+ MEMBER(Patch, additions, T_INT, "additions"),
+ MEMBER(Patch, deletions, T_INT, "deletions"),
{NULL}
};
View
2 src/types.h
@@ -113,6 +113,8 @@ typedef struct {
char* new_oid;
char status;
unsigned similarity;
+ unsigned additions;
+ unsigned deletions;
} Patch;
typedef struct {
Something went wrong with that request. Please try again.