MCPcopy Create free account
hub / github.com/git/git / grep_source_name

Function grep_source_name

builtin/grep.c:329–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329static 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
361static int grep_oid(struct grep_opt *opt, const struct object_id *oid,
362 const char *filename, int tree_name_len,

Callers 2

grep_oidFunction · 0.85
grep_fileFunction · 0.85

Calls 7

relative_pathFunction · 0.85
strbuf_addFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_releaseFunction · 0.85
quote_pathFunction · 0.85
quote_c_styleFunction · 0.85
strbuf_insertFunction · 0.85

Tested by

no test coverage detected