Branch Coverage

deps/libgit2/src/libgit2/attr.c
Criterion Covered Total %
branch 106 248 42.7


line true false branch
24 260 2196 if (attr == NULL || attr == git_attr__unset)
0 260 if (attr == NULL || attr == git_attr__unset)
27 260 0 if (attr == git_attr__true)
30 0 0 if (attr == git_attr__false)
61 0 4 GIT_ASSERT_ARG(value);
62 0 4 GIT_ASSERT_ARG(repo);
63 0 4 GIT_ASSERT_ARG(name);
64 0 4 GIT_ERROR_CHECK_VERSION(opts, GIT_ATTR_OPTIONS_VERSION, "git_attr_options");
68 0 4 if (git_repository_is_bare(repo))
71 0 4 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
74 0 4 if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0)
81 8 4 git_vector_foreach(&files, i, file) {
83 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 8 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
86 0 0 if (!git_vector_bsearch(&pos, &rule->assigns, &attr)) {
140 0 627 if (!num_attr)
143 0 627 GIT_ASSERT_ARG(values);
144 0 627 GIT_ASSERT_ARG(repo);
145 0 627 GIT_ASSERT_ARG(pathname);
146 0 627 GIT_ASSERT_ARG(names);
147 0 627 GIT_ERROR_CHECK_VERSION(opts, GIT_ATTR_OPTIONS_VERSION, "git_attr_options");
149 0 627 if (git_repository_is_bare(repo))
152 0 627 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
155 0 627 if ((error = collect_attr_files(repo, attr_session, opts, pathname, &files)) < 0)
159 0 627 GIT_ERROR_CHECK_ALLOC(info);
161 1378 627 git_vector_foreach(&files, i, file) {
163 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 1378 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
165 0 0 for (k = 0; k < num_attr; k++) {
168 0 0 if (info[k].found != NULL) /* already found assignment */
171 0 0 if (!info[k].name.name) {
176 0 0 if (!git_vector_bsearch(&pos, &rule->assigns, &info[k].name)) {
181 0 0 if (++num_found == num_attr)
188 1147 627 for (k = 0; k < num_attr; k++) {
189 1147 0 if (!info[k].found)
260 0 0 GIT_ASSERT_ARG(repo);
261 0 0 GIT_ASSERT_ARG(callback);
262 0 0 GIT_ERROR_CHECK_VERSION(opts, GIT_ATTR_OPTIONS_VERSION, "git_attr_options");
264 0 0 if (git_repository_is_bare(repo))
267 0 0 if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
270 0 0 if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0 ||
0 0 if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0 ||
274 0 0 git_vector_foreach(&files, i, file) {
276 0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
0 0 git_attr_file__foreach_matching_rule(file, &path, j, rule) {
278 0 0 git_vector_foreach(&rule->assigns, k, assign) {
280 0 0 if (git_strmap_exists(seen, assign->name))
283 0 0 if ((error = git_strmap_set(seen, assign->name, assign)) < 0)
287 0 0 if (error) {
311 0 1551 if (!source)
317 1551 0 if (!error)
331 517 1034 if (!filename)
346 926 222 if (!attr_session) {
349 926 0 if (error == GIT_ENOTFOUND)
355 54 168 if (!attr_session->init_sysdir) {
358 54 0 if (error == GIT_ENOTFOUND)
360 0 0 else if (error)
366 222 0 if (attr_session->sysdir.size == 0)
391 168 463 if (attr_session && attr_session->init_setup)
114 54 if (attr_session && attr_session->init_setup)
394 0 517 if ((error = git_attr_cache__init(repo)) < 0)
402 0 517 if ((error = system_attr_file(&system, attr_session)) < 0 ||
0 0 if ((error = system_attr_file(&system, attr_session)) < 0 ||
404 0 517 if (error != GIT_ENOTFOUND)
410 0 517 if ((error = preload_attr_file(repo, attr_session, NULL,
414 517 0 if ((error = git_repository__item_path(&info, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
0 517 if ((error = git_repository__item_path(&info, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
416 0 0 if (error != GIT_ENOTFOUND)
422 517 0 if ((workdir = git_repository_workdir(repo)) != NULL &&
0 517 if ((workdir = git_repository_workdir(repo)) != NULL &&
426 517 0 if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
517 0 if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
430 493 24 if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0) &&
0 493 if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0) &&
0 0 if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0) &&
434 493 24 if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)) {
0 493 if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)) {
436 0 0 if (opts->commit_id)
442 0 0 if ((error = preload_attr_source(repo, attr_session, &commit_source)) < 0)
446 54 463 if (attr_session)
465 0 16 GIT_ASSERT_ARG(repo);
466 0 16 GIT_ASSERT_ARG(name);
468 0 16 if ((error = git_attr_cache__init(repo)) < 0)
472 0 16 GIT_ERROR_CHECK_ALLOC(macro);
477 0 16 GIT_ERROR_CHECK_ALLOC(macro->match.pattern);
484 16 0 if (!error)
487 0 16 if (error < 0)
512 755 0 if (has_wd)
514 755 0 if (has_index)
518 0 0 if (has_index)
520 0 0 if (has_wd)
524 0 0 if (has_index)
529 0 755 if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
532 0 755 if ((flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)
553 0 2141 if (error < 0)
556 1386 755 if (file != NULL) {
557 0 1386 if ((error = git_vector_insert(list, file)) < 0)
582 621 134 n_src = attr_decide_sources(info->opts ? info->opts->flags : 0,
587 755 0 allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
631 124 allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
589 2265 0 for (i = 0; !error && i < n_src; ++i) {
1510 755 for (i = 0; !error && i < n_src; ++i) {
592 0 1510 if (src[i] == GIT_ATTR_FILE_SOURCE_COMMIT && info->opts) {
0 0 if (src[i] == GIT_ATTR_FILE_SOURCE_COMMIT && info->opts) {
594 0 0 if (info->opts->commit_id)
613 1386 631 git_vector_foreach(files, i, file) {
632 0 631 GIT_ASSERT(!git_fs_path_is_absolute(path));
634 0 631 if ((error = attr_setup(repo, attr_session, opts)) < 0)
638 631 0 if (workdir != NULL) {
639 631 0 if (!(error = git_repository_workdir_path(&dir, repo, path)))
646 0 631 if (error < 0)
656 631 0 if ((error = git_repository__item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
0 631 if ((error = git_repository__item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
658 0 0 if (error != GIT_ENOTFOUND)
666 0 631 if (git_repository_index__weakptr(&info.index, repo) < 0)
670 0 631 if (!strcmp(dir.ptr, "."))
675 0 631 if (error < 0)
678 0 631 if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) {
680 0 0 if (error < 0)
684 531 100 if (!opts || (opts->flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
531 0 if (!opts || (opts->flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
687 0 631 if (!error)
689 631 0 else if (error == GIT_ENOTFOUND)
694 0 631 if (error < 0)