summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-07-10 21:26:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-07-10 21:26:15 (GMT)
commit1f9e0a53489aaca7859722e037a47e93858cbc42 (patch)
tree50327b2feabe7dc70fbd136ff5392a47371c37ab /sha1_file.c
parenta745a58adeb57107ed884bcc07c915409b9877cb (diff)
parent3096b2ecdb91c27cb9e64b692c480deed6c7e77e (diff)
downloadgit-1f9e0a53489aaca7859722e037a47e93858cbc42.zip
git-1f9e0a53489aaca7859722e037a47e93858cbc42.tar.gz
git-1f9e0a53489aaca7859722e037a47e93858cbc42.tar.bz2
Merge branch 'jk/fix-refresh-utime'
Fix a small bug in our use of umask() return value. * jk/fix-refresh-utime: check_and_freshen_file: fix reversed success-check
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index c0205a0..1cee438 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -443,6 +443,7 @@ void prepare_alt_odb(void)
read_info_alternates(get_object_directory(), 0);
}
+/* Returns 1 if we have successfully freshened the file, 0 otherwise. */
static int freshen_file(const char *fn)
{
struct utimbuf t;
@@ -450,11 +451,18 @@ static int freshen_file(const char *fn)
return !utime(fn, &t);
}
+/*
+ * All of the check_and_freshen functions return 1 if the file exists and was
+ * freshened (if freshening was requested), 0 otherwise. If they return
+ * 0, you should not assume that it is safe to skip a write of the object (it
+ * either does not exist on disk, or has a stale mtime and may be subject to
+ * pruning).
+ */
static int check_and_freshen_file(const char *fn, int freshen)
{
if (access(fn, F_OK))
return 0;
- if (freshen && freshen_file(fn))
+ if (freshen && !freshen_file(fn))
return 0;
return 1;
}