summaryrefslogtreecommitdiff
path: root/examples/diff.c
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-02-28 09:40:17 +0100
committerVicent Marti <vicent@github.com>2014-02-28 09:40:17 +0100
commit06d41826b6f85d83e68973e0565978b6b3e8976f (patch)
tree74ca53d8808a16090bb4df867b38c4a07444f8e1 /examples/diff.c
parent1574d3884f020c072f68c08785e199732e438e34 (diff)
parent6789b7a75d1e24a7f4ce34628c6b4561517f0b73 (diff)
downloadlibgit2-06d41826b6f85d83e68973e0565978b6b3e8976f.tar.gz
Merge pull request #2146 from libgit2/rb/diff-b2b
Add git_diff_buffers and git_patch_from_buffers
Diffstat (limited to 'examples/diff.c')
-rw-r--r--examples/diff.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/diff.c b/examples/diff.c
index abb9b7103..de994ecab 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -269,19 +269,23 @@ static void diff_print_numstat(git_diff *diff)
{
git_patch *patch;
const git_diff_delta *delta;
- size_t i;
- size_t ndeltas;
+ size_t d, ndeltas = git_diff_num_deltas(diff);
size_t nadditions, ndeletions;
- ndeltas = git_diff_num_deltas(diff);
- for (i = 0; i < ndeltas; i++){
+
+ for (d = 0; d < ndeltas; d++){
check_lg2(
- git_patch_from_diff(&patch, diff, i),
+ git_patch_from_diff(&patch, diff, d),
"generating patch from diff", NULL);
+
check_lg2(
git_patch_line_stats(NULL, &nadditions, &ndeletions, patch),
"generating the number of additions and deletions", NULL);
+
delta = git_patch_get_delta(patch);
- printf("%u\t%u\t%s\n", nadditions, ndeletions, delta->new_file.path);
+
+ printf("%ld\t%ld\t%s\n",
+ (long)nadditions, (long)ndeletions, delta->new_file.path);
+
+ git_patch_free(patch);
}
- git_patch_free(patch);
}