BTW. The patch will only work if the enable_gitweb_owner is set (which it is in my case), we would want to read the description regardless of this setting. The name of the function git_owner_config should probably also get renamed.

Regards
On 17/09/2012 16:51, William Bell wrote:
From 0c76f92d0ce965276551f88898d4c1ec6f6ec3ed Mon Sep 17 00:00:00 2001
From: William Bell <[email protected]>
Date: Mon, 17 Sep 2012 16:40:56 +0200
Subject: [PATCH] make cgit honour gitweb.description

---
 scan-tree.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/scan-tree.c b/scan-tree.c
index 378d795..ab85610 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -1,5 +1,5 @@
 /* scan-tree.c
- *
+ *
  * Copyright (C) 2008-2009 Lars Hjemli
  * Copyright (C) 2010 Jason A. Donenfeld <[email protected]>
  *
@@ -48,6 +48,7 @@ static int is_git_dir(const char *path)
 struct cgit_repo *repo;
 repo_config_fn config_fn;
 char *owner;
+char *description;

 static void repo_config(const char *name, const char *value)
 {
@@ -58,6 +59,8 @@ static int git_owner_config(const char *key, const char *value, void *cb)
 {
     if (!strcmp(key, "gitweb.owner"))
         owner = xstrdup(value);
+    else if (!strcmp(key, "gitweb.description"))
+        description = xstrdup(value);
     return 0;
 }

@@ -89,6 +92,7 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
         return;

     owner = NULL;
+    description = NULL;
     if (ctx.cfg.enable_gitweb_owner)
git_config_from_file(git_owner_config, fmt("%s/config", path), NULL);
     if (base == path)
@@ -118,9 +122,14 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
     }
     repo->owner = owner;

-    p = fmt("%s/description", path);
-    if (!stat(p, &st))
-        readfile(p, &repo->desc, &size);
+    if (!description) {
+        p = fmt("%s/description", path);
+        if (!stat(p, &st))
+            readfile(p, &repo->desc, &size);
+    }
+    else {
+        repo->desc = description;
+    }

     if (!repo->readme) {
         p = fmt("%s/README.html", path);
@@ -216,7 +225,7 @@ void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn
     char line[MAX_PATH * 2], *z;
     FILE *projects;
     int err;
-
+
     projects = fopen(projectsfile, "r");
     if (!projects) {
         fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n",


_______________________________________________
cgit mailing list
[email protected]
http://hjemli.net/mailman/listinfo/cgit

Reply via email to