summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-repolist.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index 2c98668..e138f59 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -1,55 +1,55 @@
1/* ui-repolist.c: functions for generating the repolist page 1/* ui-repolist.c: functions for generating the repolist page
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include "html.h" 10#include "html.h"
11#include "ui-shared.h" 11#include "ui-shared.h"
12 12
13time_t read_agefile(char *path) 13time_t read_agefile(char *path)
14{ 14{
15 time_t result; 15 time_t result;
16 size_t size; 16 size_t size;
17 char *buf; 17 char *buf;
18 static char buf2[64]; 18 static char buf2[64];
19 19
20 if (readfile(path, &buf, &size)) 20 if (readfile(path, &buf, &size))
21 return -1; 21 return -1;
22 22
23 if (parse_date(buf, buf2, sizeof(buf2))) 23 if (parse_date(buf, buf2, sizeof(buf2)) > 0)
24 result = strtoul(buf2, NULL, 10); 24 result = strtoul(buf2, NULL, 10);
25 else 25 else
26 result = 0; 26 result = 0;
27 free(buf); 27 free(buf);
28 return result; 28 return result;
29} 29}
30 30
31static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) 31static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
32{ 32{
33 char *path; 33 char *path;
34 struct stat s; 34 struct stat s;
35 struct cgit_repo *r = (struct cgit_repo *)repo; 35 struct cgit_repo *r = (struct cgit_repo *)repo;
36 36
37 if (repo->mtime != -1) { 37 if (repo->mtime != -1) {
38 *mtime = repo->mtime; 38 *mtime = repo->mtime;
39 return 1; 39 return 1;
40 } 40 }
41 path = fmt("%s/%s", repo->path, ctx.cfg.agefile); 41 path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
42 if (stat(path, &s) == 0) { 42 if (stat(path, &s) == 0) {
43 *mtime = read_agefile(path); 43 *mtime = read_agefile(path);
44 r->mtime = *mtime; 44 r->mtime = *mtime;
45 return 1; 45 return 1;
46 } 46 }
47 47
48 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); 48 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
49 if (stat(path, &s) == 0) 49 if (stat(path, &s) == 0)
50 *mtime = s.st_mtime; 50 *mtime = s.st_mtime;
51 else 51 else
52 *mtime = 0; 52 *mtime = 0;
53 53
54 r->mtime = *mtime; 54 r->mtime = *mtime;
55 return (r->mtime != 0); 55 return (r->mtime != 0);