Use git_open_noatime when accessing pack data
This utility function avoids an unnecessary update of the access time for a loose object file. Just as the atime isn't useful on a loose object, its not useful on the pack or the corresonding idx file. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Nov 1, 2010 at 15:54 UTC
4865d2b6622bd95fc07fea06916eeddf3e13e29b
1 file changed
+6
-4
sha1_file.c
+6
-4
@@ -35,6 +35,8 @@ static size_t sz_fmt(size_t s) { return s; }
35
36
const unsigned char null_sha1[20];
37
38
+static int git_open_noatime(const char *name);
39
+
40
int safe_create_leading_directories(char *path)
41
{
42
char *pos = path + offset_1st_component(path);
@@ -298,7 +300,7 @@ static void read_info_alternates(const char * relative_base, int depth)
300
int fd;
301
302
sprintf(path, "%s/%s", relative_base, alt_file_name);
301
- fd = open(path, O_RDONLY);
303
+ fd = git_open_noatime(path);
304
if (fd < 0)
305
return;
306
if (fstat(fd, &st) || (st.st_size == 0)) {
@@ -411,7 +413,7 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
413
struct pack_idx_header *hdr;
414
size_t idx_size;
415
uint32_t version, nr, i, *index;
414
- int fd = open(path, O_RDONLY);
416
+ int fd = git_open_noatime(path);
417
struct stat st;
418
419
if (fd < 0)
@@ -655,9 +657,9 @@ static int open_packed_git_1(struct packed_git *p)
657
if (!p->index_data && open_pack_index(p))
658
return error("packfile %s index unavailable", p->pack_name);
659
658
- p->pack_fd = open(p->pack_name, O_RDONLY);
660
+ p->pack_fd = git_open_noatime(p->pack_name);
661
while (p->pack_fd < 0 && errno == EMFILE && unuse_one_window(p, -1))
660
- p->pack_fd = open(p->pack_name, O_RDONLY);
662
+ p->pack_fd = git_open_noatime(p->pack_name);
663
if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
664
return -1;
665