From mboxrd@z Thu Jan 1 00:00:00 1970 From: mailings at hupie.com (Ferry Huberts) Date: Thu, 22 Aug 2013 21:09:32 +0200 Subject: [PATCH] Display the most recent modtime for the repolist In-Reply-To: <1377198333-26798-1-git-send-email-fparent@baylibre.com> References: <1377198333-26798-1-git-send-email-fparent@baylibre.com> Message-ID: <521661EC.5030503@hupie.com> This should be done with the agefile. This has come up before. NAK On 22/08/13 21:05, Fabien Parent wrote: > Instead of using the modtime of the master branch cgit now uses the modtime > of the lastest ref updated. > --- > ui-repolist.c | 32 +++++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/ui-repolist.c b/ui-repolist.c > index 2ab6e9e..dcd74dc 100644 > --- a/ui-repolist.c > +++ b/ui-repolist.c > @@ -13,6 +13,11 @@ > #include "ui-shared.h" > #include > > +struct ref_mod_time { > + struct cgit_repo *repo; > + time_t mod_time; > +}; > + > static time_t read_agefile(char *path) > { > time_t result; > @@ -74,11 +79,32 @@ end: > return (r->mtime != 0); > } > > +static int get_ref_mod_time(const char *refname, const unsigned char *sha1, > + int flags, void *cb_data) > +{ > + struct ref_mod_time *rmt = (struct ref_mod_time*) cb_data; > + char *defbranch_old; > + > + defbranch_old = rmt->repo->defbranch; > + rmt->repo->defbranch = (char*) refname; > + get_repo_modtime(rmt->repo, &rmt->mod_time); > + rmt->repo->defbranch = defbranch_old; > + return 0; > +} > + > static void print_modtime(struct cgit_repo *repo) > { > - time_t t; > - if (get_repo_modtime(repo, &t)) > - cgit_print_age(t, -1, NULL); > + struct ref_mod_time rmt = { .repo = repo }; > + struct ref_mod_time last_mod_ref = {0}; > + > + /* Get the time of the most recent update to the repo */ > + setenv("GIT_DIR", repo->path, 1); > + for_each_branch_ref(get_ref_mod_time, &rmt); > + if (rmt.mod_time > last_mod_ref.mod_time) > + last_mod_ref = rmt; > + > + if (last_mod_ref.mod_time) > + cgit_print_age(last_mod_ref.mod_time, -1, NULL); > } > > static int is_match(struct cgit_repo *repo) > -- Ferry Huberts