diff options
| author | Vicent Martà <tanoku@gmail.com> | 2012-05-02 15:59:02 -0700 |
|---|---|---|
| committer | Vicent Martà <tanoku@gmail.com> | 2012-05-02 15:59:02 -0700 |
| commit | 40879facad0337d954d4904e212af3b36cdb9465 (patch) | |
| tree | aea730551948c67bb1fb88098cf8a67d3ed3211d /tests-clar/clar_helpers.c | |
| parent | 2218fd57a50ceb851cb131939bf0747e072e40f6 (diff) | |
| parent | 3fd99be98a91416dae77d65fe593965a0723fa8c (diff) | |
| download | libgit2-40879facad0337d954d4904e212af3b36cdb9465.tar.gz | |
Merge branch 'new-error-handling' into development
Conflicts:
.travis.yml
include/git2/diff.h
src/config_file.c
src/diff.c
src/diff_output.c
src/mwindow.c
src/path.c
tests-clar/clar_helpers.c
tests-clar/object/tree/frompath.c
tests/t00-core.c
tests/t03-objwrite.c
tests/t08-tag.c
tests/t10-refs.c
tests/t12-repo.c
tests/t18-status.c
tests/test_helpers.c
tests/test_main.c
Diffstat (limited to 'tests-clar/clar_helpers.c')
| -rw-r--r-- | tests-clar/clar_helpers.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests-clar/clar_helpers.c b/tests-clar/clar_helpers.c index e90bb8737..4d9ee4f77 100644 --- a/tests-clar/clar_helpers.c +++ b/tests-clar/clar_helpers.c @@ -28,9 +28,9 @@ void cl_git_mkfile(const char *filename, const char *content) cl_must_pass(p_close(fd)); } -void cl_git_append2file(const char *filename, const char *new_content) +void cl_git_write2file(const char *filename, const char *new_content, int flags) { - int fd = p_creat(filename, 0644); + int fd = p_open(filename, flags); cl_assert(fd != 0); if (!new_content) new_content = "\n"; @@ -38,6 +38,16 @@ void cl_git_append2file(const char *filename, const char *new_content) cl_must_pass(p_close(fd)); } +void cl_git_append2file(const char *filename, const char *new_content) +{ + cl_git_write2file(filename, new_content, O_WRONLY | O_APPEND | O_CREAT); +} + +void cl_git_rewritefile(const char *filename, const char *new_content) +{ + cl_git_write2file(filename, new_content, O_WRONLY | O_CREAT | O_TRUNC); +} + static const char *_cl_sandbox = NULL; static git_repository *_cl_repo = NULL; @@ -51,11 +61,12 @@ git_repository *cl_git_sandbox_init(const char *sandbox) p_chdir(sandbox); - /* Rename `sandbox/.gitted` to `sandbox/.git` which must be done since - * we cannot store a folder named `.git` inside the fixtures folder of - * our libgit2 repo. + /* If this is not a bare repo, then rename `sandbox/.gitted` to + * `sandbox/.git` which must be done since we cannot store a folder + * named `.git` inside the fixtures folder of our libgit2 repo. */ - cl_git_pass(p_rename(".gitted", ".git")); + if (p_access(".gitted", F_OK) == 0) + cl_git_pass(p_rename(".gitted", ".git")); /* If we have `gitattributes`, rename to `.gitattributes`. This may * be necessary if we don't want the attributes to be applied in the |
