| 359 | } |
| 360 | |
| 361 | static int grep_oid(struct grep_opt *opt, const struct object_id *oid, |
| 362 | const char *filename, int tree_name_len, |
| 363 | const char *path) |
| 364 | { |
| 365 | struct strbuf pathbuf = STRBUF_INIT; |
| 366 | struct grep_source gs; |
| 367 | |
| 368 | grep_source_name(opt, filename, tree_name_len, &pathbuf); |
| 369 | grep_source_init_oid(&gs, pathbuf.buf, path, oid, opt->repo); |
| 370 | strbuf_release(&pathbuf); |
| 371 | |
| 372 | if (num_threads > 1) { |
| 373 | /* |
| 374 | * add_work() copies gs and thus assumes ownership of |
| 375 | * its fields, so do not call grep_source_clear() |
| 376 | */ |
| 377 | add_work(opt, &gs); |
| 378 | return 0; |
| 379 | } else { |
| 380 | int hit; |
| 381 | |
| 382 | hit = grep_source(opt, &gs); |
| 383 | |
| 384 | grep_source_clear(&gs); |
| 385 | return hit; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | static int grep_file(struct grep_opt *opt, const char *filename) |
| 390 | { |
no test coverage detected