about summary refs log tree commit diff stats
path: root/ui-repolist.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-repolist.c')
-rw-r--r--ui-repolist.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 76fe71a..47ca997 100644 --- a/ui-repolist.c +++ b/ui-repolist.c
@@ -33,7 +33,7 @@ static time_t read_agefile(char *path)
33 33
34static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) 34static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
35{ 35{
36 char *path; 36 struct strbuf path = STRBUF_INIT;
37 struct stat s; 37 struct stat s;
38 struct cgit_repo *r = (struct cgit_repo *)repo; 38 struct cgit_repo *r = (struct cgit_repo *)repo;
39 39
@@ -41,32 +41,36 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
41 *mtime = repo->mtime; 41 *mtime = repo->mtime;
42 return 1; 42 return 1;
43 } 43 }
44 path = fmt("%s/%s", repo->path, ctx.cfg.agefile); 44 strbuf_addf(&path, "%s/%s", repo->path, ctx.cfg.agefile);
45 if (stat(path, &s) == 0) { 45 if (stat(path.buf, &s) == 0) {
46 *mtime = read_agefile(path); 46 *mtime = read_agefile(path.buf);
47 if (*mtime) { 47 if (*mtime) {
48 r->mtime = *mtime; 48 r->mtime = *mtime;
49 return 1; 49 goto end;
50 } 50 }
51 } 51 }
52 52
53 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch ? 53 strbuf_reset(&path);
54 repo->defbranch : "master"); 54 strbuf_addf(&path, "%s/refs/heads/%s", repo->path,
55 if (stat(path, &s) == 0) { 55 repo->defbranch ? repo->defbranch : "master");
56 if (stat(path.buf, &s) == 0) {
56 *mtime = s.st_mtime; 57 *mtime = s.st_mtime;
57 r->mtime = *mtime; 58 r->mtime = *mtime;
58 return 1; 59 goto end;
59 } 60 }
60 61
61 path = fmt("%s/%s", repo->path, "packed-refs"); 62 strbuf_reset(&path);
62 if (stat(path, &s) == 0) { 63 strbuf_addf(&path, "%s/%s", repo->path, "packed-refs");
64 if (stat(path.buf, &s) == 0) {
63 *mtime = s.st_mtime; 65 *mtime = s.st_mtime;
64 r->mtime = *mtime; 66 r->mtime = *mtime;
65 return 1; 67 goto end;
66 } 68 }
67 69
68 *mtime = 0; 70 *mtime = 0;
69 r->mtime = *mtime; 71 r->mtime = *mtime;
72end:
73 strbuf_release(&path);
70 return (r->mtime != 0); 74 return (r->mtime != 0);
71} 75}
72 76