List for cgit developers and users
 help / color / mirror / Atom feed
* Weird interactions betwen cache and module-link
@ 2022-03-25 21:08 Gianni Ceccarelli
  2022-03-25 21:44 ` Gianni Ceccarelli
  0 siblings, 1 reply; 4+ messages in thread
From: Gianni Ceccarelli @ 2022-03-25 21:08 UTC (permalink / raw)
  To: cgit

Hello!

I use git submodules pretty often, and I like that cgit allows me to
link them to their proper repository.

For example, https://www.thenautilus.net/cgit/env-sensor/tree/ or
https://www.thenautilus.net/cgit/lego-piano/tree/

You may have noticed that at least one of those pages does not show
links for the sub-modules.

If I disable the cache (``cache-size=0``), all pages show all
configured module-links, reliably.

If I enable the cache (``cache-size=1000``, no other cache-related
setting in the ``/etc/cgitrc`` file), then the *first* page I access
shows the correct links (if it has any), but subsequent ones don't.

This is cgit 1.2.3 with a one-line patch to compare sub-module names
case-insensitively (``ret->submodules.cmp = strcasecmp`` inside
``cgit_add_repo``) which I'm pretty sure shouldn't create the problem
I'm seeing.

One thing I've noticed is that cgit caches all repositories'
configuration in a single file, and that file does not include any
``module-link`` line. If cgit reads the configuration directly in the
absence of this single file, but reads only this file if it's present,
that would explain the observed behaviour. Does the code that
serialises the configuration to the cache need to be taught about
``module-link`` (and maybe other settings)?

Thanks!

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Weird interactions betwen cache and module-link
  2022-03-25 21:08 Weird interactions betwen cache and module-link Gianni Ceccarelli
@ 2022-03-25 21:44 ` Gianni Ceccarelli
  2022-03-26 10:30   ` John Keeping
  0 siblings, 1 reply; 4+ messages in thread
From: Gianni Ceccarelli @ 2022-03-25 21:44 UTC (permalink / raw)
  To: cgit

This patch seems to fix the problem.

diff --git c/cgit.c w/cgit.c
index 08d81a1..d30e259 100644
--- c/cgit.c
+++ w/cgit.c
@@ -810,6 +810,10 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
 		fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
 	if (repo->module_link)
 		fprintf(f, "repo.module-link=%s\n", repo->module_link);
+	for (int i = 0; i < repo->submodules.nr; ++i) {
+		struct string_list_item *si=&repo->submodules.items[i];
+		fprintf(f, "repo.module-link.%s=%s\n", si->string, (char*)si->util);
+	}
 	if (repo->section)
 		fprintf(f, "repo.section=%s\n", repo->section);
 	if (repo->homepage)


-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Weird interactions betwen cache and module-link
  2022-03-25 21:44 ` Gianni Ceccarelli
@ 2022-03-26 10:30   ` John Keeping
  2022-03-26 10:44     ` Gianni Ceccarelli
  0 siblings, 1 reply; 4+ messages in thread
From: John Keeping @ 2022-03-26 10:30 UTC (permalink / raw)
  To: Gianni Ceccarelli; +Cc: cgit

On Fri, Mar 25, 2022 at 09:44:48PM +0000, Gianni Ceccarelli wrote:
> This patch seems to fix the problem.

Nice catch!  This definitely looks like an oversight.

Would you like to type up a proper patch with a commit message and
Signed-off-by certification?  We use the same process as git.git so
their SubmittingPatches document [1] explains this.

[1] https://git-scm.com/docs/SubmittingPatches#sign-off

> diff --git c/cgit.c w/cgit.c
> index 08d81a1..d30e259 100644
> --- c/cgit.c
> +++ w/cgit.c
> @@ -810,6 +810,10 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
>  		fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
>  	if (repo->module_link)
>  		fprintf(f, "repo.module-link=%s\n", repo->module_link);
> +	for (int i = 0; i < repo->submodules.nr; ++i) {
> +		struct string_list_item *si=&repo->submodules.items[i];
> +		fprintf(f, "repo.module-link.%s=%s\n", si->string, (char*)si->util);
> +	}
>  	if (repo->section)
>  		fprintf(f, "repo.section=%s\n", repo->section);
>  	if (repo->homepage)
> 
> 
> -- 
> 	Dakkar - <Mobilis in mobile>
> 	GPG public key fingerprint = A071 E618 DD2C 5901 9574
> 	                             6FE2 40EA 9883 7519 3F88
> 	                    key id = 0x75193F88
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Weird interactions betwen cache and module-link
  2022-03-26 10:30   ` John Keeping
@ 2022-03-26 10:44     ` Gianni Ceccarelli
  0 siblings, 0 replies; 4+ messages in thread
From: Gianni Ceccarelli @ 2022-03-26 10:44 UTC (permalink / raw)
  To: cgit

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

On 2022-03-26 John Keeping <john@keeping.me.uk> wrote:
> Would you like to type up a proper patch with a commit message and
> Signed-off-by certification?

Sure! Patch attached.

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88


[-- Attachment #2: 0001-cgit.c-teach-repo-config-printing-about-per-path-mod.patch --]
[-- Type: text/x-patch, Size: 1049 bytes --]

From 9c8f12809a7727b19a111d717b27143c4e2001bd Mon Sep 17 00:00:00 2001
From: dakkar <dakkar@thenautilus.net>
Date: Sat, 26 Mar 2022 10:39:45 +0000
Subject: [PATCH] cgit.c: teach repo config printing about per-path module-link

This prevented path-specific module-links from working when cache was
enabled, since the cache repo config didn't include them.

Signed-off-by: Gianni Ceccarelli <dakkar@thenautilus.net>
---
 cgit.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cgit.c b/cgit.c
index 08d81a1..ae3a66e 100644
--- a/cgit.c
+++ b/cgit.c
@@ -810,6 +810,10 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
 		fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
 	if (repo->module_link)
 		fprintf(f, "repo.module-link=%s\n", repo->module_link);
+	for_each_string_list_item(item, &repo->submodules) {
+		if (item->util)
+			fprintf(f, "repo.module-link.%s=%s\n", item->string, (char*)item->util);
+	}
 	if (repo->section)
 		fprintf(f, "repo.section=%s\n", repo->section);
 	if (repo->homepage)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-26 10:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 21:08 Weird interactions betwen cache and module-link Gianni Ceccarelli
2022-03-25 21:44 ` Gianni Ceccarelli
2022-03-26 10:30   ` John Keeping
2022-03-26 10:44     ` Gianni Ceccarelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).