Branch Coverage

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


line true false branch
24 228 1940 if (attr == NULL || attr == git_attr__unset)
0 228 if (attr == NULL || attr == git_attr__unset)
27 228 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 561 if (!num_attr)
126 561 0 assert(values && repo && names);
561 0 assert(values && repo && names);
0 561 assert(values && repo && names);
128 0 561 if (git_repository_is_bare(repo))
131 0 561 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
134 0 561 if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0)
138 0 561 GIT_ERROR_CHECK_ALLOC(info);
140 1238 561 git_vector_foreach(&files, i, file) {
142 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 1238 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 1017 561 for (k = 0; k < num_attr; k++) {
168 1017 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 451 1353 if (!file)
263 1353 0 if (!(error = git_attr_cache__get(&preload, repo, attr_session, source, base, file,
276 794 222 if (!attr_session) {
279 794 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 397 if (attr_session && attr_session->init_setup)
114 54 if (attr_session && attr_session->init_setup)
321 0 451 if ((error = git_attr_cache__init(repo)) < 0)
329 0 451 if ((error = system_attr_file(&path, attr_session)) < 0 ||
0 0 if ((error = system_attr_file(&path, attr_session)) < 0 ||
332 0 451 if (error != GIT_ENOTFOUND)
336 0 451 if ((error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE,
341 451 0 if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
0 451 if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
344 0 0 if (error != GIT_ENOTFOUND)
348 451 0 if ((workdir = git_repository_workdir(repo)) != NULL &&
0 451 if ((workdir = git_repository_workdir(repo)) != NULL &&
353 451 0 if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
451 0 if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
358 0 451 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
0 0 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
363 54 397 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 681 0 if (has_wd)
424 681 0 if (has_index)
428 0 0 if (has_index)
430 0 0 if (has_wd)
434 0 0 if (has_index)
439 0 681 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
460 0 1927 if (error < 0)
463 1246 681 if (file != NULL) {
464 0 1246 if ((error = git_vector_insert(list, file)) < 0)
480 681 0 allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
565 116 allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
482 2043 0 for (i = 0; !error && i < n_src; ++i)
1362 681 for (i = 0; !error && i < n_src; ++i)
494 1246 565 git_vector_foreach(files, i, file) {
513 0 565 if ((error = attr_setup(repo, attr_session, flags)) < 0)
517 565 0 if (workdir != NULL)
521 0 565 if (error < 0)
531 565 0 if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
0 565 if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
534 0 0 if (error != GIT_ENOTFOUND)
542 0 565 if (git_repository_index__weakptr(&info.index, repo) < 0)
546 0 565 if (!strcmp(dir.ptr, "."))
551 0 565 if (error < 0)
554 0 565 if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) {
557 0 0 if (error < 0)
561 565 0 if ((flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
564 0 565 if (!error)
567 565 0 else if (error == GIT_ENOTFOUND)
572 0 565 if (error < 0)