Diffstat (limited to 'ui-repolist.c')
| -rw-r--r-- | ui-repolist.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 47ca997..76fe71a 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -33,7 +33,7 @@ static time_t read_agefile(char *path) static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) { - struct strbuf path = STRBUF_INIT; + char *path; struct stat s; struct cgit_repo *r = (struct cgit_repo *)repo; @@ -41,36 +41,32 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) *mtime = repo->mtime; return 1; } - strbuf_addf(&path, "%s/%s", repo->path, ctx.cfg.agefile); - if (stat(path.buf, &s) == 0) { - *mtime = read_agefile(path.buf); + path = fmt("%s/%s", repo->path, ctx.cfg.agefile); + if (stat(path, &s) == 0) { + *mtime = read_agefile(path); if (*mtime) { r->mtime = *mtime; - goto end; + return 1; } } - strbuf_reset(&path); - strbuf_addf(&path, "%s/refs/heads/%s", repo->path, - repo->defbranch ? repo->defbranch : "master"); - if (stat(path.buf, &s) == 0) { + path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch ? + repo->defbranch : "master"); + if (stat(path, &s) == 0) { *mtime = s.st_mtime; r->mtime = *mtime; - goto end; + return 1; } - strbuf_reset(&path); - strbuf_addf(&path, "%s/%s", repo->path, "packed-refs"); - if (stat(path.buf, &s) == 0) { + path = fmt("%s/%s", repo->path, "packed-refs"); + if (stat(path, &s) == 0) { *mtime = s.st_mtime; r->mtime = *mtime; - goto end; + return 1; } *mtime = 0; r->mtime = *mtime; -end: - strbuf_release(&path); return (r->mtime != 0); } |