diff options
author | Edward Thomson <ethomson@microsoft.com> | 2013-11-04 18:28:57 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2013-11-04 22:33:05 -0500 |
commit | 1d3a8aeb4bd032d0bf34039fbcb308fba06b862a (patch) | |
tree | 8e9165cfd8c4c3919abd2d4f301b1f45e281d5eb | |
parent | f966acd13366d21e0b9beeecf021c0114596c716 (diff) | |
download | libgit2-1d3a8aeb4bd032d0bf34039fbcb308fba06b862a.tar.gz |
move mode_t to filebuf_open instead of _commit
-rw-r--r-- | src/blob.c | 2 | ||||
-rw-r--r-- | src/checkout.c | 4 | ||||
-rw-r--r-- | src/config_file.c | 4 | ||||
-rw-r--r-- | src/fetchhead.c | 4 | ||||
-rw-r--r-- | src/filebuf.c | 29 | ||||
-rw-r--r-- | src/filebuf.h | 6 | ||||
-rw-r--r-- | src/fileops.c | 11 | ||||
-rw-r--r-- | src/fileops.h | 2 | ||||
-rw-r--r-- | src/index.c | 4 | ||||
-rw-r--r-- | src/indexer.c | 10 | ||||
-rw-r--r-- | src/merge.c | 16 | ||||
-rw-r--r-- | src/merge.h | 1 | ||||
-rw-r--r-- | src/odb_loose.c | 10 | ||||
-rw-r--r-- | src/refdb_fs.c | 14 | ||||
-rw-r--r-- | src/repository.c | 6 | ||||
-rw-r--r-- | tests-clar/config/stress.c | 4 | ||||
-rw-r--r-- | tests-clar/core/filebuf.c | 20 | ||||
-rw-r--r-- | tests-clar/index/tests.c | 6 | ||||
-rw-r--r-- | tests-clar/odb/alternates.c | 4 |
19 files changed, 80 insertions, 77 deletions
diff --git a/src/blob.c b/src/blob.c index e18db4dfc..2c6d52800 100644 --- a/src/blob.c +++ b/src/blob.c @@ -284,7 +284,7 @@ int git_blob_create_fromchunks( content = git__malloc(BUFFER_SIZE); GITERR_CHECK_ALLOC(content); - if (git_filebuf_open(&file, git_buf_cstr(&path), GIT_FILEBUF_TEMPORARY) < 0) + if (git_filebuf_open(&file, git_buf_cstr(&path), GIT_FILEBUF_TEMPORARY, 0666) < 0) goto cleanup; while (1) { diff --git a/src/checkout.c b/src/checkout.c index a4f326637..6d7e3cfd4 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -1673,9 +1673,9 @@ static int checkout_write_merge( goto done; if ((error = git_futils_mkpath2file(path_workdir.ptr, 0755)) < 0 || - (error = git_filebuf_open(&output, path_workdir.ptr, GIT_FILEBUF_DO_NOT_BUFFER)) < 0 || + (error = git_filebuf_open(&output, path_workdir.ptr, GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 || (error = git_filebuf_write(&output, result.data, result.len)) < 0 || - (error = git_filebuf_commit(&output, result.mode)) < 0) + (error = git_filebuf_commit(&output)) < 0) goto done; done: diff --git a/src/config_file.c b/src/config_file.c index c7fc32060..40dcc5a37 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -1210,7 +1210,7 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p write_start = data_start; /* Lock the file */ - if (git_filebuf_open(&file, cfg->file_path, 0) < 0) + if (git_filebuf_open(&file, cfg->file_path, 0, GIT_CONFIG_FILE_MODE) < 0) return -1; skip_bom(reader); @@ -1369,7 +1369,7 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p /* refresh stats - if this errors, then commit will error too */ (void)git_filebuf_stats(&reader->file_mtime, &reader->file_size, &file); - result = git_filebuf_commit(&file, GIT_CONFIG_FILE_MODE); + result = git_filebuf_commit(&file); git_buf_free(&reader->buffer); return result; diff --git a/src/fetchhead.c b/src/fetchhead.c index 4dcebb857..9672623ff 100644 --- a/src/fetchhead.c +++ b/src/fetchhead.c @@ -112,7 +112,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs) if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) return -1; - if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE) < 0) { + if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) { git_buf_free(&path); return -1; } @@ -124,7 +124,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs) git_vector_foreach(fetchhead_refs, i, fetchhead_ref) fetchhead_ref_write(&file, fetchhead_ref); - return git_filebuf_commit(&file, GIT_REFS_FILE_MODE); + return git_filebuf_commit(&file); } static int fetchhead_ref_parse( diff --git a/src/filebuf.c b/src/filebuf.c index de2944bbc..9c3dae811 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -10,8 +10,6 @@ #include "filebuf.h" #include "fileops.h" -#define GIT_LOCK_FILE_MODE 0644 - static const size_t WRITE_BUFFER_SIZE = (4096 * 2); enum buferr_t { @@ -44,7 +42,7 @@ static int verify_last_error(git_filebuf *file) } } -static int lock_file(git_filebuf *file, int flags) +static int lock_file(git_filebuf *file, int flags, mode_t mode) { if (git_path_exists(file->path_lock) == true) { if (flags & GIT_FILEBUF_FORCE) @@ -60,9 +58,9 @@ static int lock_file(git_filebuf *file, int flags) /* create path to the file buffer is required */ if (flags & GIT_FILEBUF_FORCE) { /* XXX: Should dirmode here be configurable? Or is 0777 always fine? */ - file->fd = git_futils_creat_locked_withpath(file->path_lock, 0777, GIT_LOCK_FILE_MODE); + file->fd = git_futils_creat_locked_withpath(file->path_lock, 0777, mode); } else { - file->fd = git_futils_creat_locked(file->path_lock, GIT_LOCK_FILE_MODE); + file->fd = git_futils_creat_locked(file->path_lock, mode); } if (file->fd < 0) @@ -195,7 +193,7 @@ static int write_deflate(git_filebuf *file, void *source, size_t len) return 0; } -int git_filebuf_open(git_filebuf *file, const char *path, int flags) +int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode) { int compression, error = -1; size_t path_len; @@ -255,7 +253,7 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags) git_buf tmp_path = GIT_BUF_INIT; /* Open the file as temporary for locking */ - file->fd = git_futils_mktmp(&tmp_path, path); + file->fd = git_futils_mktmp(&tmp_path, path, mode); if (file->fd < 0) { git_buf_free(&tmp_path); @@ -282,7 +280,7 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags) memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH); /* open the file for locking */ - if ((error = lock_file(file, flags)) < 0) + if ((error = lock_file(file, flags, mode)) < 0) goto cleanup; } @@ -309,24 +307,20 @@ int git_filebuf_hash(git_oid *oid, git_filebuf *file) return 0; } -int git_filebuf_commit_at(git_filebuf *file, const char *path, mode_t mode) +int git_filebuf_commit_at(git_filebuf *file, const char *path) { git__free(file->path_original); file->path_original = git__strdup(path); GITERR_CHECK_ALLOC(file->path_original); - return git_filebuf_commit(file, mode); + return git_filebuf_commit(file); } -int git_filebuf_commit(git_filebuf *file, mode_t mode) +int git_filebuf_commit(git_filebuf *file) { - mode_t mask; - /* temporary files cannot be committed */ assert(file && file->path_original); - p_umask(mask = p_umask(0)); - file->flush_mode = Z_FINISH; flush_buffer(file); @@ -342,11 +336,6 @@ int git_filebuf_commit(git_filebuf *file, mode_t mode) file->fd = -1; - if (p_chmod(file->path_lock, (mode & ~mask))) { - giterr_set(GITERR_OS, "Failed to set attributes for file at '%s'", file->path_lock); - goto on_error; - } - p_unlink(file->path_original); if (p_rename(file->path_lock, file->path_original) < 0) { diff --git a/src/filebuf.h b/src/filebuf.h index 823af81bf..044af5405 100644 --- a/src/filebuf.h +++ b/src/filebuf.h @@ -77,9 +77,9 @@ int git_filebuf_write(git_filebuf *lock, const void *buff, size_t len); int git_filebuf_reserve(git_filebuf *file, void **buff, size_t len); int git_filebuf_printf(git_filebuf *file, const char *format, ...) GIT_FORMAT_PRINTF(2, 3); -int git_filebuf_open(git_filebuf *lock, const char *path, int flags); -int git_filebuf_commit(git_filebuf *lock, mode_t mode); -int git_filebuf_commit_at(git_filebuf *lock, const char *path, mode_t mode); +int git_filebuf_open(git_filebuf *lock, const char *path, int flags, mode_t mode); +int git_filebuf_commit(git_filebuf *lock); +int git_filebuf_commit_at(git_filebuf *lock, const char *path); void git_filebuf_cleanup(git_filebuf *lock); int git_filebuf_hash(git_oid *oid, git_filebuf *file); int git_filebuf_flush(git_filebuf *file); diff --git a/src/fileops.c b/src/fileops.c index 54bf5d850..1c27b277d 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -19,9 +19,12 @@ int git_futils_mkpath2file(const char *file_path, const mode_t mode) GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST | GIT_MKDIR_VERIFY_DIR); } -int git_futils_mktmp(git_buf *path_out, const char *filename) +int git_futils_mktmp(git_buf *path_out, const char *filename, mode_t mode) { int fd; + mode_t mask; + + p_umask(mask = p_umask(0)); git_buf_sets(path_out, filename); git_buf_puts(path_out, "_git2_XXXXXX"); @@ -35,6 +38,12 @@ int git_futils_mktmp(git_buf *path_out, const char *filename) return -1; } + if (p_chmod(path_out->ptr, (mode & ~mask))) { + giterr_set(GITERR_OS, + "Failed to set permissions on file '%s'", path_out->ptr); + return -1; + } + return fd; } diff --git a/src/fileops.h b/src/fileops.h index 1b2728e58..59a6a21a7 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -141,7 +141,7 @@ extern int git_futils_rmdir_r(const char *path, const char *base, uint32_t flags * Writes the filename into path_out. * @return On success, an open file descriptor, else an error code < 0. */ -extern int git_futils_mktmp(git_buf *path_out, const char *filename); +extern int git_futils_mktmp(git_buf *path_out, const char *filename, mode_t mode); /** * Move a file on the filesystem, create the diff --git a/src/index.c b/src/index.c index dbf1ab529..ecab15024 100644 --- a/src/index.c +++ b/src/index.c @@ -500,7 +500,7 @@ int git_index_write(git_index *index) git_vector_sort(&index->reuc); if ((error = git_filebuf_open( - &file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS)) < 0) { + &file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) { if (error == GIT_ELOCKED) giterr_set(GITERR_INDEX, "The index is locked. This might be due to a concurrrent or crashed process"); @@ -512,7 +512,7 @@ int git_index_write(git_index *index) return error; } - if ((error = git_filebuf_commit(&file, GIT_INDEX_FILE_MODE)) < 0) + if ((error = git_filebuf_commit(&file)) < 0) return error; error = git_futils_filestamp_check(&index->stamp, index->index_file_path); diff --git a/src/indexer.c b/src/indexer.c index 0873c8cf0..90fb52187 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -140,7 +140,8 @@ int git_indexer_new( goto cleanup; error = git_filebuf_open(&idx->pack_file, path.ptr, - GIT_FILEBUF_TEMPORARY | GIT_FILEBUF_DO_NOT_BUFFER); + GIT_FILEBUF_TEMPORARY | GIT_FILEBUF_DO_NOT_BUFFER, + GIT_PACK_FILE_MODE); git_buf_free(&path); if (error < 0) goto cleanup; @@ -903,7 +904,8 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) if (git_buf_oom(&filename)) return -1; - if (git_filebuf_open(&index_file, filename.ptr, GIT_FILEBUF_HASH_CONTENTS) < 0) + if (git_filebuf_open(&index_file, filename.ptr, + GIT_FILEBUF_HASH_CONTENTS, GIT_PACK_FILE_MODE) < 0) goto on_error; /* Write out the header */ @@ -969,7 +971,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) goto on_error; /* Commit file */ - if (git_filebuf_commit_at(&index_file, filename.ptr, GIT_PACK_FILE_MODE) < 0) + if (git_filebuf_commit_at(&index_file, filename.ptr) < 0) goto on_error; git_mwindow_free_all(&idx->pack->mwf); @@ -980,7 +982,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) if (index_path(&filename, idx, ".pack") < 0) goto on_error; /* And don't forget to rename the packfile to its new place. */ - if (git_filebuf_commit_at(&idx->pack_file, filename.ptr, GIT_PACK_FILE_MODE) < 0) + if (git_filebuf_commit_at(&idx->pack_file, filename.ptr) < 0) return -1; git_buf_free(&filename); diff --git a/src/merge.c b/src/merge.c index a22801e48..ea2224d86 100644 --- a/src/merge.c +++ b/src/merge.c @@ -1623,9 +1623,9 @@ static int write_orig_head( git_oid_tostr(orig_oid_str, GIT_OID_HEXSZ+1, &our_head->oid); if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 && - (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE)) == 0 && + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 && (error = git_filebuf_printf(&file, "%s\n", orig_oid_str)) == 0) - error = git_filebuf_commit(&file, 0666); + error = git_filebuf_commit(&file); if (error < 0) git_filebuf_cleanup(&file); @@ -1649,7 +1649,7 @@ static int write_merge_head( assert(repo && heads); if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_HEAD_FILE)) < 0 || - (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE)) < 0) + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) goto cleanup; for (i = 0; i < heads_len; i++) { @@ -1659,7 +1659,7 @@ static int write_merge_head( goto cleanup; } - error = git_filebuf_commit(&file, 0666); + error = git_filebuf_commit(&file); cleanup: if (error < 0) @@ -1682,10 +1682,10 @@ static int write_merge_mode(git_repository *repo, unsigned int flags) assert(repo); if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MODE_FILE)) < 0 || - (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE)) < 0) + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) goto cleanup; - error = git_filebuf_commit(&file, 0666); + error = git_filebuf_commit(&file); cleanup: if (error < 0) @@ -1911,7 +1911,7 @@ static int write_merge_msg( entries[i].merge_head = heads[i]; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || - (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0 || (error = git_filebuf_write(&file, "Merge ", 6)) < 0) goto cleanup; @@ -1988,7 +1988,7 @@ static int write_merge_msg( } if ((error = git_filebuf_printf(&file, "\n")) < 0 || - (error = git_filebuf_commit(&file, 0666)) < 0) + (error = git_filebuf_commit(&file)) < 0) goto cleanup; cleanup: diff --git a/src/merge.h b/src/merge.h index ba6725de9..0ecad6e3e 100644 --- a/src/merge.h +++ b/src/merge.h @@ -16,6 +16,7 @@ #define GIT_MERGE_MSG_FILE "MERGE_MSG" #define GIT_MERGE_MODE_FILE "MERGE_MODE" +#define GIT_MERGE_FILE_MODE 0666 #define GIT_MERGE_TREE_RENAME_THRESHOLD 50 #define GIT_MERGE_TREE_TARGET_LIMIT 1000 diff --git a/src/odb_loose.c b/src/odb_loose.c index 3e52edf05..ced272b33 100644 --- a/src/odb_loose.c +++ b/src/odb_loose.c @@ -789,7 +789,7 @@ static int loose_backend__stream_fwrite(git_odb_stream *_stream, const git_oid * error = -1; else error = git_filebuf_commit_at( - &stream->fbuf, final_path.ptr, backend->object_file_mode); + &stream->fbuf, final_path.ptr); git_buf_free(&final_path); @@ -838,7 +838,8 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_ if (git_buf_joinpath(&tmp_path, backend->objects_dir, "tmp_object") < 0 || git_filebuf_open(&stream->fbuf, tmp_path.ptr, GIT_FILEBUF_TEMPORARY | - (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT)) < 0 || + (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT), + backend->object_file_mode) < 0 || stream->stream.write((git_odb_stream *)stream, hdr, hdrlen) < 0) { git_filebuf_cleanup(&stream->fbuf); @@ -867,7 +868,8 @@ static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, c if (git_buf_joinpath(&final_path, backend->objects_dir, "tmp_object") < 0 || git_filebuf_open(&fbuf, final_path.ptr, GIT_FILEBUF_TEMPORARY | - (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT)) < 0) + (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT), + backend->object_file_mode) < 0) { error = -1; goto cleanup; @@ -878,7 +880,7 @@ static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, c if (object_file_name(&final_path, backend, oid) < 0 || object_mkdir(&final_path, backend) < 0 || - git_filebuf_commit_at(&fbuf, final_path.ptr, backend->object_file_mode) < 0) + git_filebuf_commit_at(&fbuf, final_path.ptr) < 0) error = -1; cleanup: diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 7ce09ba55..62d5c1047 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -702,7 +702,7 @@ static int loose_write(refdb_fs_backend *backend, const git_reference *ref) if (git_buf_joinpath(&ref_path, backend->path, ref->name) < 0) return -1; - if (git_filebuf_open(&file, ref_path.ptr, GIT_FILEBUF_FORCE) < 0) { + if (git_filebuf_open(&file, ref_path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) { git_buf_free(&ref_path); return -1; } @@ -720,7 +720,7 @@ static int loose_write(refdb_fs_backend *backend, const git_reference *ref) assert(0); /* don't let this happen */ } - return git_filebuf_commit(&file, GIT_REFS_FILE_MODE); + return git_filebuf_commit(&file); } /* @@ -865,7 +865,7 @@ static int packed_write(refdb_fs_backend *backend) return -1; /* Open the file! */ - if (git_filebuf_open(&pack_file, git_sortedcache_path(refcache), 0) < 0) + if (git_filebuf_open(&pack_file, git_sortedcache_path(refcache), 0, GIT_PACKEDREFS_FILE_MODE) < 0) goto fail; /* Packfiles have a header... apparently @@ -886,7 +886,7 @@ static int packed_write(refdb_fs_backend *backend) /* if we've written all the references properly, we can commit * the packfile to make the changes effective */ - if (git_filebuf_commit(&pack_file, GIT_PACKEDREFS_FILE_MODE) < 0) + if (git_filebuf_commit(&pack_file) < 0) goto fail; /* when and only when the packfile has been properly written, @@ -1289,7 +1289,7 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo goto cleanup; } - if ((error = git_filebuf_open(&fbuf, git_buf_cstr(&log_path), 0)) < 0) + if ((error = git_filebuf_open(&fbuf, git_buf_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE)) < 0) goto cleanup; git_vector_foreach(&reflog->entries, i, entry) { @@ -1300,7 +1300,7 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo goto cleanup; } - error = git_filebuf_commit(&fbuf, GIT_REFLOG_FILE_MODE); + error = git_filebuf_commit(&fbuf); goto success; cleanup: @@ -1350,7 +1350,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_ if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0) return -1; - if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path))) < 0) { + if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) { error = -1; goto cleanup; } diff --git a/src/repository.c b/src/repository.c index c5ce8425f..dcc02e4fb 100644 --- a/src/repository.c +++ b/src/repository.c @@ -816,7 +816,7 @@ static int repo_init_create_head(const char *git_dir, const char *ref_name) const char *fmt; if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 || - git_filebuf_open(&ref, ref_path.ptr, 0) < 0) + git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE) < 0) goto fail; if (!ref_name) @@ -828,7 +828,7 @@ static int repo_init_create_head(const char *git_dir, const char *ref_name) fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n"; if (git_filebuf_printf(&ref, fmt, ref_name) < 0 || - git_filebuf_commit(&ref, GIT_REFS_FILE_MODE) < 0) + git_filebuf_commit(&ref) < 0) goto fail; git_buf_free(&ref_path); @@ -875,7 +875,7 @@ static bool are_symlinks_supported(const char *wd_path) struct stat st; int symlinks_supported = -1; - if ((fd = git_futils_mktmp(&path, wd_path)) < 0 || + if ((fd = git_futils_mktmp(&path, wd_path, 0666)) < 0 || p_close(fd) < 0 || p_unlink(path.ptr) < 0 || p_symlink("testing", path.ptr) < 0 || diff --git a/tests-clar/config/stress.c b/tests-clar/config/stress.c index 8cc64d23c..eeca54ff4 100644 --- a/tests-clar/config/stress.c +++ b/tests-clar/config/stress.c @@ -10,12 +10,12 @@ void test_config_stress__initialize(void) { git_filebuf file = GIT_FILEBUF_INIT; - cl_git_pass(git_filebuf_open(&file, TEST_CONFIG, 0)); + cl_git_pass(git_filebuf_open(&file, TEST_CONFIG, 0, 0666)); git_filebuf_printf(&file, "[color]\n\tui = auto\n"); git_filebuf_printf(&file, "[core]\n\teditor = \n"); - cl_git_pass(git_filebuf_commit(&file, 0666)); + cl_git_pass(git_filebuf_commit(&file)); } void test_config_stress__cleanup(void) diff --git a/tests-clar/core/filebuf.c b/tests-clar/core/filebuf.c index 646d42c6e..5a3e7510f 100644 --- a/tests-clar/core/filebuf.c +++ b/tests-clar/core/filebuf.c @@ -13,7 +13,7 @@ void test_core_filebuf__0(void) cl_must_pass(fd); cl_must_pass(p_close(fd)); - cl_git_fail(git_filebuf_open(&file, test, 0)); + cl_git_fail(git_filebuf_open(&file, test, 0, 0666)); cl_assert(git_path_exists(testlock)); cl_must_pass(p_unlink(testlock)); @@ -28,9 +28,9 @@ void test_core_filebuf__1(void) cl_git_mkfile(test, "libgit2 rocks\n"); - cl_git_pass(git_filebuf_open(&file, test, GIT_FILEBUF_APPEND)); + cl_git_pass(git_filebuf_open(&file, test, GIT_FILEBUF_APPEND, 0666)); cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks")); - cl_git_pass(git_filebuf_commit(&file, 0666)); + cl_git_pass(git_filebuf_commit(&file)); cl_assert_equal_file("libgit2 rocks\nlibgit2 rocks\n", 0, test); @@ -47,9 +47,9 @@ void test_core_filebuf__2(void) memset(buf, 0xfe, sizeof(buf)); - cl_git_pass(git_filebuf_open(&file, test, 0)); + cl_git_pass(git_filebuf_open(&file, test, 0, 0666)); cl_git_pass(git_filebuf_write(&file, buf, sizeof(buf))); - cl_git_pass(git_filebuf_commit(&file, 0666)); + cl_git_pass(git_filebuf_commit(&file)); cl_assert_equal_file((char *)buf, sizeof(buf), test); @@ -64,7 +64,7 @@ void test_core_filebuf__4(void) cl_assert(file.buffer == NULL); - cl_git_pass(git_filebuf_open(&file, test, 0)); + cl_git_pass(git_filebuf_open(&file, test, 0, 0666)); cl_assert(file.buffer != NULL); git_filebuf_cleanup(&file); @@ -80,12 +80,12 @@ void test_core_filebuf__5(void) cl_assert(file.buffer == NULL); - cl_git_pass(git_filebuf_open(&file, test, 0)); + cl_git_pass(git_filebuf_open(&file, test, 0, 0666)); cl_assert(file.buffer != NULL); cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks")); cl_assert(file.buffer != NULL); - cl_git_pass(git_filebuf_commit(&file, 0666)); + cl_git_pass(git_filebuf_commit(&file)); cl_assert(file.buffer == NULL); cl_must_pass(p_unlink(test)); @@ -110,12 +110,12 @@ void test_core_filebuf__umask(void) cl_assert(file.buffer == NULL); - cl_git_pass(git_filebuf_open(&file, test, 0)); + cl_git_pass(git_filebuf_open(&file, test, 0, 0666)); cl_assert(file.buffer != NULL); cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks")); cl_assert(file.buffer != NULL); - cl_git_pass(git_filebuf_commit(&file, 0666)); + cl_git_pass(git_filebuf_commit(&file)); cl_assert(file.buffer == NULL); cl_must_pass(p_stat("test", &statbuf)); diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c index 09b05bf6e..e5202980c 100644 --- a/tests-clar/index/tests.c +++ b/tests-clar/index/tests.c @@ -224,9 +224,9 @@ void test_index_tests__add(void) /* Create a new file in the working directory */ cl_git_pass(git_futils_mkpath2file("myrepo/test.txt", 0777)); - cl_git_pass(git_filebuf_open(&file, "myrepo/test.txt", 0)); + cl_git_pass(git_filebuf_open(&file, "myrepo/test.txt", 0, 0666)); cl_git_pass(git_filebuf_write(&file, "hey there\n", 10)); - cl_git_pass(git_filebuf_commit(&file, 0666)); + cl_git_pass(git_filebuf_commit(&file)); /* Store the expected hash of the file/blob * This has been generated by executing the following @@ -474,7 +474,7 @@ void test_index_tests__elocked(void) cl_git_pass(git_repository_index(&index, repo)); /* Lock the index file so we fail to lock it */ - cl_git_pass(git_filebuf_open(&file, index->index_file_path, 0)); + cl_git_pass(git_filebuf_open(&file, index->index_file_path, 0, 0666)); error = git_index_write(index); cl_assert_equal_i(GIT_ELOCKED, error); diff --git a/tests-clar/odb/alternates.c b/tests-clar/odb/alternates.c index 4e876c2b3..c75f6feaa 100644 --- a/tests-clar/odb/alternates.c +++ b/tests-clar/odb/alternates.c @@ -32,9 +32,9 @@ static void init_linked_repo(const char *path, const char *alternate) cl_git_pass(git_futils_mkdir(filepath.ptr, NULL, 0755, GIT_MKDIR_PATH)); cl_git_pass(git_buf_joinpath(&filepath, filepath.ptr , "alternates")); - cl_git_pass(git_filebuf_open(&file, git_buf_cstr(&filepath), 0)); + cl_git_pass(git_filebuf_open(&file, git_buf_cstr(&filepath), 0, 0666)); git_filebuf_printf(&file, "%s\n", git_buf_cstr(&destpath)); - cl_git_pass(git_filebuf_commit(&file, 0644)); + cl_git_pass(git_filebuf_commit(&file)); git_repository_free(repo); } |