2 * Copyright (C) 2005 Junio C Hamano
9 static int contains(struct diff_filespec
*one
,
10 const char *needle
, unsigned long len
)
12 unsigned long offset
, sz
;
14 if (diff_populate_filespec(one
))
18 for (offset
= 0; offset
+ len
<= sz
; offset
++)
19 if (!strncmp(needle
, data
+ offset
, len
))
24 void diff_pickaxe(const char *needle
)
26 struct diff_queue_struct
*q
= &diff_queued_diff
;
27 unsigned long len
= strlen(needle
);
29 struct diff_queue_struct outq
;
31 outq
.nr
= outq
.alloc
= 0;
33 for (i
= 0; i
< q
->nr
; i
++) {
34 struct diff_filepair
*p
= q
->queue
[i
];
35 if (!DIFF_FILE_VALID(p
->one
)) {
36 if (!DIFF_FILE_VALID(p
->two
))
37 continue; /* ignore nonsense */
39 if (contains(p
->two
, needle
, len
))
40 diff_queue(&outq
, p
->one
, p
->two
);
42 else if (!DIFF_FILE_VALID(p
->two
)) {
43 if (contains(p
->one
, needle
, len
))
44 diff_queue(&outq
, p
->one
, p
->two
);
46 else if (contains(p
->one
, needle
, len
) !=
47 contains(p
->two
, needle
, len
))
48 diff_queue(&outq
, p
->one
, p
->two
);
50 for (i
= 0; i
< q
->nr
; i
++) {
51 struct diff_filepair
*p
= q
->queue
[i
];