line |
true |
false |
branch |
35
|
187 |
0 |
while (tries--) { |
42
|
0 |
187 |
if (git_str_oom(path_out)) |
46
|
187 |
0 |
if ((fd = p_open(path_out->ptr, open_flags, mode)) >= 0) |
60
|
0 |
0 |
if (git_futils_mkpath2file(path, dirmode) < 0) |
64
|
0 |
0 |
if (fd < 0) { |
77
|
0 |
317 |
if (fd < 0) { |
95
|
0 |
144 |
if (git_futils_mkpath2file(path, dirmode) < 0) |
104
|
392 |
2940 |
if (fd < 0) |
112
|
0 |
0 |
if (fd < 0) |
123
|
0 |
4 |
if (p_fstat(fd, &sb)) { |
128
|
0 |
4 |
if (sb.st_size < 0) { |
139
|
671 |
206 |
if (S_ISREG(raw_mode)) |
140
|
0 |
671 |
return S_IFREG | GIT_PERMS_CANONICAL(raw_mode); |
141
|
0 |
206 |
else if (S_ISLNK(raw_mode)) |
143
|
0 |
206 |
else if (S_ISGITLINK(raw_mode)) |
145
|
206 |
0 |
else if (S_ISDIR(raw_mode)) |
158
|
0 |
2371 |
if (!git__is_ssizet(len)) { |
163
|
0 |
2371 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, len, 1); |
|
0 |
2371 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, len, 1); |
164
|
0 |
2371 |
if (git_str_grow(buf, alloc_len) < 0) |
170
|
0 |
2371 |
if (read_size < 0) { |
176
|
0 |
2371 |
if ((size_t)read_size != len) { |
197
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, blocksize); |
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, blocksize); |
199
|
0 |
0 |
if (git_str_grow(buf, alloc_len) < 0) |
205
|
0 |
0 |
if (read_size < 0) { |
213
|
0 |
0 |
if ((size_t)read_size < blocksize) { |
236
|
0 |
2545 |
GIT_ASSERT_ARG(out); |
237
|
2545 |
0 |
GIT_ASSERT_ARG(path && *path); |
|
0 |
2545 |
GIT_ASSERT_ARG(path && *path); |
239
|
0 |
2545 |
if (updated != NULL) |
242
|
228 |
2317 |
if (p_stat(path, &st) < 0) |
246
|
0 |
2317 |
if (S_ISDIR(st.st_mode)) { |
251
|
0 |
2317 |
if (!git__is_sizet(st.st_size+1)) { |
256
|
0 |
2317 |
if ((fd = git_futils_open_ro(path)) < 0) |
259
|
0 |
2317 |
if (git_futils_readbuffer_fd(&buf, fd, (size_t)st.st_size) < 0) { |
266
|
0 |
2317 |
if (checksum) { |
267
|
0 |
0 |
if ((error = git_hash_buf(checksum_new, buf.ptr, buf.size, GIT_HASH_ALGORITHM_SHA1)) < 0) { |
275
|
0 |
0 |
if (!memcmp(checksum, checksum_new, GIT_HASH_SHA1_SIZE)) { |
277
|
0 |
0 |
if (updated) |
289
|
0 |
2317 |
if (updated != NULL) |
308
|
21 |
122 |
if (!flags) |
311
|
0 |
143 |
if ((flags & O_FSYNC) != 0) |
316
|
0 |
143 |
if (!mode) |
319
|
0 |
143 |
if ((fd = p_open(path, flags, mode)) < 0) { |
324
|
0 |
143 |
if ((error = p_write(fd, git_str_cstr(buf), git_str_len(buf))) < 0) { |
330
|
0 |
143 |
if (do_fsync && (error = p_fsync(fd)) < 0) { |
|
0 |
0 |
if (do_fsync && (error = p_fsync(fd)) < 0) { |
336
|
0 |
143 |
if ((error = p_close(fd)) < 0) { |
341
|
0 |
143 |
if (do_fsync && (flags & O_CREAT)) |
|
0 |
0 |
if (do_fsync && (flags & O_CREAT)) |
349
|
0 |
0 |
if (git_futils_mkpath2file(to, dirmode) < 0) |
352
|
0 |
0 |
if (p_rename(from, to) < 0) { |
371
|
0 |
0 |
if (fd < 0) |
374
|
0 |
0 |
if ((result = git_futils_filesize(&len, fd)) < 0) |
377
|
0 |
0 |
if (!git__is_sizet(len)) { |
402
|
0 |
304 |
if ((flags & GIT_MKDIR_EXCL) != 0) { |
408
|
0 |
304 |
if ((S_ISREG(st->st_mode) && (flags & GIT_MKDIR_REMOVE_FILES)) || |
|
0 |
0 |
if ((S_ISREG(st->st_mode) && (flags & GIT_MKDIR_REMOVE_FILES)) || |
|
0 |
304 |
if ((S_ISREG(st->st_mode) && (flags & GIT_MKDIR_REMOVE_FILES)) || |
409
|
0 |
0 |
(S_ISLNK(st->st_mode) && (flags & GIT_MKDIR_REMOVE_SYMLINKS))) { |
410
|
0 |
0 |
if (p_unlink(path) < 0) { |
411
|
0 |
0 |
git_error_set(GIT_ERROR_OS, "failed to remove %s '%s'", |
418
|
0 |
0 |
if (p_mkdir(path, mode) < 0) { |
424
|
0 |
304 |
else if (S_ISLNK(st->st_mode)) { |
428
|
0 |
0 |
if (p_stat(path, st) < 0) { |
434
|
0 |
304 |
else if (!S_ISDIR(st->st_mode)) { |
451
|
469 |
26 |
if (((terminal_path && (flags & GIT_MKDIR_CHMOD) != 0) || |
|
469 |
0 |
if (((terminal_path && (flags & GIT_MKDIR_CHMOD) != 0) || |
|
0 |
495 |
if (((terminal_path && (flags & GIT_MKDIR_CHMOD) != 0) || |
452
|
0 |
0 |
(flags & GIT_MKDIR_CHMOD_PATH) != 0) && st->st_mode != mode) { |
456
|
0 |
0 |
if (p_chmod(path, mode) < 0) { |
471
|
0 |
517 |
if (path->size == 0) { |
477
|
0 |
517 |
if ((root_len = git_fs_path_root(path->ptr)) < 0) |
482
|
562 |
0 |
while (path->size > (size_t)root_len && path->ptr[path->size - 1] == '/') |
|
45 |
517 |
while (path->size > (size_t)root_len && path->ptr[path->size - 1] == '/') |
486
|
0 |
517 |
if ((flags & GIT_MKDIR_SKIP_LAST2) != 0) { |
490
|
460 |
57 |
if ((flags & GIT_MKDIR_SKIP_LAST) != 0) { |
497
|
0 |
517 |
if (path->size <= (size_t)root_len) |
515
|
282 |
0 |
if ((error = git_str_puts(&make_path, path)) < 0 || |
|
282 |
0 |
if ((error = git_str_puts(&make_path, path)) < 0 || |
516
|
282 |
0 |
(error = mkdir_canonicalize(&make_path, flags)) < 0 || |
517
|
282 |
0 |
(error = git_str_puts(&parent_path, make_path.ptr)) < 0 || |
526
|
293 |
0 |
for (relative = make_path.ptr; parent_path.size; ) { |
529
|
273 |
20 |
if (error == 0) { |
531
|
0 |
20 |
} else if (errno != ENOENT) { |
540
|
0 |
20 |
if ((len = git_fs_path_dirname_r(&parent_path, parent_path.ptr)) < 0) { |
545
|
0 |
20 |
GIT_ASSERT(len); |
553
|
0 |
20 |
if ((len == 1 && parent_path.ptr[0] == '.') || |
|
0 |
0 |
if ((len == 1 && parent_path.ptr[0] == '.') || |
|
0 |
20 |
if ((len == 1 && parent_path.ptr[0] == '.') || |
554
|
0 |
0 |
(len == 1 && parent_path.ptr[0] == '/') || |
|
0 |
20 |
(len == 1 && parent_path.ptr[0] == '/') || |
563
|
9 |
11 |
if ((flags & GIT_MKDIR_PATH) == 0) |
570
|
268 |
14 |
if (depth == 0) { |
573
|
268 |
0 |
if (!error) |
585
|
14 |
0 |
error = git_futils_mkdir_relative(relative, |
613
|
187 |
48 |
if (!opts) |
617
|
0 |
235 |
if (git_fs_path_join_unrooted(&make_path, relative_path, base, &root) < 0) |
620
|
235 |
0 |
if ((error = mkdir_canonicalize(&make_path, flags)) < 0 || |
|
235 |
0 |
if ((error = mkdir_canonicalize(&make_path, flags)) < 0 || |
625
|
9 |
226 |
if ((flags & GIT_MKDIR_PATH) == 0) |
630
|
0 |
235 |
if (root < min_root_len) |
632
|
249 |
0 |
while (root >= 0 && make_path.ptr[root] == '/') |
|
14 |
235 |
while (root >= 0 && make_path.ptr[root] == '/') |
636
|
0 |
235 |
if (root > (ssize_t)make_path.size) |
638
|
0 |
235 |
if (root < 0) |
642
|
227 |
235 |
for (tail = &make_path.ptr[root]; *tail; *tail = lastch) { |
646
|
26 |
227 |
while (*tail == '/') |
648
|
729 |
201 |
while (*tail && *tail != '/') |
|
703 |
26 |
while (*tail && *tail != '/') |
656
|
0 |
227 |
if (opts->dir_map && git_strmap_exists(opts->dir_map, make_path.ptr)) |
|
0 |
0 |
if (opts->dir_map && git_strmap_exists(opts->dir_map, make_path.ptr)) |
663
|
191 |
36 |
if (p_lstat(make_path.ptr, &st) < 0) { |
664
|
191 |
0 |
if (mkdir_attempted || errno != ENOENT) { |
|
0 |
191 |
if (mkdir_attempted || errno != ENOENT) { |
673
|
0 |
191 |
if (p_mkdir(make_path.ptr, mode) < 0) { |
674
|
0 |
0 |
if (errno == EEXIST) |
681
|
0 |
36 |
if ((error = mkdir_validate_dir( |
687
|
0 |
227 |
if ((error = mkdir_validate_mode( |
691
|
0 |
227 |
if (opts->dir_map && opts->pool) { |
|
0 |
0 |
if (opts->dir_map && opts->pool) { |
695
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_size, make_path.size, 1); |
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_size, make_path.size, 1); |
697
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(cache_path); |
701
|
0 |
0 |
if ((error = git_strmap_set(opts->dir_map, cache_path, cache_path)) < 0) |
709
|
200 |
35 |
if ((flags & GIT_MKDIR_VERIFY_DIR) != 0 && |
|
34 |
166 |
if ((flags & GIT_MKDIR_VERIFY_DIR) != 0 && |
713
|
34 |
0 |
if (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode)) { |
|
0 |
34 |
if (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode)) { |
736
|
0 |
0 |
if (filemsg) |
750
|
0 |
0 |
while (error == GIT_ENOTFOUND) { |
753
|
0 |
0 |
if (!path->size || git__prefixcmp(path->ptr, ceiling) != 0) |
|
0 |
0 |
if (!path->size || git__prefixcmp(path->ptr, ceiling) != 0) |
755
|
0 |
0 |
else if (p_lstat_posixly(path->ptr, &st) == 0) { |
756
|
0 |
0 |
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) |
|
0 |
0 |
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) |
758
|
0 |
0 |
else if (!S_ISDIR(st.st_mode)) |
760
|
0 |
0 |
} else if (errno != ENOTDIR) |
764
|
0 |
0 |
if (error) |
776
|
0 |
182 |
if (data->depth > FUTILS_MAX_DEPTH) |
780
|
39 |
143 |
else if ((error = p_lstat_posixly(path->ptr, &st)) < 0) { |
781
|
39 |
0 |
if (errno == ENOENT) |
783
|
0 |
0 |
else if (errno == ENOTDIR) { |
785
|
0 |
0 |
if ((data->flags & GIT_RMDIR_REMOVE_BLOCKERS) != 0) |
795
|
12 |
131 |
else if (S_ISDIR(st.st_mode)) { |
802
|
0 |
12 |
if (error < 0) |
805
|
12 |
0 |
if (data->depth == 0 && (data->flags & GIT_RMDIR_SKIP_ROOT) != 0) |
|
0 |
12 |
if (data->depth == 0 && (data->flags & GIT_RMDIR_SKIP_ROOT) != 0) |
808
|
0 |
12 |
if ((error = p_rmdir(path->ptr)) < 0) { |
810
|
0 |
0 |
(errno == ENOTEMPTY || errno == EEXIST || errno == EBUSY)) |
|
0 |
0 |
(errno == ENOTEMPTY || errno == EEXIST || errno == EBUSY)) |
817
|
55 |
76 |
else if ((data->flags & GIT_RMDIR_REMOVE_FILES) != 0) { |
818
|
0 |
55 |
if (p_unlink(path->ptr) < 0) |
822
|
0 |
76 |
else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0) |
833
|
26 |
30 |
if (strlen(path) <= data->baselen) |
836
|
26 |
4 |
else if (p_rmdir(path) < 0) { |
839
|
0 |
26 |
if (en == ENOENT || en == ENOTDIR) { |
|
0 |
0 |
if (en == ENOENT || en == ENOTDIR) { |
841
|
0 |
0 |
} else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0 && |
|
0 |
0 |
} else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0 && |
844
|
0 |
0 |
} else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) { |
|
0 |
0 |
} else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) { |
|
0 |
0 |
} else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) { |
862
|
0 |
145 |
if (git_fs_path_join_unrooted(&fullpath, path, base, NULL) < 0) |
866
|
134 |
11 |
data.base = base ? base : ""; |
867
|
134 |
11 |
data.baselen = base ? strlen(base) : 0; |
873
|
145 |
0 |
if (!error && (flags & GIT_RMDIR_EMPTY_PARENTS) != 0) |
|
26 |
119 |
if (!error && (flags & GIT_RMDIR_EMPTY_PARENTS) != 0) |
877
|
26 |
119 |
if (error == GIT_ITEROVER) { |
891
|
0 |
0 |
if (fd >= 0) { |
904
|
0 |
0 |
while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0) |
|
0 |
0 |
while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0) |
910
|
0 |
0 |
if (len < 0) { |
915
|
0 |
0 |
if (error < 0) |
918
|
0 |
0 |
if (close_fd_when_done) { |
930
|
0 |
0 |
if ((ifd = git_futils_open_ro(from)) < 0) |
933
|
0 |
0 |
if ((ofd = p_open(to, O_WRONLY | O_CREAT | O_EXCL, filemode)) < 0) { |
946
|
0 |
289 |
times[0].tv_sec = times[1].tv_sec = when ? *when : time(NULL); |
951
|
163 |
126 |
return (ret < 0) ? git_fs_path_set_error(errno, path, "touch") : 0; |
961
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_size, link_size, 1); |
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_size, link_size, 1); |
963
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(link_data); |
966
|
0 |
0 |
if (read_len != (ssize_t)link_size) { |
973
|
0 |
0 |
if (p_symlink(link_data, to) < 0) { |
1000
|
0 |
0 |
if ((info->flags & GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT) == 0) { |
1001
|
0 |
0 |
error = git_futils_mkdir( |
1009
|
0 |
0 |
if (!error) |
1028
|
0 |
0 |
if ((error = git_str_joinpath( |
1032
|
0 |
0 |
if (!(error = git_fs_path_lstat(info->to.ptr, &to_st))) |
1034
|
0 |
0 |
else if (error != GIT_ENOTFOUND) |
1041
|
0 |
0 |
if ((error = git_fs_path_lstat(from->ptr, &from_st)) < 0) |
1044
|
0 |
0 |
if (S_ISDIR(from_st.st_mode)) { |
1048
|
0 |
0 |
if ((info->flags & GIT_CPDIR_CHMOD_DIRS) == 0) |
1052
|
0 |
0 |
if (!exists && (info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) != 0) |
|
0 |
0 |
if (!exists && (info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) != 0) |
1056
|
0 |
0 |
if (!error && (!exists || S_ISDIR(to_st.st_mode))) |
|
0 |
0 |
if (!error && (!exists || S_ISDIR(to_st.st_mode))) |
|
0 |
0 |
if (!error && (!exists || S_ISDIR(to_st.st_mode))) |
1059
|
0 |
0 |
if (oldmode != 0) |
1065
|
0 |
0 |
if (exists) { |
1066
|
0 |
0 |
if ((info->flags & GIT_CPDIR_OVERWRITE) == 0) |
1069
|
0 |
0 |
if (p_unlink(info->to.ptr) < 0) { |
1077
|
0 |
0 |
if (!S_ISREG(from_st.st_mode) && |
|
0 |
0 |
if (!S_ISREG(from_st.st_mode) && |
1078
|
0 |
0 |
(!S_ISLNK(from_st.st_mode) || |
1083
|
0 |
0 |
if ((info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0 && |
|
0 |
0 |
if ((info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0 && |
1088
|
0 |
0 |
if (info->flags & GIT_CPDIR_LINK_FILES) { |
1089
|
0 |
0 |
if ((error = p_link(from->ptr, info->to.ptr)) < 0) |
1091
|
0 |
0 |
} else if (S_ISLNK(from_st.st_mode)) { |
1096
|
0 |
0 |
if ((info->flags & GIT_CPDIR_SIMPLE_TO_MODE) != 0) |
1097
|
0 |
0 |
usemode = GIT_PERMS_FOR_WRITE(usemode); |
1115
|
0 |
0 |
if (git_str_joinpath(&path, from, "") < 0) /* ensure trailing slash */ |
1126
|
0 |
0 |
if ((flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0) { |
1131
|
0 |
0 |
if ((flags & GIT_CPDIR_CHMOD_DIRS) != 0) |
1135
|
0 |
0 |
info.mkdir_flags = |
1153
|
0 |
2676 |
if (stamp == NULL) |
1156
|
334 |
2342 |
if (p_stat(path, &st) < 0) |
1159
|
2307 |
35 |
if (stamp->mtime.tv_sec == st.st_mtime && |
|
2256 |
51 |
if (stamp->mtime.tv_sec == st.st_mtime && |
1163
|
2216 |
40 |
stamp->size == (uint64_t)st.st_size && |
1180
|
11 |
71 |
if (source) |
1190
|
171 |
0 |
if (st) { |
1212
|
0 |
0 |
if ((fd = p_open(path, O_RDONLY)) < 0) { |
1217
|
0 |
0 |
if ((error = p_fsync(fd)) < 0) |
1230
|
0 |
0 |
if ((parent = git_fs_path_dirname(path)) == NULL) |