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

Function setup_additional_headers

log-tree.c:981–1012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979}
980
981static void setup_additional_headers(struct diff_options *o,
982 struct strmap *all_headers)
983{
984 struct hashmap_iter iter;
985 struct strmap_entry *entry;
986
987 /*
988 * Make o->additional_path_headers contain the subset of all_headers
989 * that match o->pathspec. If there aren't any that match o->pathspec,
990 * then make o->additional_path_headers be NULL.
991 */
992
993 if (!o->pathspec.nr) {
994 o->additional_path_headers = all_headers;
995 return;
996 }
997
998 o->additional_path_headers = xmalloc(sizeof(struct strmap));
999 strmap_init_with_options(o->additional_path_headers, NULL, 0);
1000 strmap_for_each_entry(all_headers, &iter, entry) {
1001 if (match_pathspec(the_repository->index, &o->pathspec,
1002 entry->key, strlen(entry->key),
1003 0 /* prefix */, NULL /* seen */,
1004 0 /* is_dir */))
1005 strmap_put(o->additional_path_headers,
1006 entry->key, entry->value);
1007 }
1008 if (!strmap_get_size(o->additional_path_headers)) {
1009 strmap_clear(o->additional_path_headers, 0);
1010 FREE_AND_NULL(o->additional_path_headers);
1011 }
1012}
1013
1014static void cleanup_additional_headers(struct diff_options *o)
1015{

Callers 1

do_remerge_diffFunction · 0.85

Calls 6

strmap_init_with_optionsFunction · 0.85
match_pathspecFunction · 0.85
strmap_putFunction · 0.85
strmap_get_sizeFunction · 0.85
strmap_clearFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected