:man source: cgit :man manual: cgit CGITRC(5) ======== NAME ---- cgitrc - runtime configuration for cgit SYNOPSIS -------- Cgitrc contains all runtime settings for cgit, including the list of git repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank lines, and lines starting with '#', are ignored. LOCATION -------- The default location of cgitrc, defined at compile time, is /etc/cgitrc. At runtime, cgit will consult the environment variable CGIT_CONFIG and, if defined, use its value instead. GLOBAL SETTINGS --------------- about-filter:: Specifies a command which will be invoked to format the content of about pages (both top-level and for each repository). The command will get the content of the about-file on its STDIN, the name of the file as the first argument, and the STDOUT from the command will be included verbatim on the about page. Default value: none. See also: "FILTER API". agefile:: Specifies a path, relative to each repository path, which can be used to specify the date and time of the youngest commit in the repository. The first line in the file is used as input to the "parse_date" function in libgit. Recommended timestamp-format is "yyyy-mm-dd hh:mm:ss". You may want to generate this file from a post-receive hook. Default value: "info/web/last-modified". auth-filter:: Specifies a command that will be invoked for authenticating repository access. Receives quite a few arguments, and data on both stdin and stdout for authentication processing. Details follow later in this document. If no auth-filter is specified, no authentication is performed. Default value: none. See also: "FILTER API". branch-sort:: Flag which, when set to "age", enables date ordering in the branch ref list, and when set to "name" enables ordering by branch name. Default value: "name". cache-root:: Path used to store the cgit cache entries. Default value: "/var/cache/cgit". See also: "MACRO EXPANSION". cache-static-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed with a fixed SHA1. See also: "CACHE". Default value: -1". cache-dynamic-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed without a fixed SHA1. See also: "CACHE". Default value: "5". cache-repo-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository summary page. See also: "CACHE". Default value: "5". cache-root-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository index page. See also: "CACHE". Default value: "5". cache-scanrc-ttl:: Number which specifies the time-to-live, in minutes, for the result of scanning a path for git repositories. See also: "CACHE". Default value: "15". cache-about-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of the repository about page. See also: "CACHE". Default value: "15". cache-snapshot-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of snapshots. See also: "CACHE". Default value: "5". cache-size:: The maximum number of entries in the cgit cache. When set to "0", caching is disabled. See also: "CACHE". Default value: "0" case-sensitive-sort:: Sort items in the repo list case sensitively. Default value: "1". See also: repository-sort, section-sort. clone-prefix:: Space-separated list of common prefixes which, when combined with a repository url, generates valid clone urls for the repository. This setting is only used if `repo.clone-url` is unspecified. Default value: none. clone-url:: Space-separated list of clone-url templates. This setting is only used if `repo.clone-url` is unspecified. Default value: none. See also: "MACRO EXPANSION", "FILTER API". commit-filter:: Specifies a command which will be invoked to format commit messages. The command will get the message on its STDIN, and the STDOUT from the command will be included verbatim as the commit message, i.e. this can be used to implement bugtracker integration. Default value: none. See also: "FILTER API". commit-sort:: Flag which, when set to "date", enables strict date ordering in the commit log, and when set to "topo" enables strict topological ordering. If unset, the default ordering of "git log" is used. Default value: unset. css:: Url which specifies the css document to include in all cgit pages. Default value: "/cgit.css". email-filter:: Specifies a command which will be invoked to format names and email address of committers, authors, and taggers, as represented in various places throughout the cgit interface. This command will receive an email address and an origin page string as its command line arguments, and the text to format on STDIN. It is to write the formatted text back out onto STDOUT. Default value: none. See also: "FILTER API". embedded:: Flag which, when set to "1", will make cgit generate a html fragment suitable for embedding in other html pages. Default value: none. See also: "noheader". enable-commit-graph:: Flag which, when set to "1", will make cgit print an ASCII-art commit history graph to the left of the commit messages in the repository log page. Default value: "0". enable-filter-overrides:: Flag which, when set to "1", allows all filter settings to be overridden in repository-specific cgitrc files. Default value: none. enable-follow-links:: Flag which, when set to "1", allows users to follow a file in the log view. Default value: "0". enable-http-clone:: If set to "1", cgit will act as an dumb HTTP endpoint for git clones. You can add "http://$HTTP_HOST$SCRIPT_NAME/$CGIT_REPO_URL" to clone-url to expose this feature. If you use an alternate way of serving git repositories, you may wish to disable this. Default value: "1". enable-index-links:: Flag which, when set to "1", will make cgit generate extra links for each repo in the repository index (specifically, to the "summary", "commit" and "tree" pages). Default value: "0". enable-index-owner:: Flag which, when set to "1", will make cgit display the owner of each repo in the repository index. Default value: "1". enable-log-filecount:: Flag which, when set to "1", will make cgit print the number of modified files for each commit on the repository log page. Default value: "0". enable-log-linecount:: Flag which, when set to "1", will make cgit print the number of added and removed lines for each commit on the repository log page. Default value: "0". enable-remote-branches:: Flag which, when set to "1", will make cgit display remote branches in the summary and refs views. Default value: "0". See also: "repo.enable-remote-branches". enable-subject-links:: Flag which, when set to "1", will make cgit use the subject of the parent commit as link text when generating links to parent commits in commit view. Default value: "0". See also: "repo.enable-subject-links". enable-tree-linenumbers:: Flag which, when set to "1", will make cgit generate linenumber links for plaintext blobs printed in the tree view. Default value: "1". enable-git-config:: Flag which, when set to "1", will allow cgit to use git config to set any repo specific settings. This option is used in conjunction with "scan-path", and must be defined prior, to augment repo-specific settings. The keys gitweb.owner, gitweb.category, and gitweb.description will map to the cgit keys repo.owner, repo.section, and repo.desc, respectively. All git config keys that begin with "cgit." will be mapped to the corresponding "repo." key in cgit. Default value: "0". See also: scan-path, section-from-path. favicon:: Url used as link to a shortcut icon for cgit. It is suggested to use the value "/favicon.ico" since certain browsers will ignore other values. Default value: "/favicon.ico". footer:: The content of the file specified with this option will be included verbatim at the bottom of all pages (i.e. it replaces the standard "generated by..." message. Default value: none. head-include:: The content of the file specified with this option will be included verbatim in the html HEAD section on all pages. Default value: none. header:: The content of the file specified with this option will be included verbatim at the top of all pages. Default value: none. include:: Name of a configfile to include before the rest of the current config- file is parsed. Default value: none. See also: "MACRO EXPANSION". index-header:: The content of the file specified with this option will be included verbatim above the repository index. This setting is deprecated, and will not be supported by cgit-1.0 (use root-readme instead). Default value: none. index-info:: The content of the file specified with this option will be included verbatim below the heading on the repository index page. This setting is deprecated, and will not be supported by cgit-1.0 (use root-desc instead). Default value: none. local-time:: Flag which, if set to "1
/* ui-snapshot.c: generate snapshot of a commit
*
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
#include "html.h"
#include "ui-shared.h"
static int write_compressed_tar_archive(struct archiver_args *args,const char *filter)
{
int rw[2];
pid_t gzpid;
int stdout2;
int status;
int rv;
stdout2 = chk_non_negative(dup(STDIN_FILENO), "Preserving STDOUT before compressing");
chk_zero(pipe(rw), "Opening pipe from compressor subprocess");
gzpid = chk_non_negative(fork(), "Forking compressor subprocess");
if(gzpid==0) {
/* child */
chk_zero(close(rw[1]), "Closing write end of pipe in child");
chk_zero(close(STDIN_FILENO), "Closing STDIN");
chk_non_negative(dup2(rw[0],STDIN_FILENO), "Redirecting compressor input to stdin");
execlp(filter,filter,NULL);
_exit(-1);
}
/* parent */
chk_zero(close(rw[0]), "Closing read end of pipe");
chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor");
rv = write_tar_archive(args);
chk_zero(close(STDOUT_FILENO), "Closing STDOUT redirected to compressor");
chk_non_negative(dup2(stdout2,STDOUT_FILENO), "Restoring uncompressed STDOUT");
chk_zero(close(stdout2), "Closing uncompressed STDOUT");
chk_zero(close(rw[1]), "Closing write end of pipe in parent");
chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process");
if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) )
cgit_print_error("Failed to compress archive");
return rv;
}
static int write_tar_gzip_archive(struct archiver_args *args)
{
return write_compressed_tar_archive(args,"gzip");
}
static int write_tar_bzip2_archive(struct archiver_args *args)
{
return write_compressed_tar_archive(args,"bzip2");
}
const struct cgit_snapshot_format cgit_snapshot_formats[] = {
{ ".zip", "application/x-zip", write_zip_archive, 0x1 },
{ ".tar.gz", "application/x-gzip", write_tar_gzip_archive, 0x2 },
{ ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x4 },
{ ".tar", "application/x-tar", write_tar_archive, 0x8 },
{}
};
static const struct cgit_snapshot_format *get_format(const char *filename)
{
const struct cgit_snapshot_format *fmt;
int fl, sl;
fl = strlen(filename);
for(fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {
sl = strlen(fmt->suffix);
if (sl >= fl)
continue;
if (!strcmp(fmt->suffix, filename + fl - sl))
return fmt;
}
return NULL;
}
static int make_snapshot(const struct cgit_snapshot_format *format,
const char *hex, const char *prefix,
const char *filename)
{
struct archiver_args args;
struct commit *commit;
unsigned char sha1[20];
if(get_sha1(hex, sha1)) {
cgit_print_error(fmt("Bad object id: %s", hex));
return 1;
}
commit = lookup_commit_reference(sha1);
if(!commit)