summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-17 11:53:13 -0700
committerRussell Belfer <rb@github.com>2014-04-17 15:04:41 -0700
commit823c0e9cc142529912976f2e6abff3db456cb204 (patch)
treec07051b17bfcff2ef3edc24da05a8bb5ed6616e1 /src/fileops.c
parente6e8530aa6c8773dd523fd6fe07629b9481a8fee (diff)
downloadlibgit2-823c0e9cc142529912976f2e6abff3db456cb204.tar.gz
Fix broken logic for attr cache invalidation
The checks to see if files were out of date in the attibute cache was wrong because the cache-breaker data wasn't getting stored correctly. Additionally, when the cache-breaker triggered, the old file data was being leaked.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/fileops.c b/src/fileops.c
index d8d819151..13b8f6a39 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -132,6 +132,7 @@ int git_futils_readbuffer_fd(git_buf *buf, git_file fd, size_t len)
if (read_size != (ssize_t)len) {
giterr_set(GITERR_OS, "Failed to read descriptor");
+ git_buf_free(buf);
return -1;
}
@@ -829,3 +830,16 @@ void git_futils_filestamp_set(
else
memset(target, 0, sizeof(*target));
}
+
+
+void git_futils_filestamp_set_from_stat(
+ git_futils_filestamp *stamp, struct stat *st)
+{
+ if (st) {
+ stamp->mtime = (git_time_t)st->st_mtime;
+ stamp->size = (git_off_t)st->st_size;
+ stamp->ino = (unsigned int)st->st_ino;
+ } else {
+ memset(stamp, 0, sizeof(*stamp));
+ }
+}