Branch Coverage

deps/libgit2/src/attr.c
Criterion Covered Total %
branch 87 208 41.8


line true false branch
24 269 2268 if (attr == NULL || attr == git_attr__unset)
0 269 if (attr == NULL || attr == git_attr__unset)
27 269 0 if (attr == git_attr__true)
30 0 0 if (attr == git_attr__false)
61 4 0 assert(value && repo && name);
4 0 assert(value && repo && name);
0 4 assert(value && repo && name);
65 0 4 if (git_repository_is_bare(repo))
68 0 4 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
71 0 4 if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0)
78 8 4 git_vector_foreach(&files, i, file) {
80 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 8 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
83 0 0 if (!git_vector_bsearch(&pos, &rule->assigns, &attr)) {
123 0 645 if (!num_attr)
126 645 0 assert(values && repo && names);
645 0 assert(values && repo && names);
0 645 assert(values && repo && names);
128 0 645 if (git_repository_is_bare(repo))
131 0 645 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
134 0 645 if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0)
138 0 645 GIT_ERROR_CHECK_ALLOC(info);
140 1414 645 git_vector_foreach(&files, i, file) {
142 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 1414 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
144 0 0 for (k = 0; k < num_attr; k++) {
147 0 0 if (info[k].found != NULL) /* already found assignment */
150 0 0 if (!info[k].name.name) {
155 0 0 if (!git_vector_bsearch(&pos, &rule->assigns, &info[k].name)) {
160 0 0 if (++num_found == num_attr)
167 1183 645 for (k = 0; k < num_attr; k++) {
168 1183 0 if (!info[k].found)
209 0 0 assert(repo && callback);
0 0 assert(repo && callback);
211 0 0 if (git_repository_is_bare(repo))
214 0 0 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
217 0 0 if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 ||
0 0 if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 ||
221 0 0 git_vector_foreach(&files, i, file) {
223 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
225 0 0 git_vector_foreach(&rule->assigns, k, assign) {
227 0 0 if (git_strmap_exists(seen, assign->name))
230 0 0 if ((error = git_strmap_set(seen, assign->name, assign)) < 0)
234 0 0 if (error) {
261 535 1605 if (!file)
263 1605 0 if (!(error = git_attr_cache__get(&preload, repo, attr_session, source, base, file,
276 962 222 if (!attr_session) {
279 962 0 if (error == GIT_ENOTFOUND)
285 54 168 if (!attr_session->init_sysdir) {
288 54 0 if (error == GIT_ENOTFOUND)
290 0 0 else if (error)
296 222 0 if (attr_session->sysdir.size == 0)
318 168 481 if (attr_session && attr_session->init_setup)
114 54 if (attr_session && attr_session->init_setup)
321 0 535 if ((error = git_attr_cache__init(repo)) < 0)
329 0 535 if ((error = system_attr_file(&path, attr_session)) < 0 ||
0 0 if ((error = system_attr_file(&path, attr_session)) < 0 ||
332 0 535 if (error != GIT_ENOTFOUND)
336 0 535 if ((error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE,
341 535 0 if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
0 535 if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
344 0 0 if (error != GIT_ENOTFOUND)
348 535 0 if ((workdir = git_repository_workdir(repo)) != NULL &&
0 535 if ((workdir = git_repository_workdir(repo)) != NULL &&
353 535 0 if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
535 0 if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
358 0 535 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
0 0 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
363 54 481 if (attr_session)
381 0 16 if ((error = git_attr_cache__init(repo)) < 0)
385 0 16 GIT_ERROR_CHECK_ALLOC(macro);
390 0 16 GIT_ERROR_CHECK_ALLOC(macro->match.pattern);
397 16 0 if (!error)
400 0 16 if (error < 0)
422 773 0 if (has_wd)
424 773 0 if (has_index)
428 0 0 if (has_index)
430 0 0 if (has_wd)
434 0 0 if (has_index)
439 0 773 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
460 0 2195 if (error < 0)
463 1422 773 if (file != NULL) {
464 0 1422 if ((error = git_vector_insert(list, file)) < 0)
480 773 0 allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
649 124 allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
482 2319 0 for (i = 0; !error && i < n_src; ++i)
1546 773 for (i = 0; !error && i < n_src; ++i)
494 1422 649 git_vector_foreach(files, i, file) {
513 0 649 if ((error = attr_setup(repo, attr_session, flags)) < 0)
517 649 0 if (workdir != NULL)
521 0 649 if (error < 0)
531 649 0 if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
0 649 if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
534 0 0 if (error != GIT_ENOTFOUND)
542 0 649 if (git_repository_index__weakptr(&info.index, repo) < 0)
546 0 649 if (!strcmp(dir.ptr, "."))
551 0 649 if (error < 0)
554 0 649 if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) {
557 0 0 if (error < 0)
561 649 0 if ((flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
564 0 649 if (!error)
567 649 0 else if (error == GIT_ENOTFOUND)
572 0 649 if (error < 0)