line |
true |
false |
branch |
46
|
0 |
317 |
if (git_fs_path_exists(file->path_lock) == true) { |
54
|
144 |
173 |
if (flags & GIT_FILEBUF_CREATE_LEADING_DIRS) { |
61
|
0 |
317 |
if (file->fd < 0) |
66
|
3 |
314 |
if ((flags & GIT_FILEBUF_APPEND) && git_fs_path_exists(file->path_original) == true) { |
|
3 |
0 |
if ((flags & GIT_FILEBUF_APPEND) && git_fs_path_exists(file->path_original) == true) { |
73
|
0 |
3 |
if (source < 0) { |
80
|
3 |
3 |
while ((read_bytes = p_read(source, buffer, sizeof(buffer))) > 0) { |
81
|
0 |
3 |
if ((error = p_write(file->fd, buffer, read_bytes)) < 0) |
83
|
0 |
3 |
if (file->compute_digest) |
89
|
0 |
3 |
if (read_bytes < 0) { |
92
|
0 |
3 |
} else if (error < 0) { |
103
|
36 |
655 |
if (file->fd_is_open && file->fd >= 0) |
|
36 |
0 |
if (file->fd_is_open && file->fd >= 0) |
106
|
494 |
197 |
if (file->created_lock && !file->did_rename && file->path_lock && git_fs_path_exists(file->path_lock)) |
|
36 |
458 |
if (file->created_lock && !file->did_rename && file->path_lock && git_fs_path_exists(file->path_lock)) |
|
36 |
0 |
if (file->created_lock && !file->did_rename && file->path_lock && git_fs_path_exists(file->path_lock)) |
|
36 |
0 |
if (file->created_lock && !file->did_rename && file->path_lock && git_fs_path_exists(file->path_lock)) |
109
|
51 |
640 |
if (file->compute_digest) { |
114
|
491 |
200 |
if (file->buffer) |
118
|
177 |
514 |
if (file->z_buf) { |
123
|
474 |
217 |
if (file->path_original) |
125
|
494 |
197 |
if (file->path_lock) |
146
|
402 |
4 |
if (len > 0) { |
147
|
0 |
402 |
if (p_write(file->fd, (void *)source, len) < 0) { |
152
|
152 |
250 |
if (file->compute_digest) |
163
|
0 |
157 |
if (len > 0 || file->flush_mode == Z_FINISH) { |
|
0 |
0 |
if (len > 0 || file->flush_mode == Z_FINISH) { |
173
|
0 |
157 |
if (deflate(zs, file->flush_mode) == Z_STREAM_ERROR) { |
180
|
0 |
157 |
if (p_write(file->fd, file->z_buf, have) < 0) { |
185
|
0 |
157 |
} while (zs->avail_out == 0); |
187
|
0 |
157 |
GIT_ASSERT(zs->avail_in == 0); |
189
|
0 |
157 |
if (file->compute_digest) |
205
|
317 |
0 |
if ((error = git_str_grow(&target, GIT_PATH_MAX + 1)) < 0 || |
|
0 |
317 |
if ((error = git_str_grow(&target, GIT_PATH_MAX + 1)) < 0 || |
209
|
317 |
0 |
for (i = 0; i < MAX_SYMLINK_DEPTH; i++) { |
211
|
76 |
241 |
if (error < 0 && errno == ENOENT) { |
|
76 |
0 |
if (error < 0 && errno == ENOENT) { |
216
|
0 |
241 |
if (error < 0) { |
222
|
241 |
0 |
if (!S_ISLNK(st.st_mode)) { |
228
|
0 |
0 |
if (ret < 0) { |
234
|
0 |
0 |
if (ret == GIT_PATH_MAX) { |
245
|
0 |
0 |
if (root >= 0) { |
246
|
0 |
0 |
if ((error = git_str_sets(&curpath, target.ptr)) < 0) |
251
|
0 |
0 |
if ((error = git_fs_path_dirname_r(&dir, curpath.ptr)) < 0) |
257
|
0 |
0 |
if ((error = git_fs_path_apply_relative(&curpath, target.ptr)) < 0) |
281
|
0 |
494 |
GIT_ASSERT_ARG(file); |
282
|
0 |
494 |
GIT_ASSERT_ARG(path); |
283
|
0 |
494 |
GIT_ASSERT(file->buffer == NULL); |
287
|
3 |
491 |
if (flags & GIT_FILEBUF_DO_NOT_BUFFER) |
290
|
0 |
494 |
if (flags & GIT_FILEBUF_FSYNC) |
299
|
491 |
3 |
if (!file->do_not_buffer) { |
301
|
0 |
491 |
GIT_ERROR_CHECK_ALLOC(file->buffer); |
305
|
153 |
341 |
if (flags & GIT_FILEBUF_HASH_CONTENTS) { |
308
|
0 |
153 |
if (git_hash_ctx_init(&file->digest, GIT_HASH_ALGORITHM_SHA1) < 0) |
315
|
177 |
317 |
if (compression != 0) { |
317
|
0 |
177 |
if (deflateInit(&file->zs, compression) != Z_OK) { |
324
|
0 |
177 |
GIT_ERROR_CHECK_ALLOC(file->z_buf); |
334
|
177 |
317 |
if (flags & GIT_FILEBUF_TEMPORARY) { |
340
|
0 |
177 |
if (file->fd < 0) { |
350
|
0 |
177 |
GIT_ERROR_CHECK_ALLOC(file->path_lock); |
354
|
0 |
317 |
if ((error = resolve_symlink(&resolved_path, path)) < 0) |
362
|
0 |
317 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, path_len, GIT_FILELOCK_EXTLENGTH); |
|
0 |
317 |
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, path_len, GIT_FILELOCK_EXTLENGTH); |
364
|
0 |
317 |
GIT_ERROR_CHECK_ALLOC(file->path_lock); |
369
|
0 |
317 |
if (git_fs_path_isdir(file->path_original)) { |
376
|
0 |
317 |
if ((error = lock_file(file, flags, mode)) < 0) |
391
|
0 |
102 |
GIT_ASSERT_ARG(out); |
392
|
0 |
102 |
GIT_ASSERT_ARG(file); |
393
|
0 |
102 |
GIT_ASSERT_ARG(file->compute_digest); |
397
|
0 |
102 |
if (verify_last_error(file) < 0) |
411
|
0 |
162 |
GIT_ERROR_CHECK_ALLOC(file->path_original); |
419
|
0 |
458 |
GIT_ASSERT_ARG(file); |
420
|
0 |
458 |
GIT_ASSERT(file->path_original); |
425
|
0 |
458 |
if (verify_last_error(file) < 0) |
430
|
0 |
458 |
if (file->do_fsync && p_fsync(file->fd) < 0) { |
|
0 |
0 |
if (file->do_fsync && p_fsync(file->fd) < 0) { |
435
|
0 |
458 |
if (p_close(file->fd) < 0) { |
442
|
0 |
458 |
if (p_rename(file->path_lock, file->path_original) < 0) { |
447
|
0 |
458 |
if (file->do_fsync && git_futils_fsync_parent(file->path_original) < 0) |
|
0 |
0 |
if (file->do_fsync && git_futils_fsync_parent(file->path_original) < 0) |
470
|
0 |
2244 |
ENSURE_BUF_OK(file); |
472
|
3 |
2241 |
if (file->do_not_buffer) |
479
|
2241 |
0 |
if (space_left > len) { |
485
|
0 |
0 |
if (flush_buffer(file) < 0) |
499
|
0 |
206 |
ENSURE_BUF_OK(file); |
501
|
0 |
206 |
if (len > file->buf_size) { |
506
|
0 |
206 |
if (space_left <= len) { |
507
|
0 |
0 |
if (flush_buffer(file) < 0) |
524
|
0 |
147 |
ENSURE_BUF_OK(file); |
533
|
0 |
147 |
if (written < 0) { |
539
|
147 |
0 |
if (len + 1 <= space_left) { |
544
|
0 |
0 |
if (flush_buffer(file) < 0) |
549
|
0 |
0 |
} while (len + 1 <= space_left); |
551
|
0 |
0 |
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, len, 1) || |
|
0 |
0 |
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, len, 1) || |
561
|
0 |
0 |
if (written < 0) { |
578
|
0 |
0 |
if (file->fd_is_open) |
583
|
0 |
0 |
if (res < 0) { |
589
|
0 |
0 |
if (mtime) |
591
|
0 |
0 |
if (size) |