Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-05-21 00:41:39 +0400
committerRussell Belfer <rb@github.com>2013-05-21 00:41:39 +0400
commit4742148d54334629495eeaf0382e6c9da8786f17 (patch)
tree9fe01ef4d5b558c028432d4648f4b03c6fb5946c /src/checkout.c
parent9be5be47fb1d9bc08e25b30c05dbf48739710062 (diff)
Add more diff rename detection tests
This adds a bunch more rename detection tests including checks vs the working directory, the new exact match options, some more whitespace variants, etc. This also adds a git_futils_writebuffer helper function and uses it in checkout. This is mainly added because I wanted an easy way to write out a git_buf to disk inside my test code.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 5820f626a..c28fcdee0 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -676,33 +676,26 @@ static int buffer_to_file(
int file_open_flags,
mode_t file_mode)
{
- int fd, error;
+ int error;
if ((error = git_futils_mkpath2file(path, dir_mode)) < 0)
return error;
- if ((fd = p_open(path, file_open_flags, file_mode)) < 0) {
- giterr_set(GITERR_OS, "Could not open '%s' for writing", path);
- return fd;
- }
-
- if ((error = p_write(fd, git_buf_cstr(buffer), git_buf_len(buffer))) < 0) {
- giterr_set(GITERR_OS, "Could not write to '%s'", path);
- (void)p_close(fd);
- } else {
- if ((error = p_close(fd)) < 0)
- giterr_set(GITERR_OS, "Error while closing '%s'", path);
+ if ((error = git_futils_writebuffer(
+ buffer, path, file_open_flags, file_mode)) < 0)
+ return error;
- if ((error = p_stat(path, st)) < 0)
- giterr_set(GITERR_OS, "Error while statting '%s'", path);
+ if (st != NULL && (error = p_stat(path, st)) < 0) {
+ giterr_set(GITERR_OS, "Error while statting '%s'", path);
+ return error;
}
- if (!error &&
- (file_mode & 0100) != 0 &&
- (error = p_chmod(path, file_mode)) < 0)
+ if ((file_mode & 0100) != 0 && (error = p_chmod(path, file_mode)) < 0) {
giterr_set(GITERR_OS, "Failed to set permissions on '%s'", path);
+ return error;
+ }
- return error;
+ return 0;
}
static int blob_content_to_file(