| 327 | } |
| 328 | |
| 329 | static void grep_source_name(struct grep_opt *opt, const char *filename, |
| 330 | int tree_name_len, struct strbuf *out) |
| 331 | { |
| 332 | strbuf_reset(out); |
| 333 | |
| 334 | if (opt->null_following_name) { |
| 335 | if (opt->relative && grep_prefix) { |
| 336 | struct strbuf rel_buf = STRBUF_INIT; |
| 337 | const char *rel_name = |
| 338 | relative_path(filename + tree_name_len, |
| 339 | grep_prefix, &rel_buf); |
| 340 | |
| 341 | if (tree_name_len) |
| 342 | strbuf_add(out, filename, tree_name_len); |
| 343 | |
| 344 | strbuf_addstr(out, rel_name); |
| 345 | strbuf_release(&rel_buf); |
| 346 | } else { |
| 347 | strbuf_addstr(out, filename); |
| 348 | } |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | if (opt->relative && grep_prefix) |
| 353 | quote_path(filename + tree_name_len, grep_prefix, out, 0); |
| 354 | else |
| 355 | quote_c_style(filename + tree_name_len, out, NULL, 0); |
| 356 | |
| 357 | if (tree_name_len) |
| 358 | strbuf_insert(out, 0, filename, tree_name_len); |
| 359 | } |
| 360 | |
| 361 | static int grep_oid(struct grep_opt *opt, const struct object_id *oid, |
| 362 | const char *filename, int tree_name_len, |
no test coverage detected