- path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
- if (stat(path, &s) == 0) {
- *mtime = read_agefile(path);
+ strbuf_addf(&path, "%s/%s", repo->path, ctx.cfg.agefile);
+ if (stat(path.buf, &s) == 0) {
+ *mtime = read_agefile(path.buf);
+ if (*mtime) {
+ r->mtime = *mtime;
+ goto end;
+ }
+ }
+
+ strbuf_reset(&path);
+ strbuf_addf(&path, "%s/refs/heads/%s", repo->path,
+ repo->defbranch ? repo->defbranch : "master");
+ if (stat(path.buf, &s) == 0) {
+ *mtime = s.st_mtime;