mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 01:58:32 +00:00

The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
#include "clay_libgit2.h"
|
|
#include "filebuf.h"
|
|
|
|
/* make sure git_filebuf_open doesn't delete an existing lock */
|
|
void test_core_filebuf__0(void)
|
|
{
|
|
git_filebuf file;
|
|
int fd;
|
|
char test[] = "test", testlock[] = "test.lock";
|
|
|
|
fd = p_creat(testlock, 0744);
|
|
|
|
cl_must_pass(fd);
|
|
cl_must_pass(p_close(fd));
|
|
|
|
cl_git_fail(git_filebuf_open(&file, test, 0));
|
|
cl_git_pass(git_futils_exists(testlock));
|
|
|
|
cl_must_pass(p_unlink(testlock));
|
|
}
|
|
|
|
|
|
/* make sure GIT_FILEBUF_APPEND works as expected */
|
|
void test_core_filebuf__1(void)
|
|
{
|
|
git_filebuf file;
|
|
int fd;
|
|
char test[] = "test";
|
|
|
|
fd = p_creat(test, 0666);
|
|
cl_must_pass(fd);
|
|
cl_must_pass(p_write(fd, "libgit2 rocks\n", 14));
|
|
cl_must_pass(p_close(fd));
|
|
|
|
cl_git_pass(git_filebuf_open(&file, test, GIT_FILEBUF_APPEND));
|
|
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
|
|
cl_git_pass(git_filebuf_commit(&file, 0666));
|
|
|
|
cl_must_pass(p_unlink(test));
|
|
}
|
|
|
|
|
|
/* make sure git_filebuf_write writes large buffer correctly */
|
|
void test_core_filebuf__2(void)
|
|
{
|
|
git_filebuf file;
|
|
char test[] = "test";
|
|
unsigned char buf[4096 * 4]; /* 2 * WRITE_BUFFER_SIZE */
|
|
|
|
memset(buf, 0xfe, sizeof(buf));
|
|
|
|
cl_git_pass(git_filebuf_open(&file, test, 0));
|
|
cl_git_pass(git_filebuf_write(&file, buf, sizeof(buf)));
|
|
cl_git_pass(git_filebuf_commit(&file, 0666));
|
|
|
|
cl_must_pass(p_unlink(test));
|
|
}
|
|
|