Re: [PATCH] Support .git/category files

2015-03-05 Thread John Keeping
On Thu, Mar 05, 2015 at 06:50:47PM +0100, Jan-Marek Glogowski wrote:
> Am 05.03.2015 um 18:38 schrieb John Keeping:
> > What's the advantage of this over using "enable-git-config=1" and
> > "cgit.section" (we even support "gitweb.section" as an alias)?
> 
> Well - I have 100+ repositories, which already have the "category" file.
> There is no "advantage" over any other method.
> 
> Am 05.03.2015 um 18:41 schrieb Lukas Fleischer:>
> > There already are at least two ways to achieve the same thing (using
> > the Git configuration variables gitweb.category or cgit.section and
> > repository-specific cgitrc files). Do we really need another
> > alternative? Is this just for GitWeb compatibility or does this have
> > any advantages over the existing options?
> 
> Yes - it's "just" GitWeb compatibility, like - I guess - the
> "description" file support just the few lines before my path.

The "description" file is a bit different though - it's in the default
repository template that ships with Git and is used by the sample hooks
that ship there.

I'm not sure "category" is similar enough, particularly when you can do:

for repo in $repositories
do
git -C "$repo" config gitweb.category "$(cat "$repo"/category)" 
&&
rm -f "$repo"/category
done

and still have a configuration that works with both Gitweb and CGit.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH] Support .git/category files

2015-03-05 Thread Jan-Marek Glogowski
Am 05.03.2015 um 18:38 schrieb John Keeping:
> What's the advantage of this over using "enable-git-config=1" and
> "cgit.section" (we even support "gitweb.section" as an alias)?

Well - I have 100+ repositories, which already have the "category" file.
There is no "advantage" over any other method.

Am 05.03.2015 um 18:41 schrieb Lukas Fleischer:>
> There already are at least two ways to achieve the same thing (using
> the Git configuration variables gitweb.category or cgit.section and
> repository-specific cgitrc files). Do we really need another
> alternative? Is this just for GitWeb compatibility or does this have
> any advantages over the existing options?

Yes - it's "just" GitWeb compatibility, like - I guess - the
"description" file support just the few lines before my path.

JMG
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH] Support .git/category files

2015-03-05 Thread Lukas Fleischer
On Thu, 05 Mar 2015 at 18:15:04, Jan-Marek Glogowski wrote:
> Gitweb reads .git/category to set a repository section for
> grouping. This handles the file in the same way a .git/description
> file is handled.
> 
> The file section takes precedence over the ctx.cfg.section_from_path
> setting.
> ---
>  cgit.c  |  2 +-
>  cgit.h  |  1 +
>  scan-tree.c | 20 +++-
>  shared.c|  1 +
>  4 files changed, 22 insertions(+), 2 deletions(-)
> [...]

There already are at least two ways to achieve the same thing (using the
Git configuration variables gitweb.category or cgit.section and
repository-specific cgitrc files). Do we really need another
alternative? Is this just for GitWeb compatibility or does this have any
advantages over the existing options?
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH] Support .git/category files

2015-03-05 Thread John Keeping
On Thu, Mar 05, 2015 at 06:15:04PM +0100, Jan-Marek Glogowski wrote:
> Gitweb reads .git/category to set a repository section for
> grouping. This handles the file in the same way a .git/description
> file is handled.
> 
> The file section takes precedence over the ctx.cfg.section_from_path
> setting.

What's the advantage of this over using "enable-git-config=1" and
"cgit.section" (we even support "gitweb.section" as an alias)?

> ---
>  cgit.c  |  2 +-
>  cgit.h  |  1 +
>  scan-tree.c | 20 +++-
>  shared.c|  1 +
>  4 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/cgit.c b/cgit.c
> index 0ad8171..239f709 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -377,7 +377,7 @@ static void prepare_context(void)
>   ctx.cfg.root_desc = "a fast webinterface for the git dscm";
>   ctx.cfg.scan_hidden_path = 0;
>   ctx.cfg.script_name = CGIT_SCRIPT_NAME;
> - ctx.cfg.section = "";
> + ctx.cfg.section = cgit_default_repo_section;
>   ctx.cfg.repository_sort = "name";
>   ctx.cfg.section_sort = 1;
>   ctx.cfg.summary_branches = 10;
> diff --git a/cgit.h b/cgit.h
> index 16f8092..ea9aef9 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -318,6 +318,7 @@ extern struct cgit_context ctx;
>  extern const struct cgit_snapshot_format cgit_snapshot_formats[];
>  
>  extern char *cgit_default_repo_desc;
> +extern char *cgit_default_repo_section;
>  extern struct cgit_repo *cgit_add_repo(const char *url);
>  extern struct cgit_repo *cgit_get_repoinfo(const char *url);
>  extern void cgit_repo_config_cb(const char *name, const char *value);
> diff --git a/scan-tree.c b/scan-tree.c
> index e900ad9..c7ba509 100644
> --- a/scan-tree.c
> +++ b/scan-tree.c
> @@ -149,7 +149,25 @@ static void add_repo(const char *base, struct strbuf 
> *path, repo_config_fn fn)
>   strbuf_setlen(path, pathlen);
>   }
>  
> - if (ctx.cfg.section_from_path) {
> + if (repo->section == cgit_default_repo_section || !repo->section) {
> + strbuf_addstr(path, "category");
> + if (!stat(path->buf, &st) &&
> + !readfile(path->buf, &repo->section, &size)) {
> + // trim category, as gitweb does
> + while (size > 0 && isspace((unsigned 
> char)repo->section[size - 1]))
> + size--;
> + if (size == 0) {
> + free(repo->section);
> + repo->section = cgit_default_repo_section;
> + }
> + else
> + repo->section[size] = '\0';
> + }
> + strbuf_setlen(path, pathlen);
> + }
> +
> + if (ctx.cfg.section_from_path
> +&& (repo->section == cgit_default_repo_section || 
> !repo->section)) {
>   n = ctx.cfg.section_from_path;
>   if (n > 0) {
>   slash = rel.buf - 1;
> diff --git a/shared.c b/shared.c
> index ae17d78..4b21da2 100644
> --- a/shared.c
> +++ b/shared.c
> @@ -34,6 +34,7 @@ int chk_non_negative(int result, char *msg)
>  }
>  
>  char *cgit_default_repo_desc = "[no description]";
> +char *cgit_default_repo_section = "";
>  struct cgit_repo *cgit_add_repo(const char *url)
>  {
>   struct cgit_repo *ret;
> -- 
> 1.9.1
> 
> ___
> CGit mailing list
> CGit@lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/cgit
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit