author | Lars Hjemli <hjemli@gmail.com> | 2010-08-21 13:08:01 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-08-22 11:35:47 (UTC) |
commit | 515edb0da3b9156e07e269621d7474cdea82acaf (patch) (unidiff) | |
tree | e5fed5e83f29166c23216437386e10070e1d258d /scan-tree.c | |
parent | 6d7552bc072599313ef423d69156d824c075572a (diff) | |
download | cgit-515edb0da3b9156e07e269621d7474cdea82acaf.zip cgit-515edb0da3b9156e07e269621d7474cdea82acaf.tar.gz cgit-515edb0da3b9156e07e269621d7474cdea82acaf.tar.bz2 |
Add support for "readme" option
The value of this option is used as the default value for repo.readme.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | scan-tree.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/scan-tree.c b/scan-tree.c index e987824..780d405 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -81,67 +81,69 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
81 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); | 81 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); |
82 | if (base == path) | 82 | if (base == path) |
83 | p = fmt("%s", path); | 83 | p = fmt("%s", path); |
84 | else | 84 | else |
85 | p = fmt("%s", path + strlen(base) + 1); | 85 | p = fmt("%s", path + strlen(base) + 1); |
86 | 86 | ||
87 | if (!strcmp(p + strlen(p) - 5, "/.git")) | 87 | if (!strcmp(p + strlen(p) - 5, "/.git")) |
88 | p[strlen(p) - 5] = '\0'; | 88 | p[strlen(p) - 5] = '\0'; |
89 | 89 | ||
90 | repo = cgit_add_repo(xstrdup(p)); | 90 | repo = cgit_add_repo(xstrdup(p)); |
91 | if (ctx.cfg.remove_suffix) | 91 | if (ctx.cfg.remove_suffix) |
92 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) | 92 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) |
93 | *p = '\0'; | 93 | *p = '\0'; |
94 | repo->name = repo->url; | 94 | repo->name = repo->url; |
95 | repo->path = xstrdup(path); | 95 | repo->path = xstrdup(path); |
96 | while (!owner) { | 96 | while (!owner) { |
97 | if ((pwd = getpwuid(st.st_uid)) == NULL) { | 97 | if ((pwd = getpwuid(st.st_uid)) == NULL) { |
98 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", | 98 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", |
99 | path, strerror(errno), errno); | 99 | path, strerror(errno), errno); |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | if (pwd->pw_gecos) | 102 | if (pwd->pw_gecos) |
103 | if ((p = strchr(pwd->pw_gecos, ','))) | 103 | if ((p = strchr(pwd->pw_gecos, ','))) |
104 | *p = '\0'; | 104 | *p = '\0'; |
105 | owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name); | 105 | owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name); |
106 | } | 106 | } |
107 | repo->owner = owner; | 107 | repo->owner = owner; |
108 | 108 | ||
109 | p = fmt("%s/description", path); | 109 | p = fmt("%s/description", path); |
110 | if (!stat(p, &st)) | 110 | if (!stat(p, &st)) |
111 | readfile(p, &repo->desc, &size); | 111 | readfile(p, &repo->desc, &size); |
112 | 112 | ||
113 | p = fmt("%s/README.html", path); | 113 | if (!repo->readme) { |
114 | if (!stat(p, &st)) | 114 | p = fmt("%s/README.html", path); |
115 | repo->readme = "README.html"; | 115 | if (!stat(p, &st)) |
116 | repo->readme = "README.html"; | ||
117 | } | ||
116 | 118 | ||
117 | p = fmt("%s/cgitrc", path); | 119 | p = fmt("%s/cgitrc", path); |
118 | if (!stat(p, &st)) { | 120 | if (!stat(p, &st)) { |
119 | config_fn = fn; | 121 | config_fn = fn; |
120 | parse_configfile(xstrdup(p), &repo_config); | 122 | parse_configfile(xstrdup(p), &repo_config); |
121 | } | 123 | } |
122 | } | 124 | } |
123 | 125 | ||
124 | static void scan_path(const char *base, const char *path, repo_config_fn fn) | 126 | static void scan_path(const char *base, const char *path, repo_config_fn fn) |
125 | { | 127 | { |
126 | DIR *dir; | 128 | DIR *dir; |
127 | struct dirent *ent; | 129 | struct dirent *ent; |
128 | char *buf; | 130 | char *buf; |
129 | struct stat st; | 131 | struct stat st; |
130 | 132 | ||
131 | if (is_git_dir(path)) { | 133 | if (is_git_dir(path)) { |
132 | add_repo(base, path, fn); | 134 | add_repo(base, path, fn); |
133 | return; | 135 | return; |
134 | } | 136 | } |
135 | if (is_git_dir(fmt("%s/.git", path))) { | 137 | if (is_git_dir(fmt("%s/.git", path))) { |
136 | add_repo(base, fmt("%s/.git", path), fn); | 138 | add_repo(base, fmt("%s/.git", path), fn); |
137 | return; | 139 | return; |
138 | } | 140 | } |
139 | dir = opendir(path); | 141 | dir = opendir(path); |
140 | if (!dir) { | 142 | if (!dir) { |
141 | fprintf(stderr, "Error opening directory %s: %s (%d)\n", | 143 | fprintf(stderr, "Error opening directory %s: %s (%d)\n", |
142 | path, strerror(errno), errno); | 144 | path, strerror(errno), errno); |
143 | return; | 145 | return; |
144 | } | 146 | } |
145 | while((ent = readdir(dir)) != NULL) { | 147 | while((ent = readdir(dir)) != NULL) { |
146 | if (ent->d_name[0] == '.') { | 148 | if (ent->d_name[0] == '.') { |
147 | if (ent->d_name[1] == '\0') | 149 | if (ent->d_name[1] == '\0') |