summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--scan-tree.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/scan-tree.c b/scan-tree.c
index dbca797..1e18f3c 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -35,48 +35,50 @@ static int is_git_dir(const char *path)
35 35
36 return 1; 36 return 1;
37} 37}
38 38
39struct cgit_repo *repo; 39struct cgit_repo *repo;
40repo_config_fn config_fn; 40repo_config_fn config_fn;
41 41
42static void repo_config(const char *name, const char *value) 42static void repo_config(const char *name, const char *value)
43{ 43{
44 config_fn(repo, name, value); 44 config_fn(repo, name, value);
45} 45}
46 46
47static void add_repo(const char *base, const char *path, repo_config_fn fn) 47static void add_repo(const char *base, const char *path, repo_config_fn fn)
48{ 48{
49 struct stat st; 49 struct stat st;
50 struct passwd *pwd; 50 struct passwd *pwd;
51 char *p; 51 char *p;
52 size_t size; 52 size_t size;
53 53
54 if (stat(path, &st)) { 54 if (stat(path, &st)) {
55 fprintf(stderr, "Error accessing %s: %s (%d)\n", 55 fprintf(stderr, "Error accessing %s: %s (%d)\n",
56 path, strerror(errno), errno); 56 path, strerror(errno), errno);
57 return; 57 return;
58 } 58 }
59 if (!stat(fmt("%s/noweb", path), &st))
60 return;
59 if ((pwd = getpwuid(st.st_uid)) == NULL) { 61 if ((pwd = getpwuid(st.st_uid)) == NULL) {
60 fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", 62 fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n",
61 path, strerror(errno), errno); 63 path, strerror(errno), errno);
62 return; 64 return;
63 } 65 }
64 if (base == path) 66 if (base == path)
65 p = fmt("%s", path); 67 p = fmt("%s", path);
66 else 68 else
67 p = fmt("%s", path + strlen(base) + 1); 69 p = fmt("%s", path + strlen(base) + 1);
68 70
69 if (!strcmp(p + strlen(p) - 5, "/.git")) 71 if (!strcmp(p + strlen(p) - 5, "/.git"))
70 p[strlen(p) - 5] = '\0'; 72 p[strlen(p) - 5] = '\0';
71 73
72 repo = cgit_add_repo(xstrdup(p)); 74 repo = cgit_add_repo(xstrdup(p));
73 repo->name = repo->url; 75 repo->name = repo->url;
74 repo->path = xstrdup(path); 76 repo->path = xstrdup(path);
75 p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL; 77 p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL;
76 if (p) 78 if (p)
77 *p = '\0'; 79 *p = '\0';
78 repo->owner = (pwd ? xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name) : ""); 80 repo->owner = (pwd ? xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name) : "");
79 81
80 p = fmt("%s/description", path); 82 p = fmt("%s/description", path);
81 if (!stat(p, &st)) 83 if (!stat(p, &st))
82 readfile(p, &repo->desc, &size); 84 readfile(p, &repo->desc, &size);