From nilix at nilfm.cc Sat Jan 8 22:28:00 2022 From: nilix at nilfm.cc (Derek Stevens) Date: Sat, 8 Jan 2022 15:28:00 -0700 Subject: patches: main as default branch, go gettable Message-ID: <20220108222800.gesev62brvbbd3wi@ksatrya.siroonian.local> Hello CGit folk! I use cgit for my own git server and have made some minor modifications that might be of interest. The first is the trivial change to assume main as the default branch name, as this is the new standard in git. The second and more interesting is to add a attribute to make a repository go-gettable. Both patches are attached; Happy new year and happy hacking! Cheers, Derek -------------- next part -------------- diff --git a/ui-shared.c b/ui-shared.c index acd8ab5..49a9407 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -785,6 +785,10 @@ void cgit_print_docstart(void) html_txt(ctx.page.title); html("\n"); htmlf("\n", cgit_version); + if (ctx.repo){ + htmlf("\n", + host, cgit_rooturl(), ctx.repo->url, host, cgit_rooturl(), ctx.repo->url); + } if (ctx.cfg.robots && *ctx.cfg.robots) htmlf("\n", ctx.cfg.robots); html(" Signed-off-by: Derek Stevens --- ui-shared.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui-shared.c b/ui-shared.c index acd8ab5..0f57af6 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -785,6 +785,9 @@ void cgit_print_docstart(void) html_txt(ctx.page.title); html("\n"); htmlf("\n", cgit_version); + if (ctx.repo) + htmlf("\n", + host, cgit_rooturl(), ctx.repo->url, host, cgit_rooturl(), ctx.repo->url); if (ctx.cfg.robots && *ctx.cfg.robots) htmlf("\n", ctx.cfg.robots); html("sign-off to the commit log as well. > >https://git-scm.com/docs/git-send-email > > >As for the default branch change, I suspect people may want this feature >configurable based on their configuration. I'm thinking either derived from >your git config file or granularly via an override in the repo-list >configuration file. Ideally, obtain the default branch name from config of >each repo. > > >Thanks, > >On Sat, Jan 8, 2022 at 5:28 PM Derek Stevens wrote: > >> Hello CGit folk! >> >> I use cgit for my own git server and have made some minor modifications >> that might be of interest. >> >> The first is the trivial change to assume main as the default branch name, >> as this is the new standard in git. >> >> The second and more interesting is to add a attribute to make a >> repository go-gettable. >> >> Both patches are attached; Happy new year and happy hacking! >> >> Cheers, >> Derek >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From lists at necoro.eu Sun Jan 9 00:55:25 2022 From: lists at necoro.eu (=?UTF-8?Q?Ren=c3=a9_Neumann?=) Date: Sun, 9 Jan 2022 01:55:25 +0100 Subject: [PATCH] use main as fallback branch instead of master In-Reply-To: <20220108235637.23431-1-nilix@nilfm.cc> References: <20220108235637.23431-1-nilix@nilfm.cc> Message-ID: <89ea4cb8-8cd9-6751-92bd-dd96c3343016@necoro.eu> Am 09.01.22 um 00:56 schrieb Derek Stevens: > Signed-off-by: Derek Stevens > --- > ui-repolist.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ui-repolist.c b/ui-repolist.c > index 529a203..c162290 100644 > --- a/ui-repolist.c > +++ b/ui-repolist.c > @@ -53,7 +53,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) > > strbuf_reset(&path); > strbuf_addf(&path, "%s/refs/heads/%s", repo->path, > - repo->defbranch ? repo->defbranch : "master"); > + repo->defbranch ? repo->defbranch : "main"); > if (stat(path.buf, &s) == 0) { > *mtime = s.st_mtime; > r->mtime = *mtime; 1. This change itself seems rather meaningless. There is at least one other occurrence in cgit.c#guess_defbranch(), which must be in sync. 2. Also change the man file. - Ren? From nilix at nilfm.cc Sun Jan 9 01:45:41 2022 From: nilix at nilfm.cc (Derek Stevens) Date: Sat, 8 Jan 2022 18:45:41 -0700 Subject: [PATCH] use main as fallback branch instead of master In-Reply-To: <89ea4cb8-8cd9-6751-92bd-dd96c3343016@necoro.eu> References: <20220108235637.23431-1-nilix@nilfm.cc> <89ea4cb8-8cd9-6751-92bd-dd96c3343016@necoro.eu> Message-ID: <20220109014541.ymzegmqqsp3zmfrd@ksatrya.siroonian.local> Ah yes, point taken; My apologies for not being thorough! I am submitting a more complete one momentarily :) Thanks, Derek ------original message------ From: Ren? Neumann Date: Sat, Jan 08, 2022 at 05:55:25PM MST > >Am 09.01.22 um 00:56 schrieb Derek Stevens: >>Signed-off-by: Derek Stevens >>--- >> ui-repolist.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >>diff --git a/ui-repolist.c b/ui-repolist.c >>index 529a203..c162290 100644 >>--- a/ui-repolist.c >>+++ b/ui-repolist.c >>@@ -53,7 +53,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) >> strbuf_reset(&path); >> strbuf_addf(&path, "%s/refs/heads/%s", repo->path, >>- repo->defbranch ? repo->defbranch : "master"); >>+ repo->defbranch ? repo->defbranch : "main"); >> if (stat(path.buf, &s) == 0) { >> *mtime = s.st_mtime; >> r->mtime = *mtime; > >1. This change itself seems rather meaningless. There is at least one >other occurrence in cgit.c#guess_defbranch(), which must be in sync. >2. Also change the man file. > >- Ren? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From nilix at nilfm.cc Sun Jan 9 01:45:45 2022 From: nilix at nilfm.cc (Derek Stevens) Date: Sat, 8 Jan 2022 18:45:45 -0700 Subject: [PATCH] use main as default branch instead of master Message-ID: <20220109014545.17815-1-nilix@nilfm.cc> Signed-off-by: Derek Stevens --- cgit.c | 2 +- cgitrc.5.txt | 2 +- ui-repolist.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cgit.c b/cgit.c index 08d81a1..5b0a016 100644 --- a/cgit.c +++ b/cgit.c @@ -489,7 +489,7 @@ static char *guess_defbranch(void) ref = resolve_ref_unsafe("HEAD", 0, &oid, NULL); if (!ref || !skip_prefix(ref, "refs/heads/", &refname)) - return "master"; + return "main"; return xstrdup(refname); } diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 33a6a8c..9639156 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -479,7 +479,7 @@ repo.defbranch:: The name of the default branch for this repository. If no such branch exists in the repository, the first branch name (when sorted) is used as default instead. Default value: branch pointed to by HEAD, or - "master" if there is no suitable HEAD. + "main" if there is no suitable HEAD. repo.desc:: The value to show as repository description. Default value: none. diff --git a/ui-repolist.c b/ui-repolist.c index 529a203..c162290 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -53,7 +53,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) strbuf_reset(&path); strbuf_addf(&path, "%s/refs/heads/%s", repo->path, - repo->defbranch ? repo->defbranch : "master"); + repo->defbranch ? repo->defbranch : "main"); if (stat(path.buf, &s) == 0) { *mtime = s.st_mtime; r->mtime = *mtime; -- 2.34.1 From reto at labrat.space Sun Jan 9 03:04:54 2022 From: reto at labrat.space (Reto) Date: Sun, 9 Jan 2022 04:04:54 +0100 Subject: [PATCH] use main as default branch instead of master In-Reply-To: <20220109014545.17815-1-nilix@nilfm.cc> References: <20220109014545.17815-1-nilix@nilfm.cc> Message-ID: <20220109030454.r2gxxox4hzz5uf6g@feather> Replacing one hard coded value with another is really not helpful. Git itself solves this locally with init.defaultBranch in its config. If the corresponding option is unset you are helpfully told to choose one. That is however not simply a matter of s/master/main/ but the following: >Names commonly chosen instead of 'master' are 'main', 'trunk' and >'development'. As you can see, multiple "common" options. There's work ongoing in git to make this more streamlined, last example I know being commit e06c9e1df28e04bbf013840c6c50ce1be41b9583 Author: Thomas Wei?schuh Date: Wed Nov 3 21:17:02 2021 +0100 var: add GIT_DEFAULT_BRANCH variable. There's also similar efforts that would allow querying a remote. So I'd suggest you wait for upstream to figure it out first, rather than blindly substituting the term which would break existing setup for no real reason. From sentrycraft123 at gmail.com Sun Jan 9 12:53:22 2022 From: sentrycraft123 at gmail.com (=?UTF-8?Q?Jan_Dr=c3=b6gehoff?=) Date: Sun, 9 Jan 2022 13:53:22 +0100 Subject: [PATCH] use main as default branch instead of master In-Reply-To: <20220109030454.r2gxxox4hzz5uf6g@feather> References: <20220109014545.17815-1-nilix@nilfm.cc> <20220109030454.r2gxxox4hzz5uf6g@feather> Message-ID: <817460f2-2e3a-a385-76c4-685ce2c92700@gmail.com> > Replacing one hard coded value with another is really not helpful. > Git itself solves this locally with init.defaultBranch in its config. > > If the corresponding option is unset you are helpfully told to choose > one. That is however not simply a matter of s/master/main/ but the > following: > >> Names commonly chosen instead of 'master' are 'main', 'trunk' and >> 'development'. > As you can see, multiple "common" options. At the moment I think its better to simply stay with 'master' since that is what Git uses as the default at the moment even if multiple git hosting sites have decided to adopt main > There's work ongoing in git to make this more streamlined, > last example I know being > > commit e06c9e1df28e04bbf013840c6c50ce1be41b9583 > Author: Thomas Wei?schuh > Date: Wed Nov 3 21:17:02 2021 +0100 > > var: add GIT_DEFAULT_BRANCH variable. > > There's also similar efforts that would allow querying a remote. > > So I'd suggest you wait for upstream to figure it out first, rather than > blindly substituting the term which would break existing setup for no > real reason. From john at metanate.com Sun Jan 9 14:23:17 2022 From: john at metanate.com (John Keeping) Date: Sun, 9 Jan 2022 14:23:17 +0000 Subject: [PATCH] add 'go-import' meta tag if in a repo In-Reply-To: <20220108235559.23253-1-nilix@nilfm.cc> References: <20220108235559.23253-1-nilix@nilfm.cc> Message-ID: Please include some description here about why this change is desirable. On Sat, Jan 08, 2022 at 04:55:59PM -0700, Derek Stevens wrote: > Signed-off-by: Derek Stevens > --- > ui-shared.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/ui-shared.c b/ui-shared.c > index acd8ab5..0f57af6 100644 > --- a/ui-shared.c > +++ b/ui-shared.c > @@ -785,6 +785,9 @@ void cgit_print_docstart(void) > html_txt(ctx.page.title); > html("\n"); > htmlf("\n", cgit_version); > + if (ctx.repo) > + htmlf("\n", > + host, cgit_rooturl(), ctx.repo->url, host, cgit_rooturl(), ctx.repo->url); The indentation looks wrong here... > if (ctx.cfg.robots && *ctx.cfg.robots) > htmlf("\n", ctx.cfg.robots); > html(" The second and more interesting is to add a attribute to make a repository go-gettable. That only makes sense for go repos, you are unconditionally doing that. While that's probably fine as a local hack it certainly doesn't seem valid for all of the cgit users. From nilix at nilfm.cc Sun Jan 9 17:22:48 2022 From: nilix at nilfm.cc (Derek Stevens) Date: Sun, 9 Jan 2022 10:22:48 -0700 Subject: [PATCH] use main as default branch instead of master In-Reply-To: <817460f2-2e3a-a385-76c4-685ce2c92700@gmail.com> References: <20220109014545.17815-1-nilix@nilfm.cc> <20220109030454.r2gxxox4hzz5uf6g@feather> <817460f2-2e3a-a385-76c4-685ce2c92700@gmail.com> Message-ID: <20220109172248.4erpxsldpuyeycpy@ksatrya.siroonian.local> OK, no worries there. I'm fine leaving it alone as well. Cheers, Derek ------original message------ From: Jan Dr?gehoff Date: Sun, Jan 09, 2022 at 05:53:22AM MST >>Replacing one hard coded value with another is really not helpful. >>Git itself solves this locally with init.defaultBranch in its config. >> >>If the corresponding option is unset you are helpfully told to choose >>one. That is however not simply a matter of s/master/main/ but the >>following: >> >>>Names commonly chosen instead of 'master' are 'main', 'trunk' and >>>'development'. >>As you can see, multiple "common" options. > >At the moment I think its better to simply stay with 'master' since >that is what Git uses as the default at the moment > >even if multiple git hosting sites have decided to adopt main > >>There's work ongoing in git to make this more streamlined, >>last example I know being >> >> commit e06c9e1df28e04bbf013840c6c50ce1be41b9583 >> Author: Thomas Wei?schuh >> Date: Wed Nov 3 21:17:02 2021 +0100 >> >> var: add GIT_DEFAULT_BRANCH variable. >> >>There's also similar efforts that would allow querying a remote. >> >>So I'd suggest you wait for upstream to figure it out first, rather than >>blindly substituting the term which would break existing setup for no >>real reason. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From nilix at nilfm.cc Sun Jan 9 17:45:49 2022 From: nilix at nilfm.cc (Derek Stevens) Date: Sun, 9 Jan 2022 10:45:49 -0700 Subject: [PATCH] add 'go-import' meta tag if in a repo Message-ID: <20220109174549.qjdox4wuav3mxtci@ksatrya.siroonian.local> Ok, I'll see about adding a config option and corresponding documentation for this, as well as make sure that my indentation is consistent. Thanks! Derek ------original message------ From: Jamie Couture Date: Sun, Jan 09, 2022 at 09:59:04AM MST > On Sat, Jan 08, 2022 at 04:55:59PM -0700, Derek Stevens wrote: > > Signed-off-by: Derek Stevens > > --- > > ui-shared.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/ui-shared.c b/ui-shared.c > > index acd8ab5..0f57af6 100644 > > --- a/ui-shared.c > > +++ b/ui-shared.c > > @@ -785,6 +785,9 @@ void cgit_print_docstart(void) > > html_txt(ctx.page.title); > > html("\n"); > > htmlf("\n", cgit_version); > > + if (ctx.repo) > I recommend making this an optional feature people can opt-in and use. > Consider adding a configuration flag [1] and supporting documentation [2], > allowing admins to turn a knob 'on' if they want to use this feature. > > As John pointed out a minor nit: the leading whitespace should be tabs, > whereas these lines are mixed tab-and-space.. > > > + htmlf("\n", > > + host, cgit_rooturl(), ctx.repo->url, host, cgit_rooturl(), ctx.repo->url); > > if (ctx.cfg.robots && *ctx.cfg.robots) > > htmlf("\n", ctx.cfg.robots); > > html(" 1) { - /* If it starts with a colon, we want to use - * the default branch */ - if (colon == readme && repo->defbranch) + /* If it starts with a colon, we want to use head given + * from query or the default branch */ + if (colon == readme && ctx.qry.head) + *ref = xstrdup(ctx.qry.head); + else if (colon == readme && repo->defbranch) *ref = xstrdup(repo->defbranch); else *ref = xstrndup(readme, colon - readme); diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 33a6a8c..d9eb3b0 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -579,11 +579,11 @@ repo.readme:: verbatim as the "About" page for this repo. You may also specify a git refspec by head or by hash by prepending the refspec followed by a colon. For example, "master:docs/readme.mkd". If the value begins - with a colon, i.e. ":docs/readme.rst", the default branch of the - repository will be used. Sharing any file will expose that entire - directory tree to the "/about/PATH" endpoints, so be sure that there - are no non-public files located in the same directory as the readme - file. Default value: . + with a colon, i.e. ":docs/readme.rst", the head giving in query or + the default branch of the repository will be used. Sharing any file + will expose that entire directory tree to the "/about/PATH" endpoints, + so be sure that there are no non-public files located in the same + directory as the readme file. Default value: . repo.section:: Override the current section name for this repository. Default value: -- 2.34.1 From list at eworm.de Mon Jan 10 09:23:53 2022 From: list at eworm.de (Christian Hesse) Date: Mon, 10 Jan 2022 10:23:53 +0100 Subject: [PATCH 1/1] about: allow to give head from query In-Reply-To: <20220110091855.22394-1-list@eworm.de> References: <20220110091855.22394-1-list@eworm.de> Message-ID: <20220110102353.5a441656@leda.eworm.net> Christian Hesse on Mon, 2022/01/10 10:18: > From: Christian Hesse > > Reading the README from repository used to be limited to default > branch or a branch given in configuration. Let's allow a branch > from query if not specified explicitly. As an alternative we could introduce a new character here, so cgit can distinguish between head from query and default branch. Something like: readme=*README.md readme=:README.md readme=main:README.md Any opinion? -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From list at eworm.de Tue Jan 11 10:12:03 2022 From: list at eworm.de (Christian Hesse) Date: Tue, 11 Jan 2022 11:12:03 +0100 Subject: [PATCH 1/1] RFC: git: update to v2.35.0-rc0 Message-ID: <20220111101203.110351-1-list@eworm.de> From: Christian Hesse Update to git version v2.35.0-rc0, no additional changes required. Signed-off-by: Christian Hesse --- Makefile | 4 ++-- git | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index baa7c2d..d566c4b 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.34.1 -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz +GIT_VER = 2.35.0-rc0 +GIT_URL = https://www.kernel.org/pub/software/scm/git/testing/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r MAN5_TXT = $(wildcard *.5.txt) diff --git a/git b/git index e9d7761..90d242d 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit e9d7761bb94f20acc98824275e317fa82436c25d +Subproject commit 90d242d36e248acfae0033274b524bfa55a947fd -- 2.34.1 From alx.manpages at gmail.com Sat Jan 15 11:16:39 2022 From: alx.manpages at gmail.com (Alejandro Colomar (man-pages)) Date: Sat, 15 Jan 2022 12:16:39 +0100 Subject: blame: View blame prior to a change Message-ID: <38c101ab-0f02-6694-c27a-6bf55ae2e458@gmail.com> Hi, I'd like to propose a feature (maybe it has already been proposed) regarding the blame. Github has a very nice feature (IMHO), that allows you to easily jump from the current blame, to a blame of a previous version of the file. It's a link called "View blame prior to this change". It really helps quickly find when something very specific was changed, if there have been other more recent changes that affected the line I'm looking at. Could you please add such a feature to cgit? Thanks, Alex -- Alejandro Colomar Linux man-pages maintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/ From list at eworm.de Mon Jan 24 19:54:26 2022 From: list at eworm.de (Christian Hesse) Date: Mon, 24 Jan 2022 20:54:26 +0100 Subject: [PATCH 1/1] git: update to v2.35.0 Message-ID: <20220124195426.133788-1-list@eworm.de> From: Christian Hesse Update to git version v2.35.0, no additional changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index baa7c2d..e82e328 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.34.1 +GIT_VER = 2.35.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index e9d7761..89bece5 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit e9d7761bb94f20acc98824275e317fa82436c25d +Subproject commit 89bece5c8c96f0b962cfc89e63f82d603fd60bed -- 2.35.0 From list at eworm.de Mon Jan 24 20:10:45 2022 From: list at eworm.de (Christian Hesse) Date: Mon, 24 Jan 2022 21:10:45 +0100 Subject: [PATCH 1/1] git: update to v2.35.0 In-Reply-To: <20220124195426.133788-1-list@eworm.de> References: <20220124195426.133788-1-list@eworm.de> Message-ID: <20220124211045.2e98e935@leda.eworm.net> Christian Hesse on Mon, 2022/01/24 20:54: > From: Christian Hesse > > Update to git version v2.35.0, no additional changes required. We still have breaking changes from earlier git updates... So asking for fast-forward merge into master again. :) -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From list at eworm.de Sat Jan 29 09:22:11 2022 From: list at eworm.de (Christian Hesse) Date: Sat, 29 Jan 2022 10:22:11 +0100 Subject: [PATCH 1/1] git: update to v2.35.1 Message-ID: <20220129092211.12225-1-list@eworm.de> From: Christian Hesse Update to git version v2.35.1, no additional changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e82e328..2d9198d 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.35.0 +GIT_VER = 2.35.1 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index 89bece5..4c53a8c 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 89bece5c8c96f0b962cfc89e63f82d603fd60bed +Subproject commit 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a -- 2.35.0 From equaa at protonmail.com Sun Jan 30 18:04:10 2022 From: equaa at protonmail.com (equa) Date: Sun, 30 Jan 2022 18:04:10 +0000 Subject: [PATCH] Add "default-tab" and "root-default-tab" configuration options Message-ID: These options allow the user to specify a page to display at the root repository/index location instead of the default summary or repository list. Signed-off-by: equa --- cgit.c | 10 ++++++++++ cgit.h | 3 +++ cgitrc.5.txt | 11 +++++++++++ cmd.c | 6 +++--- shared.c | 1 + ui-repolist.c | 2 +- ui-shared.c | 24 ++++++++++++++++++++---- ui-shared.h | 2 ++ 8 files changed, 51 insertions(+), 8 deletions(-) diff --git a/cgit.c b/cgit.c index 08d81a1..f1c2224 100644 --- a/cgit.c +++ b/cgit.c @@ -56,6 +56,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->homepage = xstrdup(value); else if (!strcmp(name, "defbranch")) repo->defbranch = xstrdup(value); + else if (!strcmp(name, "default-tab")) + repo->default_tab = xstrdup(value); else if (!strcmp(name, "extra-head-content")) repo->extra_head_content = xstrdup(value); else if (!strcmp(name, "snapshots")) @@ -285,6 +287,10 @@ static void config_cb(const char *name, const char *value) ctx.cfg.clone_url = xstrdup(value); else if (!strcmp(name, "local-time")) ctx.cfg.local_time = atoi(value); + else if (!strcmp(name, "default-tab")) + ctx.cfg.default_tab = xstrdup(value); + else if (!strcmp(name, "root-default-tab")) + ctx.cfg.root_default_tab = xstrdup(value); else if (!strcmp(name, "commit-sort")) { if (!strcmp(value, "date")) ctx.cfg.commit_sort = 1; @@ -373,6 +379,8 @@ static void prepare_context(void) ctx.cfg.cache_scanrc_ttl = 15; ctx.cfg.cache_dynamic_ttl = 5; ctx.cfg.cache_static_ttl = -1; + ctx.cfg.default_tab = "summary"; + ctx.cfg.root_default_tab = "repolist"; ctx.cfg.case_sensitive_sort = 1; ctx.cfg.branch_sort = 0; ctx.cfg.commit_sort = 0; @@ -816,6 +824,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.homepage=%s\n", repo->homepage); if (repo->clone_url) fprintf(f, "repo.clone-url=%s\n", repo->clone_url); + if (repo->default_tab) + fprintf(f, "repo.default-tab=%s\n", repo->default_tab); fprintf(f, "repo.enable-blame=%d\n", repo->enable_blame); fprintf(f, "repo.enable-commit-graph=%d\n", diff --git a/cgit.h b/cgit.h index 69b5c13..bb555cf 100644 --- a/cgit.h +++ b/cgit.h @@ -86,6 +86,7 @@ struct cgit_repo { char *owner; char *homepage; char *defbranch; + char *default_tab; char *module_link; struct string_list readme; char *section; @@ -215,6 +216,8 @@ struct cgit_config { char *repository_sort; char *virtual_root; /* Always ends with '/'. */ char *strict_export; + char *default_tab; + char *root_default_tab; int cache_size; int cache_dynamic_ttl; int cache_max_create_time; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 33a6a8c..f32fb33 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -128,6 +128,10 @@ css:: Url which specifies the css document to include in all cgit pages. Default value: "/cgit.css". +default-tab:: + Specifies the tab to automatically load in the root page of a repository. + Default value: "summary". See also: root-default-tab, repo.default-tab. + email-filter:: Specifies a command which will be invoked to format names and email address of committers, authors, and taggers, as represented in various @@ -352,6 +356,10 @@ robots:: Text used as content for the "robots" meta-tag. Default value: "index, nofollow". +root-default-tab:: + Specifies the tab to automatically load as the root index page. + Default value: "repolist". See also: default-tab, repo.default-tab. + root-desc:: Text printed below the heading on the repository index page. Default value: "a fast webinterface for the git dscm". @@ -481,6 +489,9 @@ repo.defbranch:: as default instead. Default value: branch pointed to by HEAD, or "master" if there is no suitable HEAD. +repo.default-tab:: + Override the global default-tab. Default value: none. + repo.desc:: The value to show as repository description. Default value: none. diff --git a/cmd.c b/cmd.c index 0eb75b1..64f6639 100644 --- a/cmd.c +++ b/cmd.c @@ -55,7 +55,7 @@ static void about_fn(void) cgit_redirect(ctx.repo->homepage, false); else { char *currenturl = cgit_currenturl(); - char *redirect = fmtalloc("%s../", currenturl); + char *redirect = cgit_pageurl(ctx.repo->url, "summary", NULL); cgit_redirect(redirect, false); free(currenturl); free(redirect); @@ -196,9 +196,9 @@ struct cgit_cmd *cgit_get_cmd(void) if (ctx.qry.page == NULL) { if (ctx.repo) - ctx.qry.page = "summary"; + ctx.qry.page = ctx.repo->default_tab; else - ctx.qry.page = "repolist"; + ctx.qry.page = ctx.cfg.root_default_tab; } for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++) diff --git a/shared.c b/shared.c index 8115469..b1090a6 100644 --- a/shared.c +++ b/shared.c @@ -79,6 +79,7 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->clone_url = ctx.cfg.clone_url; ret->submodules.strdup_strings = 1; ret->hide = ret->ignore = 0; + ret->default_tab = ctx.cfg.default_tab; return ret; } diff --git a/ui-repolist.c b/ui-repolist.c index 529a203..75db72a 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -321,7 +321,7 @@ void cgit_print_repolist(void) } htmlf("", !sorted && section ? "sublevel-repo" : "toplevel-repo"); - cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); + cgit_repo_link(ctx.repo->name, ctx.repo->name, NULL, NULL); html(""); repourl = cgit_repourl(ctx.repo->url); html_link_open(repourl, NULL, NULL); diff --git a/ui-shared.c b/ui-shared.c index acd8ab5..17b1e49 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -203,6 +203,9 @@ static void site_url(const char *page, const char *search, const char *sort, int { char *delim = "?"; + if (!strcmp(page ? page : "", ctx.cfg.root_default_tab)) + page = NULL; + if (always_root || page) html_attr(cgit_rooturl()); else { @@ -257,7 +260,7 @@ static void site_link(const char *page, const char *name, const char *title, void cgit_index_link(const char *name, const char *title, const char *class, const char *pattern, const char *sort, int ofs, int always_root) { - site_link(NULL, name, title, class, pattern, sort, ofs, always_root); + site_link("repolist", name, title, class, pattern, sort, ofs, always_root); } static char *repolink(const char *title, const char *class, const char *page, @@ -317,6 +320,12 @@ static void reporevlink(const char *page, const char *name, const char *title, { char *delim; + if (page + && !rev + && !path + && !strcmp(page, ctx.repo->default_tab)) + page = NULL; + delim = repolink(title, class, page, head, path); if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { html(delim); @@ -328,10 +337,17 @@ static void reporevlink(const char *page, const char *name, const char *title, html(""); } +void cgit_repo_link(const char *name, const char *title, const char *class, + const char *head) +{ + reporevlink(NULL, name, title, class, head, NULL, NULL); +} + + void cgit_summary_link(const char *name, const char *title, const char *class, const char *head) { - reporevlink(NULL, name, title, class, head, NULL, NULL); + reporevlink("summary", name, title, class, head, NULL, NULL); } void cgit_tag_link(const char *name, const char *title, const char *class, @@ -995,7 +1011,7 @@ static void print_header(void) if (ctx.repo) { cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); html(" : "); - cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); + cgit_repo_link(ctx.repo->name, ctx.repo->name, NULL, NULL); if (ctx.env.authenticated) { html(""); html("
\n"); @@ -1084,7 +1100,7 @@ void cgit_print_pageheader(void) html("
\n"); } else if (ctx.env.authenticated) { char *currenturl = cgit_currenturl(); - site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); + site_link("repolist", "index", NULL, hc("repolist"), NULL, NULL, 0, 1); if (ctx.cfg.root_readme) site_link("about", "about", NULL, hc("about"), NULL, NULL, 0, 1); diff --git a/ui-shared.h b/ui-shared.h index 6964873..9faf2ba 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -17,6 +17,8 @@ extern void cgit_add_clone_urls(void (*fn)(const char *)); extern void cgit_index_link(const char *name, const char *title, const char *class, const char *pattern, const char *sort, int ofs, int always_root); +extern void cgit_repo_link(const char *name, const char *title, + const char *class, const char *head); extern void cgit_summary_link(const char *name, const char *title, const char *class, const char *head); extern void cgit_tag_link(const char *name, const char *title, -- 2.30.2