From 33127043b3ef8dd8dd695ba3613eaa104a80a56b Mon Sep 17 00:00:00 2001 From: Brodie Rao Date: Fri, 14 Oct 2011 14:18:02 -0700 Subject: fileops/posix: replace usage of "int mode" with "mode_t mode" Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t. --- tests/t10-refs.c | 2 +- tests/t12-repo.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/t10-refs.c b/tests/t10-refs.c index c7bfe4eea..aa6735a30 100644 --- a/tests/t10-refs.c +++ b/tests/t10-refs.c @@ -431,7 +431,7 @@ END_TEST BEGIN_TEST(pack0, "create a packfile for an empty folder") git_repository *repo; char temp_path[GIT_PATH_MAX]; - const int mode = 0755; /* or 0777 ? */ + const mode_t mode = 0755; /* or 0777 ? */ must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); diff --git a/tests/t12-repo.c b/tests/t12-repo.c index de921f9ca..6884188a3 100644 --- a/tests/t12-repo.c +++ b/tests/t12-repo.c @@ -173,7 +173,7 @@ END_TEST BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory") char path_repository[GIT_PATH_MAX]; char current_workdir[GIT_PATH_MAX]; - const int mode = 0755; /* or 0777 ? */ + const mode_t mode = 0755; /* or 0777 ? */ git_repository* repo; must_pass(p_getcwd(current_workdir, sizeof(current_workdir))); @@ -232,7 +232,7 @@ BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of t char current_workdir[GIT_PATH_MAX]; char path_repository[GIT_PATH_MAX]; - const int mode = 0755; /* or 0777 ? */ + const mode_t mode = 0755; /* or 0777 ? */ git_repository* repo; /* Setup the repository to open */ @@ -384,7 +384,7 @@ BEGIN_TEST(discover0, "test discover") char repository_path[GIT_PATH_MAX]; char sub_repository_path[GIT_PATH_MAX]; char found_path[GIT_PATH_MAX]; - int mode = 0755; + mode_t mode = 0755; git_futils_mkdir_r(DISCOVER_FOLDER, mode); must_pass(append_ceiling_dir(ceiling_dirs, TEMP_REPO_FOLDER)); -- cgit v1.2.1 From ce8cd006ce3adcd012a38401b8a7555ba3307b3f Mon Sep 17 00:00:00 2001 From: Brodie Rao Date: Wed, 7 Sep 2011 15:32:44 -0700 Subject: fileops/repository: create (most) directories with 0777 permissions To further match how Git behaves, this change makes most of the directories libgit2 creates in a git repo have a file mode of 0777. Specifically: - Intermediate directories created with git_futils_mkpath2file() have 0777 permissions. This affects odb_loose, reflog, and refs. - The top level folder for bare repos is created with 0777 permissions. - The top level folder for non-bare repos is created with 0755 permissions. - /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are created with 0777 permissions. Additionally, the following changes have been made: - fileops functions that create intermediate directories have grown a new dirmode parameter. The only exception to this is filebuf's lock_file(), which unconditionally creates intermediate directories with 0777 permissions when GIT_FILEBUF_FORCE is set. - The test runner now sets the umask to 0 before running any tests. This ensurses all file mode checks are consistent across systems. - t09-tree.c now does a directory permissions check. I've avoided adding this check to other tests that might reuse existing directories from the prefabricated test repos. Because they're checked into the repo, they have 0755 permissions. - Other assorted directories created by tests have 0777 permissions. --- tests/t00-core.c | 18 +++++++++--------- tests/t03-objwrite.c | 2 +- tests/t06-index.c | 2 +- tests/t09-tree.c | 3 +++ tests/t10-refs.c | 3 +-- tests/t12-repo.c | 8 ++++---- tests/test_helpers.c | 42 ++++++++++++++++++++++++++++++++++++++---- tests/test_helpers.h | 4 ++++ tests/test_main.c | 4 ++++ 9 files changed, 65 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/t00-core.c b/tests/t00-core.c index 703504bf8..185681562 100644 --- a/tests/t00-core.c +++ b/tests/t00-core.c @@ -250,14 +250,14 @@ static int setup(walk_data *d) { name_data *n; - if (p_mkdir(top_dir, 0755) < 0) + if (p_mkdir(top_dir, 0777) < 0) return error("can't mkdir(\"%s\")", top_dir); if (p_chdir(top_dir) < 0) return error("can't chdir(\"%s\")", top_dir); if (strcmp(d->sub, ".") != 0) - if (p_mkdir(d->sub, 0755) < 0) + if (p_mkdir(d->sub, 0777) < 0) return error("can't mkdir(\"%s\")", d->sub); strcpy(path_buffer, d->sub); @@ -510,27 +510,27 @@ static int setup_empty_tmp_dir(void) { char path[GIT_PATH_MAX]; - if (p_mkdir(empty_tmp_dir, 0755)) + if (p_mkdir(empty_tmp_dir, 0777)) return -1; git_path_join(path, empty_tmp_dir, "/one"); - if (p_mkdir(path, 0755)) + if (p_mkdir(path, 0777)) return -1; git_path_join(path, empty_tmp_dir, "/one/two_one"); - if (p_mkdir(path, 0755)) + if (p_mkdir(path, 0777)) return -1; git_path_join(path, empty_tmp_dir, "/one/two_two"); - if (p_mkdir(path, 0755)) + if (p_mkdir(path, 0777)) return -1; git_path_join(path, empty_tmp_dir, "/one/two_two/three"); - if (p_mkdir(path, 0755)) + if (p_mkdir(path, 0777)) return -1; git_path_join(path, empty_tmp_dir, "/two"); - if (p_mkdir(path, 0755)) + if (p_mkdir(path, 0777)) return -1; return 0; @@ -547,7 +547,7 @@ BEGIN_TEST(rmdir1, "make sure non-empty dir cannot be deleted recusively") must_pass(setup_empty_tmp_dir()); git_path_join(file, empty_tmp_dir, "/two/file.txt"); - fd = p_creat(file, 0755); + fd = p_creat(file, 0777); must_pass(fd); must_pass(p_close(fd)); must_fail(git_futils_rmdir_r(empty_tmp_dir, 0)); diff --git a/tests/t03-objwrite.c b/tests/t03-objwrite.c index 31f611a5c..7563d0e3a 100644 --- a/tests/t03-objwrite.c +++ b/tests/t03-objwrite.c @@ -31,7 +31,7 @@ static char *odb_dir = "test-objects"; static int make_odb_dir(void) { - if (p_mkdir(odb_dir, 0755) < 0) { + if (p_mkdir(odb_dir, GIT_OBJECT_DIR_MODE) < 0) { int err = errno; fprintf(stderr, "can't make directory \"%s\"", odb_dir); if (err == EEXIST) diff --git a/tests/t06-index.c b/tests/t06-index.c index 621e742b3..dde98abaf 100644 --- a/tests/t06-index.c +++ b/tests/t06-index.c @@ -176,7 +176,7 @@ BEGIN_TEST(add0, "add a new file to the index") must_pass(git_index_entrycount(index) == 0); /* Create a new file in the working directory */ - must_pass(git_futils_mkpath2file(TEMP_REPO_FOLDER "myrepo/test.txt")); + must_pass(git_futils_mkpath2file(TEMP_REPO_FOLDER "myrepo/test.txt", 0777)); must_pass(git_filebuf_open(&file, TEMP_REPO_FOLDER "myrepo/test.txt", 0)); must_pass(git_filebuf_write(&file, "hey there\n", 10)); must_pass(git_filebuf_commit(&file)); diff --git a/tests/t09-tree.c b/tests/t09-tree.c index 3af06ea67..1f2fe3f02 100644 --- a/tests/t09-tree.c +++ b/tests/t09-tree.c @@ -200,6 +200,9 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory") // check data is correct must_pass(git_tree_lookup(&tree, repo, &id_hiearar)); must_be_true(2 == git_tree_entrycount(tree)); +#ifndef GIT_WIN32 + must_be_true((loose_object_dir_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_DIR_MODE); +#endif git_tree_close(tree); close_temp_repo(repo); diff --git a/tests/t10-refs.c b/tests/t10-refs.c index aa6735a30..4cb31d5e7 100644 --- a/tests/t10-refs.c +++ b/tests/t10-refs.c @@ -431,12 +431,11 @@ END_TEST BEGIN_TEST(pack0, "create a packfile for an empty folder") git_repository *repo; char temp_path[GIT_PATH_MAX]; - const mode_t mode = 0755; /* or 0777 ? */ must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); git_path_join_n(temp_path, 3, repo->path_repository, GIT_REFS_HEADS_DIR, "empty_dir"); - must_pass(git_futils_mkdir_r(temp_path, mode)); + must_pass(git_futils_mkdir_r(temp_path, GIT_REFS_DIR_MODE)); must_pass(git_reference_packall(repo)); diff --git a/tests/t12-repo.c b/tests/t12-repo.c index 6884188a3..c07150c9c 100644 --- a/tests/t12-repo.c +++ b/tests/t12-repo.c @@ -173,7 +173,7 @@ END_TEST BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory") char path_repository[GIT_PATH_MAX]; char current_workdir[GIT_PATH_MAX]; - const mode_t mode = 0755; /* or 0777 ? */ + const mode_t mode = 0777; git_repository* repo; must_pass(p_getcwd(current_workdir, sizeof(current_workdir))); @@ -232,7 +232,7 @@ BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of t char current_workdir[GIT_PATH_MAX]; char path_repository[GIT_PATH_MAX]; - const mode_t mode = 0755; /* or 0777 ? */ + const mode_t mode = 0777; git_repository* repo; /* Setup the repository to open */ @@ -351,7 +351,7 @@ static int write_file(const char *path, const char *content) return error; } - file = git_futils_creat_withpath(path, 0644); + file = git_futils_creat_withpath(path, 0777, 0644); if (file < GIT_SUCCESS) return file; @@ -384,7 +384,7 @@ BEGIN_TEST(discover0, "test discover") char repository_path[GIT_PATH_MAX]; char sub_repository_path[GIT_PATH_MAX]; char found_path[GIT_PATH_MAX]; - mode_t mode = 0755; + const mode_t mode = 0777; git_futils_mkdir_r(DISCOVER_FOLDER, mode); must_pass(append_ceiling_dir(ceiling_dirs, TEMP_REPO_FOLDER)); diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 0900430e1..7074e4822 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -42,7 +42,7 @@ int write_object_data(char *file, void *data, size_t len) int write_object_files(const char *odb_dir, object_data *d) { - if (p_mkdir(odb_dir, 0755) < 0) { + if (p_mkdir(odb_dir, GIT_OBJECT_DIR_MODE) < 0) { int err = errno; fprintf(stderr, "can't make directory \"%s\"", odb_dir); if (err == EEXIST) @@ -51,7 +51,7 @@ int write_object_files(const char *odb_dir, object_data *d) return -1; } - if ((p_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) { + if ((p_mkdir(d->dir, GIT_OBJECT_DIR_MODE) < 0) && (errno != EEXIST)) { fprintf(stderr, "can't make object directory \"%s\"\n", d->dir); return -1; } @@ -82,7 +82,7 @@ int remove_object_files(const char *odb_dir, object_data *d) return 0; } -int remove_loose_object(const char *repository_folder, git_object *object) +void locate_loose_object(const char *repository_folder, git_object *object, char **out, char **out_folder) { static const char *objects_folder = "objects/"; @@ -104,6 +104,40 @@ int remove_loose_object(const char *repository_folder, git_object *object) ptr += GIT_OID_HEXSZ + 1; *ptr = 0; + *out = full_path; + + if (out_folder) + *out_folder = top_folder; +} + +int loose_object_dir_mode(const char *repository_folder, git_object *object) +{ + char *object_path; + size_t pos; + struct stat st; + + locate_loose_object(repository_folder, object, &object_path, NULL); + + pos = strlen(object_path); + while (pos--) { + if (object_path[pos] == '/') { + object_path[pos] = 0; + break; + } + } + + assert(p_stat(object_path, &st) == 0); + free(object_path); + + return st.st_mode; +} + +int remove_loose_object(const char *repository_folder, git_object *object) +{ + char *full_path, *top_folder; + + locate_loose_object(repository_folder, object, &full_path, &top_folder); + if (p_unlink(full_path) < 0) { fprintf(stderr, "can't delete object file \"%s\"\n", full_path); return -1; @@ -141,7 +175,7 @@ int copy_file(const char *src, const char *dst) if (git_futils_readbuffer(&source_buf, src) < GIT_SUCCESS) return GIT_ENOTFOUND; - dst_fd = git_futils_creat_withpath(dst, 0644); + dst_fd = git_futils_creat_withpath(dst, 0777, 0644); if (dst_fd < 0) goto cleanup; diff --git a/tests/test_helpers.h b/tests/test_helpers.h index 53361b7b1..2e5194d7c 100644 --- a/tests/test_helpers.h +++ b/tests/test_helpers.h @@ -63,6 +63,10 @@ extern int remove_object_files(const char *odb_dir, object_data *d); extern int cmp_objects(git_rawobj *o, object_data *d); +extern void locate_loose_object(const char *odb_dir, git_object *object, char **out, char **out_folder); + +extern int loose_object_dir_mode(const char *odb_dir, git_object *object); + extern int remove_loose_object(const char *odb_dir, git_object *object); extern int cmp_files(const char *a, const char *b); diff --git a/tests/test_main.c b/tests/test_main.c index c9f8da3a4..9961ffd6b 100644 --- a/tests/test_main.c +++ b/tests/test_main.c @@ -26,6 +26,8 @@ #include #include +#include "posix.h" + #include "test_lib.h" #include "test_helpers.h" @@ -81,6 +83,8 @@ main(int GIT_UNUSED(argc), char *GIT_UNUSED(argv[])) GIT_UNUSED_ARG(argc); GIT_UNUSED_ARG(argv); + p_umask(0); + failures = 0; for (i = 0; i < GIT_SUITE_COUNT; ++i) -- cgit v1.2.1 From 01ad7b3a9ec8f5e465f94c2704e1e96b84f941c7 Mon Sep 17 00:00:00 2001 From: Brodie Rao Date: Tue, 6 Sep 2011 15:48:45 -0700 Subject: *: correct and codify various file permissions 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". --- tests/t00-core.c | 8 ++++---- tests/t04-commit.c | 4 ++++ tests/t06-index.c | 2 +- tests/t08-tag.c | 3 +++ tests/t09-tree.c | 1 + tests/t12-repo.c | 2 +- tests/t15-config.c | 2 +- tests/t18-status.c | 4 ++-- tests/test_helpers.c | 14 +++++++++++++- tests/test_helpers.h | 1 + 10 files changed, 31 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/t00-core.c b/tests/t00-core.c index 185681562..dbc80670f 100644 --- a/tests/t00-core.c +++ b/tests/t00-core.c @@ -264,7 +264,7 @@ static int setup(walk_data *d) state_loc = d; for (n = d->names; n->name; n++) { - git_file fd = p_creat(n->name, 0600); + git_file fd = p_creat(n->name, 0666); if (fd < 0) return GIT_ERROR; p_close(fd); @@ -479,14 +479,14 @@ BEGIN_TEST(filebuf1, "make sure GIT_FILEBUF_APPEND works as expected") int fd; char test[] = "test"; - fd = p_creat(test, 0644); + fd = p_creat(test, 0666); must_pass(fd); must_pass(p_write(fd, "libgit2 rocks\n", 14)); must_pass(p_close(fd)); must_pass(git_filebuf_open(&file, test, GIT_FILEBUF_APPEND)); must_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks")); - must_pass(git_filebuf_commit(&file)); + must_pass(git_filebuf_commit(&file, 0666)); must_pass(p_unlink(test)); END_TEST @@ -499,7 +499,7 @@ BEGIN_TEST(filebuf2, "make sure git_filebuf_write writes large buffer correctly" memset(buf, 0xfe, sizeof(buf)); must_pass(git_filebuf_open(&file, test, 0)); must_pass(git_filebuf_write(&file, buf, sizeof(buf))); - must_pass(git_filebuf_commit(&file)); + must_pass(git_filebuf_commit(&file, 0666)); must_pass(p_unlink(test)); END_TEST diff --git a/tests/t04-commit.c b/tests/t04-commit.c index 3fb4d370c..4abbf01c2 100644 --- a/tests/t04-commit.c +++ b/tests/t04-commit.c @@ -690,6 +690,10 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk") must_be_true(strcmp(git_commit_message(commit), COMMIT_MESSAGE) == 0); +#ifndef GIT_WIN32 + must_be_true((loose_object_mode(REPOSITORY_FOLDER, (git_object *)commit) & 0777) == GIT_OBJECT_FILE_MODE); +#endif + must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit)); git_commit_close(commit); diff --git a/tests/t06-index.c b/tests/t06-index.c index dde98abaf..44562d004 100644 --- a/tests/t06-index.c +++ b/tests/t06-index.c @@ -179,7 +179,7 @@ BEGIN_TEST(add0, "add a new file to the index") must_pass(git_futils_mkpath2file(TEMP_REPO_FOLDER "myrepo/test.txt", 0777)); must_pass(git_filebuf_open(&file, TEMP_REPO_FOLDER "myrepo/test.txt", 0)); must_pass(git_filebuf_write(&file, "hey there\n", 10)); - must_pass(git_filebuf_commit(&file)); + must_pass(git_filebuf_commit(&file, 0666)); /* Store the expected hash of the file/blob * This has been generated by executing the following diff --git a/tests/t08-tag.c b/tests/t08-tag.c index 216fb9dfc..85ef9225e 100644 --- a/tests/t08-tag.c +++ b/tests/t08-tag.c @@ -189,6 +189,9 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again") must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/the-tag")); must_be_true(git_oid_cmp(git_reference_oid(ref_tag), &tag_id) == 0); must_pass(git_reference_delete(ref_tag)); +#ifndef GIT_WIN32 + must_be_true((loose_object_mode(REPOSITORY_FOLDER, (git_object *)tag) & 0777) == GIT_OBJECT_FILE_MODE); +#endif must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)tag)); diff --git a/tests/t09-tree.c b/tests/t09-tree.c index 1f2fe3f02..2341a1ca4 100644 --- a/tests/t09-tree.c +++ b/tests/t09-tree.c @@ -202,6 +202,7 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory") must_be_true(2 == git_tree_entrycount(tree)); #ifndef GIT_WIN32 must_be_true((loose_object_dir_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_DIR_MODE); + must_be_true((loose_object_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_FILE_MODE); #endif git_tree_close(tree); diff --git a/tests/t12-repo.c b/tests/t12-repo.c index c07150c9c..6197cdd00 100644 --- a/tests/t12-repo.c +++ b/tests/t12-repo.c @@ -351,7 +351,7 @@ static int write_file(const char *path, const char *content) return error; } - file = git_futils_creat_withpath(path, 0777, 0644); + file = git_futils_creat_withpath(path, 0777, 0666); if (file < GIT_SUCCESS) return file; diff --git a/tests/t15-config.c b/tests/t15-config.c index c4cb590f5..a97f82067 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -319,7 +319,7 @@ BEGIN_TEST(config16, "add a variable in a new section") /* As the section wasn't removed, owerwrite the file */ must_pass(git_filebuf_open(&buf, CONFIG_BASE "/config10", 0)); must_pass(git_filebuf_write(&buf, "[empty]\n", strlen("[empty]\n"))); - must_pass(git_filebuf_commit(&buf)); + must_pass(git_filebuf_commit(&buf, 0666)); END_TEST BEGIN_TEST(config17, "prefixes aren't broken") diff --git a/tests/t18-status.c b/tests/t18-status.c index bd205a438..d836fb9a9 100644 --- a/tests/t18-status.c +++ b/tests/t18-status.c @@ -37,7 +37,7 @@ static int file_create(const char *filename, const char *content) { int fd; - fd = p_creat(filename, 0644); + fd = p_creat(filename, 0666); if (fd == 0) return GIT_ERROR; if (p_write(fd, content, strlen(content)) != 0) @@ -400,7 +400,7 @@ BEGIN_TEST(singlestatus3, "test retrieving status for a new file in an empty rep must_pass(remove_placeholders(TEST_STD_REPO_FOLDER, "dummy-marker.txt")); git_path_join(file_path, TEMP_REPO_FOLDER, filename); - fd = p_creat(file_path, 0644); + fd = p_creat(file_path, 0666); must_pass(fd); must_pass(p_write(fd, "new_file\n", 9)); must_pass(p_close(fd)); diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 7074e4822..7bba2e1d2 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -110,6 +110,18 @@ void locate_loose_object(const char *repository_folder, git_object *object, char *out_folder = top_folder; } +int loose_object_mode(const char *repository_folder, git_object *object) +{ + char *object_path; + struct stat st; + + locate_loose_object(repository_folder, object, &object_path, NULL); + assert(p_stat(object_path, &st) == 0); + free(object_path); + + return st.st_mode; +} + int loose_object_dir_mode(const char *repository_folder, git_object *object) { char *object_path; @@ -175,7 +187,7 @@ int copy_file(const char *src, const char *dst) if (git_futils_readbuffer(&source_buf, src) < GIT_SUCCESS) return GIT_ENOTFOUND; - dst_fd = git_futils_creat_withpath(dst, 0777, 0644); + dst_fd = git_futils_creat_withpath(dst, 0777, 0666); if (dst_fd < 0) goto cleanup; diff --git a/tests/test_helpers.h b/tests/test_helpers.h index 2e5194d7c..16a3a2ced 100644 --- a/tests/test_helpers.h +++ b/tests/test_helpers.h @@ -65,6 +65,7 @@ extern int cmp_objects(git_rawobj *o, object_data *d); extern void locate_loose_object(const char *odb_dir, git_object *object, char **out, char **out_folder); +extern int loose_object_mode(const char *odb_dir, git_object *object); extern int loose_object_dir_mode(const char *odb_dir, git_object *object); extern int remove_loose_object(const char *odb_dir, git_object *object); -- cgit v1.2.1 From 3286c408eccb18c525ca123383f3ebf5097441bc Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 28 Oct 2011 14:51:13 -0700 Subject: global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers. --- tests/t00-core.c | 8 ++++---- tests/t01-rawobj.c | 4 ++-- tests/t04-commit.c | 6 +++--- tests/t07-hashtable.c | 6 +++--- tests/test_helpers.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/t00-core.c b/tests/t00-core.c index 703504bf8..f93444d57 100644 --- a/tests/t00-core.c +++ b/tests/t00-core.c @@ -99,8 +99,8 @@ BEGIN_TEST(vector2, "remove duplicates") must_be_true(x.length == 2); git_vector_free(&x); - free(ptrs[0]); - free(ptrs[1]); + git__free(ptrs[0]); + git__free(ptrs[1]); END_TEST @@ -112,7 +112,7 @@ BEGIN_TEST(path0, "get the dirname of a path") must_be_true(strcmp(dir, B) == 0); \ must_be_true((dir2 = git_path_dirname(A)) != NULL); \ must_be_true(strcmp(dir2, B) == 0); \ - free(dir2); \ + git__free(dir2); \ } DIRNAME_TEST(NULL, "."); @@ -141,7 +141,7 @@ BEGIN_TEST(path1, "get the base name of a path") must_be_true(strcmp(base, B) == 0); \ must_be_true((base2 = git_path_basename(A)) != NULL); \ must_be_true(strcmp(base2, B) == 0); \ - free(base2); \ + git__free(base2); \ } BASENAME_TEST(NULL, "."); diff --git a/tests/t01-rawobj.c b/tests/t01-rawobj.c index 255208532..8b05f3394 100644 --- a/tests/t01-rawobj.c +++ b/tests/t01-rawobj.c @@ -217,7 +217,7 @@ BEGIN_TEST(oid12, "compare oids (allocate + format)") out = git_oid_allocfmt(&in); must_be_true(out); must_be_true(strcmp(exp, out) == 0); - free(out); + git__free(out); END_TEST BEGIN_TEST(oid13, "compare oids (path format)") @@ -390,7 +390,7 @@ BEGIN_TEST(oid17, "stress test for the git_oid_shorten object") /* cleanup */ for (i = 0; i < MAX_OIDS; ++i) - free(oids[i]); + git__free(oids[i]); git_oid_shorten_free(os); diff --git a/tests/t04-commit.c b/tests/t04-commit.c index 3fb4d370c..303b8f7cb 100644 --- a/tests/t04-commit.c +++ b/tests/t04-commit.c @@ -162,7 +162,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") must_be_true(strcmp(_email, person.email) == 0);\ must_be_true(_time == person.when.time);\ must_be_true(_offset == person.when.offset);\ - free(person.name); free(person.email);\ + git__free(person.name); git__free(person.email);\ } #define TEST_SIGNATURE_FAIL(_string, _header) { \ @@ -170,7 +170,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") size_t len = strlen(_string);\ git_signature person = {NULL, NULL, {0, 0}}; \ must_fail(git_signature__parse(&person, &ptr, ptr + len, _header, '\n'));\ - free(person.name); free(person.email);\ + git__free(person.name); git__free(person.email);\ } TEST_SIGNATURE_PASS( @@ -759,7 +759,7 @@ BEGIN_TEST(root0, "create a root commit") must_pass(git_reference_set_target(head, head_old)); must_pass(git_reference_delete(branch)); must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit)); - free(head_old); + git__free(head_old); git_commit_close(commit); git_repository_free(repo); END_TEST diff --git a/tests/t07-hashtable.c b/tests/t07-hashtable.c index c0e852259..41d52af19 100644 --- a/tests/t07-hashtable.c +++ b/tests/t07-hashtable.c @@ -103,7 +103,7 @@ BEGIN_TEST(table1, "fill the hashtable with random entries") } git_hashtable_free(table); - free(objects); + git__free(objects); END_TEST @@ -145,7 +145,7 @@ BEGIN_TEST(table2, "make sure the table resizes automatically") } git_hashtable_free(table); - free(objects); + git__free(objects); END_TEST @@ -179,7 +179,7 @@ BEGIN_TEST(tableit0, "iterate through all the contents of the table") must_be_true(objects[i].visited); git_hashtable_free(table); - free(objects); + git__free(objects); END_TEST diff --git a/tests/test_helpers.c b/tests/test_helpers.c index cb95607e1..d1d7c9ebd 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -116,7 +116,7 @@ int remove_loose_object(const char *repository_folder, git_object *object) return -1; } - free(full_path); + git__free(full_path); return GIT_SUCCESS; } -- cgit v1.2.1 From a1bd78ea29caa05cf44e57f525d5b11fd9e2dc3a Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sat, 29 Oct 2011 21:29:31 +0200 Subject: status: Add a file in the test repository to cover the correct sorting of entries when the working folder is being read In this case, "subdir.txt" should be listed before the "subdir" directory. --- tests/resources/status/.gitted/COMMIT_EDITMSG | 2 +- tests/resources/status/.gitted/ORIG_HEAD | 2 +- tests/resources/status/.gitted/index | Bin 1080 -> 1160 bytes tests/resources/status/.gitted/logs/HEAD | 1 + tests/resources/status/.gitted/logs/refs/heads/master | 1 + .../objects/26/a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f | 2 ++ .../objects/37/fcb02ccc1a85d1941e7f106d52dc3702dcf0d0 | Bin 0 -> 331 bytes .../objects/e8/ee89e15bbe9b20137715232387b3de5b28972e | Bin 0 -> 38 bytes tests/resources/status/.gitted/refs/heads/master | 2 +- tests/resources/status/subdir.txt | 2 ++ 10 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/resources/status/.gitted/objects/26/a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f create mode 100644 tests/resources/status/.gitted/objects/37/fcb02ccc1a85d1941e7f106d52dc3702dcf0d0 create mode 100644 tests/resources/status/.gitted/objects/e8/ee89e15bbe9b20137715232387b3de5b28972e create mode 100644 tests/resources/status/subdir.txt (limited to 'tests') diff --git a/tests/resources/status/.gitted/COMMIT_EDITMSG b/tests/resources/status/.gitted/COMMIT_EDITMSG index ff887ba13..1a25cd4a6 100644 --- a/tests/resources/status/.gitted/COMMIT_EDITMSG +++ b/tests/resources/status/.gitted/COMMIT_EDITMSG @@ -1 +1 @@ -add subdir +Add a file which name should appear before the "subdir/" folder while being dealt with by the treewalker diff --git a/tests/resources/status/.gitted/ORIG_HEAD b/tests/resources/status/.gitted/ORIG_HEAD index c2805f422..b46871fd6 100644 --- a/tests/resources/status/.gitted/ORIG_HEAD +++ b/tests/resources/status/.gitted/ORIG_HEAD @@ -1 +1 @@ -0017bd4ab1ec30440b17bae1680cff124ab5f1f6 +735b6a258cd196a8f7c9428419b02c1dca93fd75 diff --git a/tests/resources/status/.gitted/index b/tests/resources/status/.gitted/index index 5c4b18841..d793791c9 100644 Binary files a/tests/resources/status/.gitted/index and b/tests/resources/status/.gitted/index differ diff --git a/tests/resources/status/.gitted/logs/HEAD b/tests/resources/status/.gitted/logs/HEAD index e876bd80b..7b95b3cf1 100644 --- a/tests/resources/status/.gitted/logs/HEAD +++ b/tests/resources/status/.gitted/logs/HEAD @@ -1,2 +1,3 @@ 0000000000000000000000000000000000000000 0017bd4ab1ec30440b17bae1680cff124ab5f1f6 Jason Penny 1308050070 -0400 commit (initial): initial 0017bd4ab1ec30440b17bae1680cff124ab5f1f6 735b6a258cd196a8f7c9428419b02c1dca93fd75 Jason Penny 1308954538 -0400 commit: add subdir +735b6a258cd196a8f7c9428419b02c1dca93fd75 26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f nulltoken 1319911544 +0200 commit: Add a file which name should appear before the "subdir/" folder while being dealt with by the treewalker diff --git a/tests/resources/status/.gitted/logs/refs/heads/master b/tests/resources/status/.gitted/logs/refs/heads/master index e876bd80b..7b95b3cf1 100644 --- a/tests/resources/status/.gitted/logs/refs/heads/master +++ b/tests/resources/status/.gitted/logs/refs/heads/master @@ -1,2 +1,3 @@ 0000000000000000000000000000000000000000 0017bd4ab1ec30440b17bae1680cff124ab5f1f6 Jason Penny 1308050070 -0400 commit (initial): initial 0017bd4ab1ec30440b17bae1680cff124ab5f1f6 735b6a258cd196a8f7c9428419b02c1dca93fd75 Jason Penny 1308954538 -0400 commit: add subdir +735b6a258cd196a8f7c9428419b02c1dca93fd75 26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f nulltoken 1319911544 +0200 commit: Add a file which name should appear before the "subdir/" folder while being dealt with by the treewalker diff --git a/tests/resources/status/.gitted/objects/26/a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f b/tests/resources/status/.gitted/objects/26/a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f new file mode 100644 index 000000000..f7dddc4ff --- /dev/null +++ b/tests/resources/status/.gitted/objects/26/a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f @@ -0,0 +1,2 @@ +xMn )V (̀BD޾LЍRȷވ@,9̜tNj6f`M6Z;h Zp ڙY,37/;42x&gϟۉIm|j \ No newline at end of file diff --git a/tests/resources/status/.gitted/objects/37/fcb02ccc1a85d1941e7f106d52dc3702dcf0d0 b/tests/resources/status/.gitted/objects/37/fcb02ccc1a85d1941e7f106d52dc3702dcf0d0 new file mode 100644 index 000000000..b75481b51 Binary files /dev/null and b/tests/resources/status/.gitted/objects/37/fcb02ccc1a85d1941e7f106d52dc3702dcf0d0 differ diff --git a/tests/resources/status/.gitted/objects/e8/ee89e15bbe9b20137715232387b3de5b28972e b/tests/resources/status/.gitted/objects/e8/ee89e15bbe9b20137715232387b3de5b28972e new file mode 100644 index 000000000..cfc2413d5 Binary files /dev/null and b/tests/resources/status/.gitted/objects/e8/ee89e15bbe9b20137715232387b3de5b28972e differ diff --git a/tests/resources/status/.gitted/refs/heads/master b/tests/resources/status/.gitted/refs/heads/master index b46871fd6..3e2e2a07a 100644 --- a/tests/resources/status/.gitted/refs/heads/master +++ b/tests/resources/status/.gitted/refs/heads/master @@ -1 +1 @@ -735b6a258cd196a8f7c9428419b02c1dca93fd75 +26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f diff --git a/tests/resources/status/subdir.txt b/tests/resources/status/subdir.txt new file mode 100644 index 000000000..e8ee89e15 --- /dev/null +++ b/tests/resources/status/subdir.txt @@ -0,0 +1,2 @@ +Is it a bird? +Is it a plane? -- cgit v1.2.1 From ec9079443c874fe1711acefb22b3fc606484c786 Mon Sep 17 00:00:00 2001 From: schu Date: Sun, 30 Oct 2011 13:48:00 +0100 Subject: test_helpers: do not rely on assert The functions loose_object_mode and loose_object_dir_mode call stat inside an assert statement which isn't evaluated when compiling in Release mode (NDEBUG) and leads to failing tests. Replace it. Signed-off-by: schu --- tests/test_helpers.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 47a0b1b11..31e38bf6a 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -116,7 +116,8 @@ int loose_object_mode(const char *repository_folder, git_object *object) struct stat st; locate_loose_object(repository_folder, object, &object_path, NULL); - assert(p_stat(object_path, &st) == 0); + if (p_stat(object_path, &st) < 0) + return 0; free(object_path); return st.st_mode; @@ -138,7 +139,8 @@ int loose_object_dir_mode(const char *repository_folder, git_object *object) } } - assert(p_stat(object_path, &st) == 0); + if (p_stat(object_path, &st) < 0) + return 0; free(object_path); return st.st_mode; -- cgit v1.2.1 From a46ec45746f965f2895098e058979225d92d66e5 Mon Sep 17 00:00:00 2001 From: schu Date: Wed, 10 Aug 2011 16:19:42 +0200 Subject: refs: split internal and external references Currently libgit2 shares pointers to its internal reference cache with the user. This leads to several problems like invalidation of reference pointers when reordering the cache or manipulation of the cache from user side. Give each user its own git_reference instead of leaking the internal representation (struct reference). Add the following new API functions: * git_reference_free * git_reference_is_packed Signed-off-by: schu --- tests/t10-refs.c | 72 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'tests') diff --git a/tests/t10-refs.c b/tests/t10-refs.c index 4cb31d5e7..cfedff0a5 100644 --- a/tests/t10-refs.c +++ b/tests/t10-refs.c @@ -42,8 +42,8 @@ BEGIN_TEST(readtag0, "lookup a loose tag reference") must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name)); - must_be_true(reference->type & GIT_REF_OID); - must_be_true((reference->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_type(reference) & GIT_REF_OID); + must_be_true(git_reference_is_packed(reference) == 0); must_be_true(strcmp(reference->name, loose_tag_ref_name) == 0); must_pass(git_object_lookup(&object, repo, git_reference_oid(reference), GIT_OBJ_ANY)); @@ -81,12 +81,12 @@ BEGIN_TEST(readsym0, "lookup a symbolic reference") must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&reference, repo, GIT_HEAD_FILE)); - must_be_true(reference->type & GIT_REF_SYMBOLIC); - must_be_true((reference->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_type(reference) & GIT_REF_SYMBOLIC); + must_be_true(git_reference_is_packed(reference) == 0); must_be_true(strcmp(reference->name, GIT_HEAD_FILE) == 0); must_pass(git_reference_resolve(&resolved_ref, reference)); - must_be_true(resolved_ref->type == GIT_REF_OID); + must_be_true(git_reference_type(resolved_ref) == GIT_REF_OID); must_pass(git_object_lookup(&object, repo, git_reference_oid(resolved_ref), GIT_OBJ_ANY)); must_be_true(object != NULL); @@ -108,12 +108,12 @@ BEGIN_TEST(readsym1, "lookup a nested symbolic reference") must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&reference, repo, head_tracker_sym_ref_name)); - must_be_true(reference->type & GIT_REF_SYMBOLIC); - must_be_true((reference->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_type(reference) & GIT_REF_SYMBOLIC); + must_be_true(git_reference_is_packed(reference) == 0); must_be_true(strcmp(reference->name, head_tracker_sym_ref_name) == 0); must_pass(git_reference_resolve(&resolved_ref, reference)); - must_be_true(resolved_ref->type == GIT_REF_OID); + must_be_true(git_reference_type(resolved_ref) == GIT_REF_OID); must_pass(git_object_lookup(&object, repo, git_reference_oid(resolved_ref), GIT_OBJ_ANY)); must_be_true(object != NULL); @@ -173,8 +173,8 @@ BEGIN_TEST(readpacked0, "lookup a packed reference") must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&reference, repo, packed_head_name)); - must_be_true(reference->type & GIT_REF_OID); - must_be_true((reference->type & GIT_REF_PACKED) != 0); + must_be_true(git_reference_type(reference) & GIT_REF_OID); + must_be_true(git_reference_is_packed(reference)); must_be_true(strcmp(reference->name, packed_head_name) == 0); must_pass(git_object_lookup(&object, repo, git_reference_oid(reference), GIT_OBJ_ANY)); @@ -192,8 +192,8 @@ BEGIN_TEST(readpacked1, "assure that a loose reference is looked up before a pac must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&reference, repo, packed_head_name)); must_pass(git_reference_lookup(&reference, repo, packed_test_head_name)); - must_be_true(reference->type & GIT_REF_OID); - must_be_true((reference->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_type(reference) & GIT_REF_OID); + must_be_true(git_reference_is_packed(reference) == 0); must_be_true(strcmp(reference->name, packed_test_head_name) == 0); git_repository_free(repo); @@ -219,13 +219,13 @@ BEGIN_TEST(create0, "create a new symbolic reference") /* Ensure the reference can be looked-up... */ must_pass(git_reference_lookup(&looked_up_ref, repo, new_head_tracker)); - must_be_true(looked_up_ref->type & GIT_REF_SYMBOLIC); - must_be_true((looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_type(looked_up_ref) & GIT_REF_SYMBOLIC); + must_be_true(git_reference_is_packed(looked_up_ref) == 0); must_be_true(strcmp(looked_up_ref->name, new_head_tracker) == 0); /* ...peeled.. */ must_pass(git_reference_resolve(&resolved_ref, looked_up_ref)); - must_be_true(resolved_ref->type == GIT_REF_OID); + must_be_true(git_reference_type(resolved_ref) == GIT_REF_OID); /* ...and that it points to the current master tip */ must_be_true(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0); @@ -283,8 +283,8 @@ BEGIN_TEST(create2, "create a new OID reference") /* Ensure the reference can be looked-up... */ must_pass(git_reference_lookup(&looked_up_ref, repo, new_head)); - must_be_true(looked_up_ref->type & GIT_REF_OID); - must_be_true((looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_type(looked_up_ref) & GIT_REF_OID); + must_be_true(git_reference_is_packed(looked_up_ref) == 0); must_be_true(strcmp(looked_up_ref->name, new_head) == 0); /* ...and that it points to the current master tip */ @@ -359,14 +359,14 @@ BEGIN_TEST(overwrite1, "Overwrite an existing object id reference") must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&ref, repo, ref_master_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); /* Create it */ must_pass(git_reference_create_oid(&ref, repo, ref_name, &id, 0)); must_pass(git_reference_lookup(&ref, repo, ref_test_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); /* Ensure we can't overwrite unless we force it */ @@ -388,7 +388,7 @@ BEGIN_TEST(overwrite2, "Overwrite an existing object id reference with a symboli must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&ref, repo, ref_master_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); must_pass(git_reference_create_oid(&ref, repo, ref_name, &id, 0)); @@ -411,7 +411,7 @@ BEGIN_TEST(overwrite3, "Overwrite an existing symbolic reference with an object must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&ref, repo, ref_master_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); /* Create the symbolic ref */ @@ -451,7 +451,7 @@ BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo") /* Ensure a known loose ref can be looked up */ must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name)); - must_be_true((reference->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(reference) == 0); must_be_true(strcmp(reference->name, loose_tag_ref_name) == 0); /* @@ -467,7 +467,7 @@ BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo") /* Ensure the known ref can still be looked up but is now packed */ must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name)); - must_be_true((reference->type & GIT_REF_PACKED) != 0); + must_be_true(git_reference_is_packed(reference)); must_be_true(strcmp(reference->name, loose_tag_ref_name) == 0); /* Ensure the known ref has been removed from the loose folder structure */ @@ -493,7 +493,7 @@ BEGIN_TEST(rename0, "rename a loose reference") must_pass(git_reference_lookup(&looked_up_ref, repo, loose_tag_ref_name)); /* ... which is indeed loose */ - must_be_true((looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(looked_up_ref) == 0); /* Now that the reference is renamed... */ must_pass(git_reference_rename(looked_up_ref, new_name, 0)); @@ -507,8 +507,8 @@ BEGIN_TEST(rename0, "rename a loose reference") must_be_true(!strcmp(another_looked_up_ref->name, new_name)); /* .. the ref is still loose... */ - must_be_true((another_looked_up_ref->type & GIT_REF_PACKED) == 0); - must_be_true((looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(another_looked_up_ref) == 0); + must_be_true(git_reference_is_packed(looked_up_ref) == 0); /* ...and the ref can be found in the file system */ git_path_join(temp_path, repo->path_repository, new_name); @@ -533,7 +533,7 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)") must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name)); /* .. and it's packed */ - must_be_true((looked_up_ref->type & GIT_REF_PACKED) != 0); + must_be_true(git_reference_is_packed(looked_up_ref) != 0); /* Now that the reference is renamed... */ must_pass(git_reference_rename(looked_up_ref, brand_new_name, 0)); @@ -547,8 +547,8 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)") must_be_true(!strcmp(another_looked_up_ref->name, brand_new_name)); /* .. the ref is no longer packed... */ - must_be_true((another_looked_up_ref->type & GIT_REF_PACKED) == 0); - must_be_true((looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(another_looked_up_ref) == 0); + must_be_true(git_reference_is_packed(looked_up_ref) == 0); /* ...and the ref now happily lives in the file system */ git_path_join(temp_path, repo->path_repository, brand_new_name); @@ -573,13 +573,13 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference must_pass(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name)); /* Ensure it's loose */ - must_be_true((another_looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(another_looked_up_ref) == 0); /* Lookup the reference to rename */ must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name)); /* Ensure it's packed */ - must_be_true((looked_up_ref->type & GIT_REF_PACKED) != 0); + must_be_true(git_reference_is_packed(looked_up_ref) != 0); /* Now that the reference is renamed... */ must_pass(git_reference_rename(looked_up_ref, brand_new_name, 0)); @@ -588,7 +588,7 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference must_pass(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name)); /* Ensure it's loose */ - must_be_true((another_looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(another_looked_up_ref) == 0); /* Ensure the other ref still exists on the file system */ must_pass(git_futils_exists(temp_path)); @@ -699,7 +699,7 @@ BEGIN_TEST(rename7, "can not overwrite name of existing reference") must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&ref, repo, ref_master_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); @@ -729,7 +729,7 @@ BEGIN_TEST(rename8, "can be renamed to a new name prefixed with the old name") must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&ref, repo, ref_master_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); @@ -758,7 +758,7 @@ BEGIN_TEST(rename9, "can move a reference to a upper reference hierarchy") must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&ref, repo, ref_master_name)); - must_be_true(ref->type & GIT_REF_OID); + must_be_true(git_reference_type(ref) & GIT_REF_OID); git_oid_cpy(&id, git_reference_oid(ref)); @@ -794,7 +794,7 @@ BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name)); /* Ensure it's the loose version that has been found */ - must_be_true((looked_up_ref->type & GIT_REF_PACKED) == 0); + must_be_true(git_reference_is_packed(looked_up_ref) == 0); /* Now that the reference is deleted... */ must_pass(git_reference_delete(looked_up_ref)); -- cgit v1.2.1 From 4fd89fa0392967fabb905c7f4001cd4834f11dbd Mon Sep 17 00:00:00 2001 From: schu Date: Tue, 26 Jul 2011 11:17:32 +0200 Subject: refs: add test case checking "immutable" references Signed-off-by: schu --- tests/t10-refs.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/t10-refs.c b/tests/t10-refs.c index cfedff0a5..298aaa07f 100644 --- a/tests/t10-refs.c +++ b/tests/t10-refs.c @@ -808,6 +808,37 @@ BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove close_temp_repo(repo); END_TEST +BEGIN_TEST(delete1, "can delete a just packed reference") + git_reference *ref; + git_repository *repo; + git_oid id; + const char *new_ref = "refs/heads/new_ref"; + + git_oid_fromstr(&id, current_master_tip); + + must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); + + /* Create and write the new object id reference */ + must_pass(git_reference_create_oid(&ref, repo, new_ref, &id, 0)); + + /* Lookup the reference */ + must_pass(git_reference_lookup(&ref, repo, new_ref)); + + /* Ensure it's a loose reference */ + must_be_true(git_reference_is_packed(ref) == 0); + + /* Pack all existing references */ + must_pass(git_reference_packall(repo)); + + /* Ensure it's a packed reference */ + must_be_true(git_reference_is_packed(ref) == 1); + + /* This should pass */ + must_pass(git_reference_delete(ref)); + + close_temp_repo(repo); +END_TEST + static int ensure_refname_normalized(int is_oid_ref, const char *input_refname, const char *expected_refname) { int error = GIT_SUCCESS; @@ -1172,6 +1203,7 @@ BEGIN_SUITE(refs) ADD_TEST(rename9); ADD_TEST(delete0); + ADD_TEST(delete1); ADD_TEST(list0); ADD_TEST(list1); -- cgit v1.2.1 From 75abd2b92452782a9e6cee6ed5041339bd00c5bf Mon Sep 17 00:00:00 2001 From: schu Date: Thu, 11 Aug 2011 19:38:13 +0200 Subject: Free all used references in the source tree Since references are not owned by the repository anymore we have to free them manually now. Signed-off-by: schu --- tests/t04-commit.c | 2 ++ tests/t08-tag.c | 6 ++++- tests/t10-refs.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/t12-repo.c | 4 +++ 4 files changed, 88 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/t04-commit.c b/tests/t04-commit.c index 681b3fbd1..d0bb1b583 100644 --- a/tests/t04-commit.c +++ b/tests/t04-commit.c @@ -766,6 +766,8 @@ BEGIN_TEST(root0, "create a root commit") git__free(head_old); git_commit_close(commit); git_repository_free(repo); + + git_reference_free(head); END_TEST BEGIN_SUITE(commit) diff --git a/tests/t08-tag.c b/tests/t08-tag.c index 85ef9225e..44efb584d 100644 --- a/tests/t08-tag.c +++ b/tests/t08-tag.c @@ -197,7 +197,6 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again") git_tag_close(tag); git_repository_free(repo); - END_TEST BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already existing tag") @@ -266,6 +265,7 @@ BEGIN_TEST(write3, "Replace an already existing tag") close_temp_repo(repo); + git_reference_free(ref_tag); END_TEST BEGIN_TEST(write4, "write a lightweight tag to the repository and read it again") @@ -296,6 +296,8 @@ BEGIN_TEST(write4, "write a lightweight tag to the repository and read it again" must_pass(git_tag_delete(repo, "light-tag")); git_repository_free(repo); + + git_reference_free(ref_tag); END_TEST BEGIN_TEST(write5, "Attempt to write a lightweight tag bearing the same name than an already existing tag") @@ -334,6 +336,8 @@ BEGIN_TEST(delete0, "Delete an already existing tag") must_fail(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b")); close_temp_repo(repo); + + git_reference_free(ref_tag); END_TEST BEGIN_SUITE(tag) diff --git a/tests/t10-refs.c b/tests/t10-refs.c index 298aaa07f..12632b02b 100644 --- a/tests/t10-refs.c +++ b/tests/t10-refs.c @@ -56,6 +56,8 @@ BEGIN_TEST(readtag0, "lookup a loose tag reference") git_object_close(object); git_repository_free(repo); + + git_reference_free(reference); END_TEST BEGIN_TEST(readtag1, "lookup a loose tag reference that doesn't exist") @@ -66,6 +68,8 @@ BEGIN_TEST(readtag1, "lookup a loose tag reference that doesn't exist") must_fail(git_reference_lookup(&reference, repo, non_existing_tag_ref_name)); git_repository_free(repo); + + git_reference_free(reference); END_TEST static const char *head_tracker_sym_ref_name = "head-tracker"; @@ -97,6 +101,9 @@ BEGIN_TEST(readsym0, "lookup a symbolic reference") git_object_close(object); git_repository_free(repo); + + git_reference_free(reference); + git_reference_free(resolved_ref); END_TEST BEGIN_TEST(readsym1, "lookup a nested symbolic reference") @@ -124,6 +131,9 @@ BEGIN_TEST(readsym1, "lookup a nested symbolic reference") git_object_close(object); git_repository_free(repo); + + git_reference_free(reference); + git_reference_free(resolved_ref); END_TEST BEGIN_TEST(readsym2, "lookup the HEAD and resolve the master branch") @@ -145,6 +155,10 @@ BEGIN_TEST(readsym2, "lookup the HEAD and resolve the master branch") must_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref))); git_repository_free(repo); + + git_reference_free(reference); + git_reference_free(resolved_ref); + git_reference_free(comp_base_ref); END_TEST BEGIN_TEST(readsym3, "lookup the master branch and then the HEAD") @@ -160,6 +174,10 @@ BEGIN_TEST(readsym3, "lookup the master branch and then the HEAD") must_pass(git_oid_cmp(git_reference_oid(master_ref), git_reference_oid(resolved_ref))); git_repository_free(repo); + + git_reference_free(reference); + git_reference_free(resolved_ref); + git_reference_free(master_ref); END_TEST static const char *packed_head_name = "refs/heads/packed"; @@ -183,6 +201,8 @@ BEGIN_TEST(readpacked0, "lookup a packed reference") git_object_close(object); git_repository_free(repo); + + git_reference_free(reference); END_TEST BEGIN_TEST(readpacked1, "assure that a loose reference is looked up before a packed reference") @@ -197,6 +217,8 @@ BEGIN_TEST(readpacked1, "assure that a loose reference is looked up before a pac must_be_true(strcmp(reference->name, packed_test_head_name) == 0); git_repository_free(repo); + + git_reference_free(reference); END_TEST BEGIN_TEST(create0, "create a new symbolic reference") @@ -240,6 +262,10 @@ BEGIN_TEST(create0, "create a new symbolic reference") must_be_true(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0); close_temp_repo(repo2); + + git_reference_free(new_reference); + git_reference_free(looked_up_ref); + git_reference_free(resolved_ref); END_TEST BEGIN_TEST(create1, "create a deep symbolic reference") @@ -261,6 +287,10 @@ BEGIN_TEST(create1, "create a deep symbolic reference") must_be_true(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0); close_temp_repo(repo); + + git_reference_free(new_reference); + git_reference_free(looked_up_ref); + git_reference_free(resolved_ref); END_TEST BEGIN_TEST(create2, "create a new OID reference") @@ -299,6 +329,9 @@ BEGIN_TEST(create2, "create a new OID reference") must_be_true(git_oid_cmp(&id, git_reference_oid(looked_up_ref)) == 0); close_temp_repo(repo2); + + git_reference_free(new_reference); + git_reference_free(looked_up_ref); END_TEST BEGIN_TEST(create3, "Can not create a new OID reference which targets at an unknown id") @@ -349,6 +382,9 @@ BEGIN_TEST(overwrite0, "Overwrite an existing symbolic reference") must_be_true(!strcmp(git_reference_target(ref), ref_master_name)); close_temp_repo(repo); + + git_reference_free(ref); + git_reference_free(branch_ref); END_TEST BEGIN_TEST(overwrite1, "Overwrite an existing object id reference") @@ -378,6 +414,8 @@ BEGIN_TEST(overwrite1, "Overwrite an existing object id reference") must_be_true(!git_oid_cmp(&id, git_reference_oid(ref))); close_temp_repo(repo); + + git_reference_free(ref); END_TEST BEGIN_TEST(overwrite2, "Overwrite an existing object id reference with a symbolic one") @@ -401,6 +439,8 @@ BEGIN_TEST(overwrite2, "Overwrite an existing object id reference with a symboli must_be_true(!strcmp(git_reference_target(ref), ref_master_name)); close_temp_repo(repo); + + git_reference_free(ref); END_TEST BEGIN_TEST(overwrite3, "Overwrite an existing symbolic reference with an object id one") @@ -426,6 +466,8 @@ BEGIN_TEST(overwrite3, "Overwrite an existing symbolic reference with an object must_be_true(!git_oid_cmp(git_reference_oid(ref), &id)); close_temp_repo(repo); + + git_reference_free(ref); END_TEST BEGIN_TEST(pack0, "create a packfile for an empty folder") @@ -475,6 +517,8 @@ BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo") must_pass(!git_futils_exists(temp_path)); close_temp_repo(repo); + + git_reference_free(reference); END_TEST BEGIN_TEST(rename0, "rename a loose reference") @@ -515,6 +559,9 @@ BEGIN_TEST(rename0, "rename a loose reference") must_pass(git_futils_exists(temp_path)); close_temp_repo(repo); + + git_reference_free(looked_up_ref); + git_reference_free(another_looked_up_ref); END_TEST BEGIN_TEST(rename1, "rename a packed reference (should make it loose)") @@ -555,6 +602,9 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)") must_pass(git_futils_exists(temp_path)); close_temp_repo(repo); + + git_reference_free(looked_up_ref); + git_reference_free(another_looked_up_ref); END_TEST BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference which happens to be in both loose and pack state") @@ -594,6 +644,9 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference must_pass(git_futils_exists(temp_path)); close_temp_repo(repo); + + git_reference_free(looked_up_ref); + git_reference_free(another_looked_up_ref); END_TEST BEGIN_TEST(rename3, "can not rename a reference with the name of an existing reference") @@ -613,6 +666,8 @@ BEGIN_TEST(rename3, "can not rename a reference with the name of an existing ref must_be_true(!strcmp(looked_up_ref->name, packed_head_name)); close_temp_repo(repo); + + git_reference_free(looked_up_ref); END_TEST BEGIN_TEST(rename4, "can not rename a reference with an invalid name") @@ -635,6 +690,8 @@ BEGIN_TEST(rename4, "can not rename a reference with an invalid name") must_be_true(!strcmp(looked_up_ref->name, packed_test_head_name)); close_temp_repo(repo); + + git_reference_free(looked_up_ref); END_TEST BEGIN_TEST(rename5, "can force-rename a packed reference with the name of an existing loose and packed reference") @@ -660,6 +717,8 @@ BEGIN_TEST(rename5, "can force-rename a packed reference with the name of an exi must_fail(git_reference_lookup(&looked_up_ref, repo, packed_head_name)); close_temp_repo(repo); + + git_reference_free(looked_up_ref); END_TEST BEGIN_TEST(rename6, "can force-rename a loose reference with the name of an existing loose reference") @@ -685,6 +744,8 @@ BEGIN_TEST(rename6, "can force-rename a loose reference with the name of an exis must_fail(git_reference_lookup(&looked_up_ref, repo, "refs/heads/br2")); close_temp_repo(repo); + + git_reference_free(looked_up_ref); END_TEST static const char *ref_one_name = "refs/heads/one/branch"; @@ -717,6 +778,11 @@ BEGIN_TEST(rename7, "can not overwrite name of existing reference") must_fail(git_reference_lookup(&ref_one_new, repo, ref_one_name_new)); close_temp_repo(repo); + + git_reference_free(ref); + git_reference_free(ref_one); + git_reference_free(ref_one_new); + git_reference_free(ref_two); END_TEST static const char *ref_two_name_new = "refs/heads/two/two"; @@ -748,6 +814,10 @@ BEGIN_TEST(rename8, "can be renamed to a new name prefixed with the old name") must_fail(git_reference_lookup(&looked_up_ref, repo, ref_two_name)); close_temp_repo(repo); + + git_reference_free(ref); + git_reference_free(ref_two); + git_reference_free(looked_up_ref); END_TEST BEGIN_TEST(rename9, "can move a reference to a upper reference hierarchy") @@ -806,6 +876,8 @@ BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove must_pass(!git_futils_exists(temp_path)); close_temp_repo(repo); + + git_reference_free(another_looked_up_ref); END_TEST BEGIN_TEST(delete1, "can delete a just packed reference") @@ -1132,6 +1204,9 @@ BEGIN_TEST(reflog0, "write a reflog for a given reference and ensure it can be r git_signature_free(committer); git_reflog_free(reflog); close_temp_repo(repo2); + + git_reference_free(ref); + git_reference_free(lookedup_ref); END_TEST BEGIN_TEST(reflog1, "avoid writing an obviously wrong reflog") @@ -1160,6 +1235,8 @@ BEGIN_TEST(reflog1, "avoid writing an obviously wrong reflog") git_signature_free(committer); close_temp_repo(repo); + + git_reference_free(ref); END_TEST BEGIN_SUITE(refs) diff --git a/tests/t12-repo.c b/tests/t12-repo.c index 6197cdd00..47dc852f3 100644 --- a/tests/t12-repo.c +++ b/tests/t12-repo.c @@ -286,6 +286,8 @@ BEGIN_TEST(detached0, "test if HEAD is detached") must_be_true(git_repository_head_detached(repo) == 0); git_repository_free(repo); + + git_reference_free(ref); END_TEST BEGIN_TEST(orphan0, "test if HEAD is orphan") @@ -305,6 +307,8 @@ BEGIN_TEST(orphan0, "test if HEAD is orphan") must_be_true(git_repository_head_orphan(repo) == 0); git_repository_free(repo); + + git_reference_free(ref); END_TEST #define DISCOVER_FOLDER TEMP_REPO_FOLDER "discover.git" -- cgit v1.2.1 From d4a0b124d00c70933d7c6ac9065c401cc2d70b2e Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Sun, 30 Oct 2011 21:58:33 -0700 Subject: refs: Partial rewrite for read-only refs This new version of the references code is significantly faster and hopefully easier to read. External API stays the same. A new method `git_reference_reload()` has been added to force updating a memory reference from disk. In-memory references are no longer updated automagically -- this was killing us. If a reference is deleted externally and the user doesn't reload the memory object, nothing critical happens: any functions using that reference should fail gracefully (e.g. deletion, renaming, and so on). All generated references from the API are read only and must be free'd by the user. There is no reference counting and no traces of generated references are kept in the library. There is no longer an internal representation for references. There is only one reference struct `git_reference`, and symbolic/oid targets are stored inside an union. Packfile references are stored using an optimized struct with flex array for reference names. This should significantly reduce the memory cost of loading the packfile from disk. --- tests/t10-refs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/t10-refs.c b/tests/t10-refs.c index 12632b02b..e5e722992 100644 --- a/tests/t10-refs.c +++ b/tests/t10-refs.c @@ -143,22 +143,23 @@ BEGIN_TEST(readsym2, "lookup the HEAD and resolve the master branch") must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_reference_lookup(&reference, repo, head_tracker_sym_ref_name)); - must_pass(git_reference_resolve(&resolved_ref, reference)); - comp_base_ref = resolved_ref; + must_pass(git_reference_resolve(&comp_base_ref, reference)); + git_reference_free(reference); must_pass(git_reference_lookup(&reference, repo, GIT_HEAD_FILE)); must_pass(git_reference_resolve(&resolved_ref, reference)); must_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref))); + git_reference_free(reference); + git_reference_free(resolved_ref); must_pass(git_reference_lookup(&reference, repo, current_head_target)); must_pass(git_reference_resolve(&resolved_ref, reference)); must_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref))); - - git_repository_free(repo); - git_reference_free(reference); git_reference_free(resolved_ref); + git_reference_free(comp_base_ref); + git_repository_free(repo); END_TEST BEGIN_TEST(readsym3, "lookup the master branch and then the HEAD") @@ -902,6 +903,9 @@ BEGIN_TEST(delete1, "can delete a just packed reference") /* Pack all existing references */ must_pass(git_reference_packall(repo)); + /* Reload the reference from disk */ + must_pass(git_reference_reload(ref)); + /* Ensure it's a packed reference */ must_be_true(git_reference_is_packed(ref) == 1); -- cgit v1.2.1 From 0c49ec2d3b5bfc32d69d189b7dc69cc26beb6a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 7 Nov 2011 19:34:24 +0100 Subject: Implement p_rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto --- tests/t18-status.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/t18-status.c b/tests/t18-status.c index d836fb9a9..73e328c2c 100644 --- a/tests/t18-status.c +++ b/tests/t18-status.c @@ -136,7 +136,7 @@ BEGIN_TEST(statuscb0, "test retrieving status for worktree of repository") struct status_entry_counts counts; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); + must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); memset(&counts, 0x0, sizeof(struct status_entry_counts)); @@ -223,7 +223,7 @@ BEGIN_TEST(statuscb2, "test retrieving status for a purged worktree of an valid struct status_entry_counts counts; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); + must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); /* Purging the working */ @@ -309,12 +309,12 @@ BEGIN_TEST(statuscb3, "test retrieving status for a worktree where a file and a struct status_entry_counts counts; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); + must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(TEMP_REPO_FOLDER "current_file", TEMP_REPO_FOLDER "swap")); - must_pass(git_futils_mv_atomic(TEMP_REPO_FOLDER "subdir", TEMP_REPO_FOLDER "current_file")); - must_pass(git_futils_mv_atomic(TEMP_REPO_FOLDER "swap", TEMP_REPO_FOLDER "subdir")); + must_pass(p_rename(TEMP_REPO_FOLDER "current_file", TEMP_REPO_FOLDER "swap")); + must_pass(p_rename(TEMP_REPO_FOLDER "subdir", TEMP_REPO_FOLDER "current_file")); + must_pass(p_rename(TEMP_REPO_FOLDER "swap", TEMP_REPO_FOLDER "subdir")); must_pass(file_create(TEMP_REPO_FOLDER ".HEADER", "dummy")); must_pass(file_create(TEMP_REPO_FOLDER "42-is-not-prime.sigh", "dummy")); @@ -341,7 +341,7 @@ BEGIN_TEST(singlestatus0, "test retrieving status for single file") int i; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); + must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); for (i = 0; i < ENTRY_COUNT0; ++i) { @@ -360,7 +360,7 @@ BEGIN_TEST(singlestatus1, "test retrieving status for nonexistent file") int error; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); + must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); // "nonexistent" does not exist in HEAD, Index or the worktree @@ -421,7 +421,7 @@ BEGIN_TEST(singlestatus4, "can't determine the status for a folder") int error; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); - must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); + must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); error = git_status_file(&status_flags, repo, "subdir"); -- cgit v1.2.1