aboutsummaryrefslogtreecommitdiffstats
path: root/scan-tree.c
AgeCommit message (Collapse)AuthorFilesLines
2011-06-20Only guess default branch when a repo page is requestedLars Hjemli1-36/+0
There's no need to invoke guess_defbranch() for each repo during scan-path, since repo.defbranch is only used when repo content is being displayed. Also, some users prefer to register their projects manually in cgitrc but they got no benefit from the new repo.defbranch handling. This patch tries to rectify these issues by only invoking guess_defbranch() when needed, regardless of how the repo was registered. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-06-20guess default branch from HEADJulius Plenz1-0/+36
This is a saner alternative than hardcoding the default branch to be "master". The add_repo() function will now check for a symbolic ref in repo_path/HEAD. If there is a suitable one, overwrite repo->defbranch with it. Note that you'll need to strip the newline from the file (-> len-17). If HEAD is a symbolic link pointing directly to a branch below refs/heads/, do a readlink() instead to find the ref name. Signed-off-by: Julius Plenz <plenz@cis.fu-berlin.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-06-06scan-tree.c: avoid memory leakJamie Couture1-0/+2
No references are kept to the memory pointed to by the 'rel' variable, so it should be free()'d before returning from add_repo(). Signed-off-by: Jamie Couture <jamie.couture@gmail.com> Signed-off-by: Lars Hjemli <larsh@hjemli.net>
2011-03-26Fix crash when projectsfile cannot be openedStefan Gehn1-0/+1
This patch makes cgit properly abort in case the projectsfile cannot be opened. Without the added return cgit continues using the projects pointer which is NULL and thus causes a segfault.
2011-02-19scan_path(): Do not recurse into hidden directories by defaultJohan Herland1-0/+2
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>
2010-11-16scan_path(): Improve handling of inaccessible directoriesJohan Herland1-9/+9
When scanning a tree containing inaccessible directories (e.g. '.ssh' directories in users' homedirs, or repos with explicitly restricted access), scan_path() currently causes three lines of "Permissions denied" errors to be printed to the CGI error log per inaccessible directory: Error checking path /home/foo/.ssh: Permission denied (13) Error checking path /home/foo/.ssh/.git: Permission denied (13) Error opening directory /home/foo/.ssh: Permission denied (13) This is a side-effect of calling is_git_dir(path) and is_git_dir(fmt("%s/.git", path) _before_ we try to opendir(path). By placing the opendir(path) before the two is_git_dir() calls, we reduce the noise to a single line per inaccessible directory: Error opening directory /home/foo/.ssh: Permission denied (13) Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <larsh@prediktor.no>
2010-11-08Add `strict-export` optionFelix Hanley1-0/+4
This option is used to specify a filename which needs to be present in the repositories found during `scan-path` processing. By setting this option to 'git-daemon-export-ok', only repositories explicitly marked for git daemon export will be included in the cgit configuration. Signed-off-by: Felix Hanley <felix@seconddrawer.com.au> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-09-19Merge branch 'lh/section-from-path'Lars Hjemli1-6/+36
Conflicts: scan-tree.c
2010-08-22Add support for 'section-from-path' optionLars Hjemli1-6/+36
This option can be used to autogenerate section names during scan-path processing. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-08-22Add support for "readme" optionLars Hjemli1-3/+5
The value of this option is used as the default value for repo.readme. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-08-04Add support for 'enable-gitweb-owner' optionJason A. Donenfeld1-9/+24
When this option is enabled (which it is by default), cgit will lookup the 'gitweb.owner' setting in each git config file found when processing the 'scan-path' option. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-08-04Add support for 'remove-suffix' optionJason A. Donenfeld1-0/+3
When this option is enabled, the '.git' suffix of repository directories found while processing the 'scan-path' option will be removed. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-08-04Add support for 'project-list' optionJason A. Donenfeld1-0/+37
This option specifies the location of a projectlist file as used by gitweb - when 'scan-tree' is later specified, only the projects listed in the projectlist file will be added. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-02-28scan-tree: add test for noweb-file in repo dirLars Hjemli1-0/+2
If such a file exists, the repo is not added to the repolist. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-24Add support for repo-local cgitrc fileLars Hjemli1-8/+22
When recursively scanning a directory tree looking for git repositories, cgit will now parse cgitrc files found within such repositories. The repo-specific config files can include any repo-specific options except 'repo.url' and 'repo.path'. Also, in such config files the 'repo.' prefix can not be used, i.e. the valid options then becomes: * name * clone-url * desc * ower * defbranch * snapshots * enable-log-filecount * enable-log-linecount * max-stats * module-link * section * about-filter * commit-filter * source-filter * readme Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-24scan-tree: detect non-bare repository and stop scanning earlyLars Hjemli1-0/+4
We don't want to descend into every subdirectory of a git repository with a workdir. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-20scan-tree: split the pw_gecos field at the ',' to get the real nameStefan Naewe1-0/+3
Signed-off-by: Stefan Naewe <stefan.naewe@atlas-elektronik.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-18Add and use a common readfile() functionLars Hjemli1-14/+2
This function is used to read the full content of a textfile into a newly allocated buffer (with zerotermination). It replaces the earlier readfile() in scan-tree.c (which was rather error-prone[1]), and is reused by read_agefile() in ui-repolist.c. 1: No checks for EINTR and EAGAIN, fixed-size buffer Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-18truncate buffer before reading empty filesSimon Arlott1-0/+1
If readfile() reads an empty file, fgets() won't truncate the buffer and it'll still contain the contents of the previously read file. [lh: fixed similar issue in ui-repolist.c] Signed-off-by: Simon Arlott <simon@fire.lp0.eu> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-09-15Add support for --scan-tree=<path> option to cgitLars Hjemli1-0/+136
This option makes cgit scan a directory tree looking for git repositories, generating suitable definitions for a cgitrc file on stdout. Signed-off-by: Lars Hjemli <hjemli@gmail.com>