| 182 | } |
| 183 | |
| 184 | static void pickaxe(struct diff_queue_struct *q, struct diff_options *o, |
| 185 | regex_t *regexp, kwset_t kws, pickaxe_fn fn) |
| 186 | { |
| 187 | int i; |
| 188 | struct diff_queue_struct outq = DIFF_QUEUE_INIT; |
| 189 | |
| 190 | if (o->pickaxe_opts & DIFF_PICKAXE_ALL) { |
| 191 | /* Showing the whole changeset if needle exists */ |
| 192 | for (i = 0; i < q->nr; i++) { |
| 193 | struct diff_filepair *p = q->queue[i]; |
| 194 | if (pickaxe_match(p, o, regexp, kws, fn)) |
| 195 | return; /* do not munge the queue */ |
| 196 | } |
| 197 | |
| 198 | /* |
| 199 | * Otherwise we will clear the whole queue by copying |
| 200 | * the empty outq at the end of this function, but |
| 201 | * first clear the current entries in the queue. |
| 202 | */ |
| 203 | for (i = 0; i < q->nr; i++) |
| 204 | diff_free_filepair(q->queue[i]); |
| 205 | } else { |
| 206 | /* Showing only the filepairs that have the needle */ |
| 207 | for (i = 0; i < q->nr; i++) { |
| 208 | struct diff_filepair *p = q->queue[i]; |
| 209 | if (pickaxe_match(p, o, regexp, kws, fn)) |
| 210 | diff_q(&outq, p); |
| 211 | else |
| 212 | diff_free_filepair(p); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | free(q->queue); |
| 217 | *q = outq; |
| 218 | } |
| 219 | |
| 220 | static void regcomp_or_die(regex_t *regex, const char *needle, int cflags) |
| 221 | { |
no test coverage detected