Branch Coverage

deps/libgit2/src/libgit2/refdb_fs.c
Criterion Covered Total %
branch 312 762 40.9


line true false branch
82 0 1825 if (git_str_joinpath(out, base, refname) < 0)
97 77 163 base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
100 0 240 if ((error = git_str_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
118 0 333 if (!backend->gitpath)
129 333 0 if (error <= 0) {
130 333 0 if (error == GIT_ENOTFOUND) {
146 0 0 if (!scan)
149 0 0 while (scan < eof && *scan == '#') {
0 0 while (scan < eof && *scan == '#') {
150 0 0 if (!(eol = strchr(scan, '\n')))
155 0 0 while (scan < eof) {
161 0 0 if (git_oid_fromstr(&oid, scan) < 0)
165 0 0 if (*scan++ != ' ')
167 0 0 if (!(eol = strchr(scan, '\n')))
170 0 0 if (eol[-1] == '\r')
173 0 0 if (git_sortedcache_upsert((void **)&ref, backend->refcache, scan) < 0)
181 0 0 if (*scan == '^') {
182 0 0 if (git_oid_fromstr(&oid, scan + 1) < 0)
186 0 0 if (scan < eof) {
187 0 0 if (!(eol = strchr(scan, '\n')))
195 0 0 else if (backend->peeling_mode == PEELING_FULL ||
0 0 else if (backend->peeling_mode == PEELING_FULL ||
196 0 0 (backend->peeling_mode == PEELING_STANDARD &&
221 0 787 if (git_str_len(file_content) < GIT_OID_HEXSZ)
225 0 787 if (git_oid_fromstr(oid, str) < 0)
230 787 0 if (*str == '\0' || git__isspace(*str))
787 0 if (*str == '\0' || git__isspace(*str))
242 1437 0 if ((error = loose_path(buf, base, path)) < 0 ||
166 1271 if ((error = loose_path(buf, base, path)) < 0 ||
259 0 0 if (loose_readbuffer(&ref_file, backend->gitpath, name) < 0) {
265 0 0 if (!git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF))
269 0 0 if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
272 0 0 if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
275 0 0 if (!(error = git_sortedcache_upsert(
294 0 0 if (git__suffixcmp(full_path->ptr, ".lock") == 0)
297 0 0 if (git_fs_path_isdir(full_path->ptr)) {
301 0 0 if (error == GIT_ENOTFOUND) {
325 0 0 if (git_str_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
350 0 30 GIT_ASSERT_ARG(backend);
354 0 30 if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
357 2 28 if (git_fs_path_isfile(ref_path.ptr)) {
362 0 28 if ((error = packed_reload(backend)) < 0)
365 0 28 if (git_sortedcache_lookup(backend->refcache, ref_name) != NULL) {
382 0 484 if (git_str_len(file_content) < header_len + 1) {
418 1334 103 if (out)
421 530 907 if (is_per_worktree_ref(ref_name))
426 1271 166 if ((error = loose_readbuffer(&ref_file, ref_dir, ref_name)) < 0)
428 484 787 else if (git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF) == 0) {
433 0 484 if (!(target = loose_parse_symbolic(&ref_file)))
435 484 0 else if (out != NULL)
440 787 0 if (!(error = loose_parse_oid(&oid, ref_name, &ref_file)) &&
684 103 if (!(error = loose_parse_oid(&oid, ref_name, &ref_file)) &&
464 0 0 if (git__prefixncmp(data, data_sz, traits_header) == 0) {
474 0 0 if (!eol)
477 0 0 if (git__memmem(data, eol - data, fully_peeled, strlen(fully_peeled)))
479 0 0 else if (git__memmem(data, eol - data, peeled, strlen(peeled)))
491 0 217 if (backend->packed_refs_map.data) {
509 0 166 if ((error = git_mutex_lock(&backend->prlock)) < 0)
521 166 0 if (fd < 0) {
523 166 0 if (fd == GIT_ENOTFOUND) {
530 0 0 if (p_fstat(fd, &st) < 0) {
537 0 0 if (st.st_size == 0) {
563 0 0 if (error < 0) {
586 0 0 if (!nl)
589 0 0 if (nl[1] == '^' && nl > buf)
0 0 if (nl[1] == '^' && nl > buf)
607 0 0 if (!p)
610 0 0 if (p < end && p[0] == '^')
0 0 if (p < end && p[0] == '^')
626 0 0 if (data_end < GIT_OID_HEXSZ + 3) {
633 0 0 if (end)
638 0 0 if (cmp_val == 0 && data_end != ref_len)
0 0 if (cmp_val == 0 && data_end != ref_len)
639 0 0 return (data_end > ref_len) ? 1 : -1;
651 0 166 if ((error = packed_reload(backend)) < 0)
654 0 166 if (git_sortedcache_rlock(backend->refcache) < 0)
658 166 0 if (!entry) {
662 0 0 if (!*out)
679 0 166 if ((error = packed_map_check(backend)) < 0)
682 166 0 if (!backend->sorted)
689 0 0 while (left < right && *left == '#') {
0 0 while (left < right && *left == '#') {
690 0 0 if (!(left = memchr(left, '\n', data_end - left)))
695 0 0 while (left < right) {
703 0 0 if (compare < 0) {
705 0 0 } else if (compare > 0) {
716 0 0 if (!(eol = memchr(rec, '\n', data_end - rec))) {
722 0 0 if (eol + 1 < data_end) {
725 0 0 if (*rec == '^') {
736 0 0 if (!*out) {
758 0 1323 GIT_ASSERT_ARG(backend);
760 1157 166 if (!(error = loose_lookup(out, backend, ref_name)))
765 166 0 if (error == GIT_ENOTFOUND) {
805 0 31 if (!backend->commonpath) /* do nothing if no commonpath for loose refs */
810 3 28 if (iter->glob) {
813 57 0 for (pos = iter->glob; *pos; ++pos) {
828 3 0 if (last_sep) {
834 31 0 if ((error = git_str_puts(&path, backend->commonpath)) < 0 ||
0 31 if ((error = git_str_puts(&path, backend->commonpath)) < 0 ||
840 2 29 if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
842 2 0 return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
0 2 return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
847 143 0 while (!error && !git_iterator_advance(&entry, fsit)) {
114 29 while (!error && !git_iterator_advance(&entry, fsit)) {
855 114 0 if (git__suffixcmp(ref_name, ".lock") == 0 ||
1 113 if (git__suffixcmp(ref_name, ".lock") == 0 ||
856 0 1 (iter->glob && wildmatch(iter->glob, ref_name, 0) != 0))
860 0 114 if (!ref_dup)
880 11 8 while (iter->loose_pos < iter->loose.length) {
883 11 0 if (loose_lookup(out, backend, path) == 0) {
885 0 11 if (ref)
895 0 8 while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) {
897 0 0 if (!ref) /* stop now if another thread deleted refs and we past end */
900 0 0 if (ref->flags & PACKREF_SHADOWED)
902 0 0 if (iter->glob && wildmatch(iter->glob, ref->name, 0) != 0)
0 0 if (iter->glob && wildmatch(iter->glob, ref->name, 0) != 0)
906 0 0 error = (*out != NULL) ? 0 : -1;
921 103 22 while (iter->loose_pos < iter->loose.length) {
925 103 0 if (loose_lookup(NULL, backend, path) == 0) {
927 0 103 if (ref)
938 0 22 while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) {
940 0 0 if (!ref) /* stop now if another thread deleted refs and we past end */
943 0 0 if (ref->flags & PACKREF_SHADOWED)
945 0 0 if (iter->glob && wildmatch(iter->glob, ref->name, 0) != 0)
0 0 if (iter->glob && wildmatch(iter->glob, ref->name, 0) != 0)
963 0 31 GIT_ASSERT_ARG(backend);
966 0 31 GIT_ERROR_CHECK_ALLOC(iter);
968 0 31 if ((error = git_pool_init(&iter->pool, 1)) < 0)
971 0 31 if ((error = git_vector_init(&iter->loose, 8, NULL)) < 0)
980 0 31 if ((error = iter_load_loose_paths(backend, iter)) < 0)
983 0 31 if ((error = packed_reload(backend)) < 0)
986 0 31 if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0)
995 0 31 if (error)
1003 0 0 if (old_ref == NULL || strcmp(old_ref, this_ref)) {
0 0 if (old_ref == NULL || strcmp(old_ref, this_ref)) {
1007 0 0 const char *lead = reflen < newlen ? new_ref : this_ref;
1009 0 0 if (!strncmp(new_ref, this_ref, cmplen) && lead[cmplen] == '/') {
0 0 if (!strncmp(new_ref, this_ref, cmplen) && lead[cmplen] == '/') {
1026 0 100 if ((error = packed_reload(backend)) < 0)
1029 30 70 if (!force) {
1032 0 30 if ((error = refdb_fs_backend__exists(
1037 2 28 if (exists) {
1045 0 98 if ((error = git_sortedcache_rlock(backend->refcache)) < 0)
1048 0 98 for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
1051 0 0 if (ref && !ref_is_available(old_ref, new_ref, ref->name)) {
0 0 if (ref && !ref_is_available(old_ref, new_ref, ref->name)) {
1069 0 108 GIT_ASSERT_ARG(file);
1070 0 108 GIT_ASSERT_ARG(backend);
1071 0 108 GIT_ASSERT_ARG(name);
1073 0 108 if (!git_path_is_valid(backend->repo, name, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1078 27 81 if (is_per_worktree_ref(name))
1086 0 108 if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
1089 0 108 if ((error = loose_path(&ref_path, basedir, name)) < 0)
1093 0 108 if (backend->fsync)
1098 0 108 if (error == GIT_EDIRECTORY)
1107 0 93 GIT_ASSERT_ARG(file);
1108 0 93 GIT_ASSERT_ARG(ref);
1110 73 20 if (ref->type == GIT_REFERENCE_DIRECT) {
1115 20 0 } else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
1131 0 3 GIT_ERROR_CHECK_ALLOC(lock);
1133 0 3 if ((error = loose_lock(lock, backend, refname)) < 0) {
1165 1 2 if (success == 2)
1167 2 0 else if (success)
1188 0 0 if (ref->flags & PACKREF_HAS_PEEL || ref->flags & PACKREF_CANNOT_PEEL)
0 0 if (ref->flags & PACKREF_HAS_PEEL || ref->flags & PACKREF_CANNOT_PEEL)
1194 0 0 if (git_object_lookup(&object, backend->repo, &ref->oid, GIT_OBJECT_ANY) < 0)
1202 0 0 if (git_object_type(object) == GIT_OBJECT_TAG) {
1240 0 0 if (ref->flags & PACKREF_HAS_PEEL) {
1244 0 0 if (git_filebuf_printf(file, "%s %s\n^%s\n", oid, ref->name, peel) < 0)
1247 0 0 if (git_filebuf_printf(file, "%s %s\n", oid, ref->name) < 0)
1274 0 0 for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
1278 0 0 if (!ref || !(ref->flags & PACKREF_WAS_LOOSE))
0 0 if (!ref || !(ref->flags & PACKREF_WAS_LOOSE))
1286 0 0 if (error == GIT_EEXISTS || error == GIT_ENOTFOUND)
0 0 if (error == GIT_EEXISTS || error == GIT_ENOTFOUND)
1289 0 0 if (error < 0) {
1297 0 0 if (error == GIT_ENOTFOUND)
1301 0 0 if (!git__prefixcmp(ref_content.ptr, GIT_SYMREF))
1305 0 0 if (loose_parse_oid(¤t_id, lock.path_original, &ref_content) < 0)
1309 0 0 if (!git_oid_equal(¤t_id, &ref->oid))
1337 0 0 if ((error = git_mutex_lock(&backend->prlock)) < 0) {
1346 0 0 if ((error = git_sortedcache_wlock(refcache)) < 0)
1349 0 0 if (backend->fsync)
1353 0 0 if ((error = git_filebuf_open(&pack_file, git_sortedcache_path(refcache), open_flags, GIT_PACKEDREFS_FILE_MODE)) < 0)
1359 0 0 if ((error = git_filebuf_printf(&pack_file, "%s\n", GIT_PACKEDREFS_HEADER)) < 0)
1362 0 0 for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
1365 0 0 GIT_ASSERT_WITH_CLEANUP(ref, {
1370 0 0 if ((error = packed_find_peel(backend, ref)) < 0)
1373 0 0 if ((error = packed_write_ref(ref, &pack_file)) < 0)
1379 0 0 if ((error = git_filebuf_commit(&pack_file)) < 0)
1384 0 0 if ((error = packed_remove_loose(backend)) < 0)
1405 0 8 if ((error = packed_reload(backend)) < 0)
1408 0 8 if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
1413 0 8 if (error == 0) {
1417 8 0 if (error == GIT_ENOTFOUND)
1422 0 8 if (found)
1439 93 113 if (!old_id && !old_target)
69 24 if (!old_id && !old_target)
1442 31 106 if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
1443 31 0 if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
29 2 if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
0 29 if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
1449 84 22 if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
2 82 if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
1453 22 82 if (old_target && old_ref->type != GIT_REFERENCE_SYMBOLIC) {
1 21 if (old_target && old_ref->type != GIT_REFERENCE_SYMBOLIC) {
1458 82 21 if (old_id && old_ref->type == GIT_REFERENCE_DIRECT)
82 0 if (old_id && old_ref->type == GIT_REFERENCE_DIRECT)
1461 21 82 if (old_target && old_ref->type == GIT_REFERENCE_SYMBOLIC)
21 0 if (old_target && old_ref->type == GIT_REFERENCE_SYMBOLIC)
1491 80 0 if ((error = git_repository_refdb(&refdb, backend->repo)) < 0 ||
80 0 if ((error = git_repository_refdb(&refdb, backend->repo)) < 0 ||
1494 50 30 if (!write_reflog)
1498 3 27 if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0)
1501 30 0 if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0 ||
1524 0 99 GIT_ASSERT_ARG(backend);
1526 2 97 if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
1530 0 97 if ((error = loose_lock(&file, backend, ref->name)) < 0)
1551 0 99 if ((error = cmp_old_ref(&cmp, _backend, ref->name, old_id, old_target)) < 0)
1554 0 99 if (cmp) {
1560 22 77 if (ref->type == GIT_REFERENCE_SYMBOLIC)
1566 31 68 if (error < 0 && error != GIT_ENOTFOUND)
0 31 if (error < 0 && error != GIT_ENOTFOUND)
1570 68 31 if (!error && !cmp) {
7 61 if (!error && !cmp) {
1575 90 2 if (update_reflog) {
1578 90 0 if ((error = git_repository_refdb__weakptr(&refdb, backend->repo)) < 0 ||
90 0 if ((error = git_repository_refdb__weakptr(&refdb, backend->repo)) < 0 ||
1582 80 10 if (should_write) {
1583 0 80 if ((error = reflog_append(backend, ref, NULL, NULL, who, message)) < 0)
1585 0 80 if ((error = maybe_append_head(backend, ref, who, message)) < 0)
1607 0 11 GIT_ASSERT_ARG(backend);
1608 0 11 GIT_ASSERT_ARG(ref_name);
1610 0 11 if ((error = git_str_sets(&relative_path, ref_name)) < 0)
1614 6 5 if ((commonlen = git_fs_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
4 2 if ((commonlen = git_fs_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
1615 0 4 (commonlen = git_fs_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
1620 7 0 if (prefix)
1629 7 0 if (!error)
1632 0 7 if (error < 0)
1639 0 7 if (error == GIT_ENOTFOUND)
1658 0 7 GIT_ASSERT_ARG(backend);
1659 0 7 GIT_ASSERT_ARG(ref_name);
1661 0 7 if ((error = loose_lock(&file, backend, ref_name)) < 0)
1664 0 7 if ((error = refdb_reflog_fs__delete(_backend, ref_name)) < 0) {
1677 0 8 if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
1681 0 8 if (error < 0 && errno == ENOENT)
0 0 if (error < 0 && errno == ENOENT)
1683 0 8 else if (error != 0)
1702 0 8 if (error < 0)
1705 0 8 if (cmp) {
1728 0 8 if ((error = packed_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
0 0 if ((error = packed_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
1731 8 0 if (error == 0)
1734 0 8 if ((error = loose_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
0 0 if ((error = loose_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
1737 0 8 if (error == GIT_ENOTFOUND) {
1738 0 0 error = packed_deleted ? 0 : ref_error_notfound(ref_name);
1744 8 0 if (error == 0)
1765 0 1 GIT_ASSERT_ARG(backend);
1767 1 0 if ((error = reference_path_available(
1768 0 1 backend, new_name, old_name, force)) < 0 ||
1772 0 1 if ((error = refdb_fs_backend__delete(_backend, old_name, NULL, NULL)) < 0) {
1778 0 1 if (!new) {
1783 0 1 if ((error = loose_lock(&file, backend, new->name)) < 0) {
1790 1 0 if (((error == 0) || (error == GIT_ENOTFOUND)) &&
1 0 if (((error == 0) || (error == GIT_ENOTFOUND)) &&
0 1 if (((error == 0) || (error == GIT_ENOTFOUND)) &&
1797 0 1 if (error < 0) {
1804 1 0 if ((error = loose_commit(&file, new)) < 0 || out == NULL) {
0 1 if ((error = loose_commit(&file, new)) < 0 || out == NULL) {
1818 0 0 GIT_ASSERT_ARG(backend);
1820 0 0 if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
0 0 if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
1821 0 0 (error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
1832 0 51 if (!backend)
1852 0 108 if (!in)
1858 108 0 if (repo->namespace == NULL) {
1864 0 0 if (parts == NULL)
1873 0 0 while ((start = git__strsep(&end, "/")) != NULL)
1880 0 0 if (git_futils_mkdir_relative(git_str_cstr(&path), in, 0777,
1901 0 20 GIT_ERROR_CHECK_ALLOC(log);
1904 0 20 GIT_ERROR_CHECK_ALLOC(log->ref_name);
1906 0 20 if (git_vector_init(&log->entries, 0, NULL) < 0) {
1921 0 20 if ((git_parse_ctx_init(&parser, buf, buf_size)) < 0)
1924 39 20 for (; parser.remain_len; git_parse_advance_line(&parser)) {
1930 0 39 GIT_ERROR_CHECK_ALLOC(entry);
1932 0 39 GIT_ERROR_CHECK_ALLOC(entry->committer);
1935 39 0 git_parse_advance_expected(&parser, " ", 1) < 0 ||
1940 2145 0 while (git_parse_peek(&c, &parser, 0) == 0 && c != '\t' && c != '\n')
2106 39 while (git_parse_peek(&c, &parser, 0) == 0 && c != '\t' && c != '\n')
2106 0 while (git_parse_peek(&c, &parser, 0) == 0 && c != '\t' && c != '\n')
1943 0 39 if (git_signature__parse(entry->committer, &sig, parser.line, NULL, 0) < 0)
1946 39 0 if (c == '\t') {
1951 39 0 if (parser.line[len - 1] == '\n')
1955 0 39 GIT_ERROR_CHECK_ALLOC(entry->msg);
1958 0 39 if ((git_vector_insert(&log->entries, entry)) < 0) {
1976 0 7 if ((error = git_futils_mkpath2file(filepath, GIT_REFLOG_DIR_MODE)) < 0)
1979 0 7 if ((fd = p_open(filepath,
1994 6 0 GIT_ASSERT_ARG(_backend && name);
0 6 GIT_ASSERT_ARG(_backend && name);
1999 0 6 if ((error = reflog_path(&path, repo, name)) < 0)
2013 0 88 if (reflog_path(&path, repo, name) < 0)
2027 0 88 GIT_ASSERT_ARG(_backend);
2028 0 88 GIT_ASSERT_ARG(name);
2044 0 20 GIT_ASSERT_ARG(out);
2045 0 20 GIT_ASSERT_ARG(_backend);
2046 0 20 GIT_ASSERT_ARG(name);
2051 0 20 if (reflog_alloc(&log, name) < 0)
2054 0 20 if (reflog_path(&log_path, repo, name) < 0)
2058 1 19 if (error < 0 && error != GIT_ENOTFOUND)
0 1 if (error < 0 && error != GIT_ENOTFOUND)
2061 1 19 if ((error == GIT_ENOTFOUND) &&
0 1 if ((error == GIT_ENOTFOUND) &&
2065 0 20 if ((error = reflog_parse(log,
2106 114 7 if (msg) {
2112 19145 114 for (i = 0; i < buf->size - 2; i++)
2113 0 19145 if (buf->ptr[i] == '\n')
2131 0 7 if (!git_path_is_valid(backend->repo, refname, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
2136 0 7 if (reflog_path(&log_path, repo, refname) < 0)
2139 0 7 if (!git_fs_path_isfile(git_str_cstr(&log_path))) {
2163 0 7 GIT_ASSERT_ARG(_backend);
2164 0 7 GIT_ASSERT_ARG(reflog);
2168 0 7 if ((error = lock_reflog(&fbuf, backend, reflog->ref_name)) < 0)
2171 10 7 git_vector_foreach(&reflog->entries, i, entry) {
2172 0 10 if (serialize_reflog_entry(&log, &(entry->oid_old), &(entry->oid_cur), entry->committer, entry->msg) < 0)
2175 0 10 if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0)
2202 48 63 if (is_symbolic &&
0 48 if (is_symbolic &&
2203 0 0 strcmp(ref->name, GIT_HEAD_FILE) &&
2204 0 0 !(old && new))
2209 31 80 if (old) {
2213 23 57 if (error < 0 && error != GIT_ENOTFOUND)
0 23 if (error < 0 && error != GIT_ENOTFOUND)
2217 30 81 if (new) {
2220 63 18 if (!is_symbolic) {
2224 0 18 if (error < 0 && error != GIT_ENOTFOUND)
0 0 if (error < 0 && error != GIT_ENOTFOUND)
2227 0 18 if (error == GIT_ENOTFOUND)
2234 0 111 if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
2237 0 111 if ((error = reflog_path(&path, repo, ref->name)) < 0)
2240 0 111 if (((error = git_futils_mkpath2file(git_str_cstr(&path), 0777)) < 0) &&
0 0 if (((error = git_futils_mkpath2file(git_str_cstr(&path), 0777)) < 0) &&
2248 0 111 if (git_fs_path_isdir(git_str_cstr(&path))) {
2249 0 0 if ((error = git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
2250 0 0 if (error == GIT_ENOTFOUND)
2252 0 0 } else if (git_fs_path_isdir(git_str_cstr(&path))) {
2258 0 0 if (error != 0)
2264 0 111 if (backend->fsync)
2286 0 1 GIT_ASSERT_ARG(_backend);
2287 0 1 GIT_ASSERT_ARG(old_name);
2288 0 1 GIT_ASSERT_ARG(new_name);
2293 0 1 if ((error = git_reference__normalize_name(
2297 0 1 if (git_str_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
2300 0 1 if ((error = loose_path(&old_path, git_str_cstr(&temp_path), old_name)) < 0)
2303 0 1 if ((error = loose_path(&new_path, git_str_cstr(&temp_path), git_str_cstr(&normalized))) < 0)
2306 1 0 if (!git_fs_path_exists(git_str_cstr(&old_path))) {
2318 0 0 if ((error = loose_path(&temp_path, git_str_cstr(&temp_path), "temp_reflog")) < 0)
2321 0 0 if ((fd = git_futils_mktmp(&temp_path, git_str_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
2328 0 0 if (p_rename(git_str_cstr(&old_path), git_str_cstr(&temp_path)) < 0) {
2340 0 0 if (git_futils_mkpath2file(git_str_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
2345 0 0 if (p_rename(git_str_cstr(&temp_path), git_str_cstr(&new_path)) < 0) {
2365 0 8 GIT_ASSERT_ARG(_backend);
2366 0 8 GIT_ASSERT_ARG(name);
2368 0 8 if ((error = reflog_path(&path, backend->repo, name)) < 0)
2371 5 3 if (!git_fs_path_exists(path.ptr))
2374 0 3 if ((error = p_unlink(path.ptr)) < 0)
2394 0 54 GIT_ERROR_CHECK_ALLOC(backend);
2395 0 54 if (git_mutex_init(&backend->prlock) < 0) {
2401 0 54 if (git_refdb_init_backend(&backend->parent, GIT_REFDB_BACKEND_VERSION) < 0)
2406 54 0 if (repository->gitdir) {
2409 0 54 if (backend->gitpath == NULL)
2413 54 0 if (repository->commondir) {
2416 0 54 if (backend->commonpath == NULL)
2428 54 0 if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
0 54 if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
2432 54 0 if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
0 54 if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
2436 54 0 if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
54 0 if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
0 54 if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||