From 74fa4bfae37e9d7c9e35550c881b114d7a83c4fa Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 28 Feb 2012 16:14:47 -0800 Subject: Update diff to use iterators This is a major reorganization of the diff code. This changes the diff functions to use the iterators for traversing the content. This allowed a lot of code to be simplified. Also, this moved the functions relating to outputting a diff into a new file (diff_output.c). This includes a number of other changes - adding utility functions, extending iterators, etc. plus more tests for the diff code. This also takes the example diff.c program much further in terms of emulating git-diff command line options. --- tests-clar/diff/diff_helpers.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index cd5a0f9a..67a4f1c5 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -29,12 +29,14 @@ int diff_file_fn( diff_expects *e = cb_data; (void)progress; e->files++; - if (delta->old_attr == 0) - e->file_adds++; - else if (delta->new_attr == 0) - e->file_dels++; - else - e->file_mods++; + switch (delta->status) { + case GIT_STATUS_ADDED: e->file_adds++; break; + case GIT_STATUS_DELETED: e->file_dels++; break; + case GIT_STATUS_MODIFIED: e->file_mods++; break; + case GIT_STATUS_IGNORED: e->file_ignored++; break; + case GIT_STATUS_UNTRACKED: e->file_untracked++; break; + default: break; + } return 0; } -- cgit v1.2.1