summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLibravatar Bo Yang <struggleyb.nku@gmail.com>2010-05-06 21:52:27 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-05-07 09:34:27 -0700
commit9ca5df90615aa3c6b60e1bc8f03db6cae98e816c (patch)
tree807f76999f2c9a7aca03d7b308ae8e36bdfd5658 /diff.c
parenttest-lib: Let tests specify commands to be run at end of test (diff)
downloadtgif-9ca5df90615aa3c6b60e1bc8f03db6cae98e816c.tar.xz
Add a macro DIFF_QUEUE_CLEAR.
Refactor the diff_queue_struct code, this macro help to reset the structure. Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/diff.c b/diff.c
index e40c1271da..4a350e365e 100644
--- a/diff.c
+++ b/diff.c
@@ -2540,6 +2540,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
void diff_setup(struct diff_options *options)
{
memset(options, 0, sizeof(*options));
+ memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));
options->file = stdout;
@@ -3457,8 +3458,7 @@ int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1)
diff_free_filepair(q->queue[i]);
free(q->queue);
- q->queue = NULL;
- q->nr = q->alloc = 0;
+ DIFF_QUEUE_CLEAR(q);
return result;
}
@@ -3586,8 +3586,7 @@ void diff_flush(struct diff_options *options)
diff_free_filepair(q->queue[i]);
free_queue:
free(q->queue);
- q->queue = NULL;
- q->nr = q->alloc = 0;
+ DIFF_QUEUE_CLEAR(q);
if (options->close_file)
fclose(options->file);
@@ -3609,8 +3608,7 @@ static void diffcore_apply_filter(const char *filter)
int i;
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
if (!filter)
return;
@@ -3678,8 +3676,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
int i;
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];