From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Sat, 18 Feb 2017 17:05:00 +0000 Subject: [PATCH] ui-log: add option to show all refs In-Reply-To: <20170204040606.4745-1-bertrand.roussel@cor-net.org> References: <20170204040606.4745-1-bertrand.roussel@cor-net.org> Message-ID: <20170218170500.GB1577@john.keeping.me.uk> On Fri, Feb 03, 2017 at 08:06:06PM -0800, Bertrand Roussel wrote: > Add option 'show-all-refs' and 'repo.show-all-refs' to display references > that are not tags or branches. Missing Signed-off-by tag (see [0]). Other than that, I wonder why this doesn't touch ui-refs.c or ui-summary.c. If this is only about using all refs for decoration, then "show-all-refs" seems like a misleading name. [0] https://developercertificate.org/ > --- > cgit.c | 5 +++++ > cgit.css | 9 +++++++++ > cgit.h | 2 ++ > cgitrc.5.txt | 8 ++++++++ > shared.c | 1 + > ui-log.c | 7 +++++-- > 6 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/cgit.c b/cgit.c > index 1075753..3303ea4 100644 > --- a/cgit.c > +++ b/cgit.c > @@ -79,6 +79,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va > item->util = xstrdup(value); > } else if (!strcmp(name, "section")) > repo->section = xstrdup(value); > + else if (!strcmp(name, "show-all-refs")) > + repo->show_all_refs = atoi(value); > else if (!strcmp(name, "readme") && value != NULL) { > if (repo->readme.items == ctx.cfg.readme.items) > memset(&repo->readme, 0, sizeof(repo->readme)); > @@ -239,6 +241,8 @@ static void config_cb(const char *name, const char *value) > ctx.cfg.project_list, repo_config); > else > scan_tree(expand_macros(value), repo_config); > + else if (!strcmp(name, "show-all-refs")) > + ctx.cfg.show_all_refs = atoi(value); > else if (!strcmp(name, "scan-hidden-path")) > ctx.cfg.scan_hidden_path = atoi(value); > else if (!strcmp(name, "section-from-path")) > @@ -834,6 +838,7 @@ static void print_repo(FILE *f, struct cgit_repo *repo) > fprintf(f, "repo.enable-remote-branches=%d\n", repo->enable_remote_branches); > fprintf(f, "repo.enable-subject-links=%d\n", repo->enable_subject_links); > fprintf(f, "repo.enable-html-serving=%d\n", repo->enable_html_serving); > + fprintf(f, "repo.show-all-refs=%d\n", repo->show_all_refs); > if (repo->branch_sort == 1) > fprintf(f, "repo.branch-sort=age\n"); > if (repo->commit_sort) { > diff --git a/cgit.css b/cgit.css > index 1dc2c11..e881bcd 100644 > --- a/cgit.css > +++ b/cgit.css > @@ -635,6 +635,14 @@ div#cgit div.footer a:hover { > text-decoration: underline; > } > > +div#cgit a.unknown-deco { > + color: #000; > + margin: 0px 0.5em; > + padding: 0px 0.25em; > + background-color: #88d3ff; > + border: solid 1px #005177; > +} > + > div#cgit a.branch-deco { > color: #000; > margin: 0px 0.5em; > @@ -667,6 +675,7 @@ div#cgit a.deco { > border: solid 1px #770000; > } > > +div#cgit div.commit-subject a.unknown-deco, > div#cgit div.commit-subject a.branch-deco, > div#cgit div.commit-subject a.tag-deco, > div#cgit div.commit-subject a.remote-deco, > diff --git a/cgit.h b/cgit.h > index fbc6c6a..c2569a0 100644 > --- a/cgit.h > +++ b/cgit.h > @@ -96,6 +96,7 @@ struct cgit_repo { > int enable_remote_branches; > int enable_subject_links; > int enable_html_serving; > + int show_all_refs; > int max_stats; > int branch_sort; > int commit_sort; > @@ -252,6 +253,7 @@ struct cgit_config { > int remove_suffix; > int scan_hidden_path; > int section_from_path; > + int show_all_refs; > int snapshots; > int section_sort; > int summary_branches; > diff --git a/cgitrc.5.txt b/cgitrc.5.txt > index 9fcf445..27b38f2 100644 > --- a/cgitrc.5.txt > +++ b/cgitrc.5.txt > @@ -416,6 +416,10 @@ section-from-path:: > If negative, cgit will discard the specified number of path elements > above the repo directory. Default value: "0". > > +show-all-refs:: > + Show all types of refs in the log, such as refs/changes/. > + Default value: "0". > + > side-by-side-diffs:: > If set to "1" shows side-by-side diffs instead of unidiffs per > default. Default value: "0". > @@ -527,6 +531,10 @@ repo.enable-html-serving:: > A flag which can be used to override the global setting > `enable-html-serving`. Default value: none. > > +repo show-all-refs:: > + Show all types of refs in the log, such as refs/changes/. > + Default value: . > + > repo.hide:: > Flag which, when set to "1", hides the repository from the repository > index. The repository can still be accessed by providing a direct path. > diff --git a/shared.c b/shared.c > index c63f1e3..34a33d3 100644 > --- a/shared.c > +++ b/shared.c > @@ -63,6 +63,7 @@ struct cgit_repo *cgit_add_repo(const char *url) > ret->enable_remote_branches = ctx.cfg.enable_remote_branches; > ret->enable_subject_links = ctx.cfg.enable_subject_links; > ret->enable_html_serving = ctx.cfg.enable_html_serving; > + ret->show_all_refs = ctx.cfg.show_all_refs; > ret->max_stats = ctx.cfg.max_stats; > ret->branch_sort = ctx.cfg.branch_sort; > ret->commit_sort = ctx.cfg.commit_sort; > diff --git a/ui-log.c b/ui-log.c > index 3220fd9..7ab4a5f 100644 > --- a/ui-log.c > +++ b/ui-log.c > @@ -68,8 +68,11 @@ void show_commit_decorations(struct commit *commit) > strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1); > switch(deco->type) { > case DECORATION_NONE: > - /* If the git-core doesn't recognize it, > - * don't display anything. */ > + if (!ctx.repo->show_all_refs) > + break; > + cgit_log_link(buf, NULL, "unknown-deco", buf, NULL, > + ctx.qry.vpath, 0, NULL, NULL, > + ctx.qry.showmsg, 0); > break; > case DECORATION_REF_LOCAL: > cgit_log_link(buf, NULL, "branch-deco", buf, NULL, > -- > 2.11.0 > > _______________________________________________ > CGit mailing list > CGit at lists.zx2c4.com > https://lists.zx2c4.com/mailman/listinfo/cgit