diff options
| author | Edward Thomson <ethomson@github.com> | 2016-07-14 16:23:24 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2016-08-04 15:12:04 -0400 |
| commit | 8f09a98e1809dcdfd9d25b8268657bac4d942e6a (patch) | |
| tree | 25f4b977d9a9055569d95a5ba5b038dfbfb01d6a /src/fileops.c | |
| parent | d2794b0e37e98206b991ba4c8639ddf53c03bdb9 (diff) | |
| download | libgit2-8f09a98e1809dcdfd9d25b8268657bac4d942e6a.tar.gz | |
odb: freshen existing objects when writing
When writing an object, we calculate its OID and see if it exists in the
object database. If it does, we need to freshen the file that contains
it.
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/fileops.c b/src/fileops.c index 22868b489..ce64934ea 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -837,6 +837,22 @@ int git_futils_cp(const char *from, const char *to, mode_t filemode) return cp_by_fd(ifd, ofd, true); } +int git_futils_touch(const char *path) +{ + struct p_timeval times[2]; + time_t now = time(NULL); + int ret; + + times[0].tv_sec = now; + times[0].tv_usec = 0; + times[1].tv_sec = now; + times[1].tv_usec = 0; + + ret = p_utimes(path, times); + + return (ret < 0) ? git_path_set_error(errno, path, "touch") : 0; +} + static int cp_link(const char *from, const char *to, size_t link_size) { int error = 0; |
