summaryrefslogtreecommitdiffabout
path: root/scan-tree.c
authorJohan Herland <johan@herland.net>2010-11-15 19:41:00 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2011-02-19 13:25:14 (UTC)
commitdf522794c38934be3229a11e0e2432a1f2a3bc8d (patch) (unidiff)
treef11aef6d303a5327303a4471d47444764bea53d8 /scan-tree.c
parent682adbc0cad2baa1a6119013b166f52de3ee3352 (diff)
downloadcgit-df522794c38934be3229a11e0e2432a1f2a3bc8d.zip
cgit-df522794c38934be3229a11e0e2432a1f2a3bc8d.tar.gz
cgit-df522794c38934be3229a11e0e2432a1f2a3bc8d.tar.bz2
scan_path(): Do not recurse into hidden directories by default
Paths that start with a period ('.') are considered hidden in the Unix world. scan_path() should arguably not recurse into these directories by default. This patch makes it so, and introduces the "scan-hidden-path" config variable for overriding the new default and revert to the old behaviour (scanning _all_ directories, including hidden .directories). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <larsh@prediktor.no>
Diffstat (limited to 'scan-tree.c') (more/less context) (show 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 eda8c67..627af1b 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -174,24 +174,26 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)
174 goto end; 174 goto end;
175 } 175 }
176 if (is_git_dir(fmt("%s/.git", path))) { 176 if (is_git_dir(fmt("%s/.git", path))) {
177 add_repo(base, fmt("%s/.git", path), fn); 177 add_repo(base, fmt("%s/.git", path), fn);
178 goto end; 178 goto end;
179 } 179 }
180 while((ent = readdir(dir)) != NULL) { 180 while((ent = readdir(dir)) != NULL) {
181 if (ent->d_name[0] == '.') { 181 if (ent->d_name[0] == '.') {
182 if (ent->d_name[1] == '\0') 182 if (ent->d_name[1] == '\0')
183 continue; 183 continue;
184 if (ent->d_name[1] == '.' && ent->d_name[2] == '\0') 184 if (ent->d_name[1] == '.' && ent->d_name[2] == '\0')
185 continue; 185 continue;
186 if (!ctx.cfg.scan_hidden_path)
187 continue;
186 } 188 }
187 buf = malloc(strlen(path) + strlen(ent->d_name) + 2); 189 buf = malloc(strlen(path) + strlen(ent->d_name) + 2);
188 if (!buf) { 190 if (!buf) {
189 fprintf(stderr, "Alloc error on %s: %s (%d)\n", 191 fprintf(stderr, "Alloc error on %s: %s (%d)\n",
190 path, strerror(errno), errno); 192 path, strerror(errno), errno);
191 exit(1); 193 exit(1);
192 } 194 }
193 sprintf(buf, "%s/%s", path, ent->d_name); 195 sprintf(buf, "%s/%s", path, ent->d_name);
194 if (stat(buf, &st)) { 196 if (stat(buf, &st)) {
195 fprintf(stderr, "Error checking path %s: %s (%d)\n", 197 fprintf(stderr, "Error checking path %s: %s (%d)\n",
196 buf, strerror(errno), errno); 198 buf, strerror(errno), errno);
197 free(buf); 199 free(buf);