author | Lars Hjemli <hjemli@gmail.com> | 2009-12-08 18:34:30 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-12-08 18:34:30 (UTC) |
commit | 4e75d7c9b93010663963d362099777b77a67c446 (patch) (side-by-side diff) | |
tree | b36c95b774e31bd4bb3bcde0123d6522719b7a5a | |
parent | f4f6210b4f9c214dc247567bbd06b1135c9ecd06 (diff) | |
parent | 41934a3222cd3e5a5f214e4275929519c70d311d (diff) | |
download | cgit-4e75d7c9b93010663963d362099777b77a67c446.zip cgit-4e75d7c9b93010663963d362099777b77a67c446.tar.gz cgit-4e75d7c9b93010663963d362099777b77a67c446.tar.bz2 |
Merge branch 'lh/remote-branches'
-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 9 | ||||
-rw-r--r-- | shared.c | 1 | ||||
-rw-r--r-- | ui-refs.c | 2 |
5 files changed, 18 insertions, 0 deletions
@@ -15,173 +15,177 @@ #include "ui-stats.h" #include "scan-tree.h" const char *cgit_version = CGIT_VERSION; void add_mimetype(const char *name, const char *value) { struct string_list_item *item; item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); item->util = xstrdup(value); } struct cgit_filter *new_filter(const char *cmd, int extra_args) { struct cgit_filter *f; if (!cmd || !cmd[0]) return NULL; f = xmalloc(sizeof(struct cgit_filter)); f->cmd = xstrdup(cmd); f->argv = xmalloc((2 + extra_args) * sizeof(char *)); f->argv[0] = f->cmd; f->argv[1] = NULL; return f; } static void process_cached_repolist(const char *path); void repo_config(struct cgit_repo *repo, const char *name, const char *value) { if (!strcmp(name, "name")) repo->name = xstrdup(value); else if (!strcmp(name, "clone-url")) repo->clone_url = xstrdup(value); else if (!strcmp(name, "desc")) repo->desc = xstrdup(value); else if (!strcmp(name, "owner")) repo->owner = xstrdup(value); else if (!strcmp(name, "defbranch")) repo->defbranch = xstrdup(value); else if (!strcmp(name, "snapshots")) repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); else if (!strcmp(name, "enable-log-filecount")) repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); else if (!strcmp(name, "enable-log-linecount")) repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); + else if (!strcmp(name, "enable-remote-branches")) + repo->enable_remote_branches = atoi(value); else if (!strcmp(name, "max-stats")) repo->max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "module-link")) repo->module_link= xstrdup(value); else if (!strcmp(name, "section")) repo->section = xstrdup(value); else if (!strcmp(name, "readme") && value != NULL) { if (*value == '/') repo->readme = xstrdup(value); else repo->readme = xstrdup(fmt("%s/%s", repo->path, value)); } else if (ctx.cfg.enable_filter_overrides) { if (!strcmp(name, "about-filter")) repo->about_filter = new_filter(value, 0); else if (!strcmp(name, "commit-filter")) repo->commit_filter = new_filter(value, 0); else if (!strcmp(name, "source-filter")) repo->source_filter = new_filter(value, 1); } } void config_cb(const char *name, const char *value) { if (!strcmp(name, "section") || !strcmp(name, "repo.group")) ctx.cfg.section = xstrdup(value); else if (!strcmp(name, "repo.url")) ctx.repo = cgit_add_repo(value); else if (ctx.repo && !strcmp(name, "repo.path")) ctx.repo->path = trim_end(value, '/'); else if (ctx.repo && !prefixcmp(name, "repo.")) repo_config(ctx.repo, name + 5, value); else if (!strcmp(name, "root-title")) ctx.cfg.root_title = xstrdup(value); else if (!strcmp(name, "root-desc")) ctx.cfg.root_desc = xstrdup(value); else if (!strcmp(name, "root-readme")) ctx.cfg.root_readme = xstrdup(value); else if (!strcmp(name, "css")) ctx.cfg.css = xstrdup(value); else if (!strcmp(name, "favicon")) ctx.cfg.favicon = xstrdup(value); else if (!strcmp(name, "footer")) ctx.cfg.footer = xstrdup(value); else if (!strcmp(name, "head-include")) ctx.cfg.head_include = xstrdup(value); else if (!strcmp(name, "header")) ctx.cfg.header = xstrdup(value); else if (!strcmp(name, "logo")) ctx.cfg.logo = xstrdup(value); else if (!strcmp(name, "index-header")) ctx.cfg.index_header = xstrdup(value); else if (!strcmp(name, "index-info")) ctx.cfg.index_info = xstrdup(value); else if (!strcmp(name, "logo-link")) ctx.cfg.logo_link = xstrdup(value); else if (!strcmp(name, "module-link")) ctx.cfg.module_link = xstrdup(value); else if (!strcmp(name, "virtual-root")) { ctx.cfg.virtual_root = trim_end(value, '/'); if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) ctx.cfg.virtual_root = ""; } else if (!strcmp(name, "nocache")) ctx.cfg.nocache = atoi(value); else if (!strcmp(name, "noplainemail")) ctx.cfg.noplainemail = atoi(value); else if (!strcmp(name, "noheader")) ctx.cfg.noheader = atoi(value); else if (!strcmp(name, "snapshots")) ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); else if (!strcmp(name, "enable-filter-overrides")) ctx.cfg.enable_filter_overrides = atoi(value); else if (!strcmp(name, "enable-index-links")) ctx.cfg.enable_index_links = atoi(value); else if (!strcmp(name, "enable-log-filecount")) ctx.cfg.enable_log_filecount = atoi(value); else if (!strcmp(name, "enable-log-linecount")) ctx.cfg.enable_log_linecount = atoi(value); + else if (!strcmp(name, "enable-remote-branches")) + ctx.cfg.enable_remote_branches = atoi(value); else if (!strcmp(name, "enable-tree-linenumbers")) ctx.cfg.enable_tree_linenumbers = atoi(value); else if (!strcmp(name, "max-stats")) ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "cache-size")) ctx.cfg.cache_size = atoi(value); else if (!strcmp(name, "cache-root")) ctx.cfg.cache_root = xstrdup(value); else if (!strcmp(name, "cache-root-ttl")) ctx.cfg.cache_root_ttl = atoi(value); else if (!strcmp(name, "cache-repo-ttl")) ctx.cfg.cache_repo_ttl = atoi(value); else if (!strcmp(name, "cache-scanrc-ttl")) ctx.cfg.cache_scanrc_ttl = atoi(value); else if (!strcmp(name, "cache-static-ttl")) ctx.cfg.cache_static_ttl = atoi(value); else if (!strcmp(name, "cache-dynamic-ttl")) ctx.cfg.cache_dynamic_ttl = atoi(value); else if (!strcmp(name, "about-filter")) ctx.cfg.about_filter = new_filter(value, 0); else if (!strcmp(name, "commit-filter")) ctx.cfg.commit_filter = new_filter(value, 0); else if (!strcmp(name, "embedded")) ctx.cfg.embedded = atoi(value); else if (!strcmp(name, "max-message-length")) ctx.cfg.max_msg_len = atoi(value); else if (!strcmp(name, "max-repodesc-length")) ctx.cfg.max_repodesc_len = atoi(value); else if (!strcmp(name, "max-blob-size")) ctx.cfg.max_blob_size = atoi(value); else if (!strcmp(name, "max-repo-count")) ctx.cfg.max_repo_count = atoi(value); else if (!strcmp(name, "max-commit-count")) ctx.cfg.max_commit_count = atoi(value); else if (!strcmp(name, "scan-path")) if (!ctx.cfg.nocache && ctx.cfg.cache_size) process_cached_repolist(value); else scan_tree(value, repo_config); else if (!strcmp(name, "source-filter")) ctx.cfg.source_filter = new_filter(value, 1); else if (!strcmp(name, "summary-log")) ctx.cfg.summary_log = atoi(value); else if (!strcmp(name, "summary-branches")) ctx.cfg.summary_branches = atoi(value); else if (!strcmp(name, "summary-tags")) ctx.cfg.summary_tags = atoi(value); else if (!strcmp(name, "side-by-side-diffs")) @@ -27,96 +27,97 @@ #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" #define FMT_SHORTDATE "%Y-%m-%d" #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" /* * Limits used for relative dates */ #define TM_MIN 60 #define TM_HOUR (TM_MIN * 60) #define TM_DAY (TM_HOUR * 24) #define TM_WEEK (TM_DAY * 7) #define TM_YEAR (TM_DAY * 365) #define TM_MONTH (TM_YEAR / 12.0) /* * Default encoding */ #define PAGE_ENCODING "UTF-8" typedef void (*configfn)(const char *name, const char *value); typedef void (*filepair_fn)(struct diff_filepair *pair); typedef void (*linediff_fn)(char *line, int len); struct cgit_filter { char *cmd; char **argv; int old_stdout; int pipe_fh[2]; int pid; int exitstatus; }; struct cgit_repo { char *url; char *name; char *path; char *desc; char *owner; char *defbranch; char *module_link; char *readme; char *section; char *clone_url; int snapshots; int enable_log_filecount; int enable_log_linecount; + int enable_remote_branches; int max_stats; time_t mtime; struct cgit_filter *about_filter; struct cgit_filter *commit_filter; struct cgit_filter *source_filter; }; typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, const char *value); struct cgit_repolist { int length; int count; struct cgit_repo *repos; }; struct commitinfo { struct commit *commit; char *author; char *author_email; unsigned long author_date; char *committer; char *committer_email; unsigned long committer_date; char *subject; char *msg; char *msg_encoding; }; struct taginfo { char *tagger; char *tagger_email; unsigned long tagger_date; char *msg; }; struct refinfo { const char *refname; struct object *object; union { struct taginfo *tag; struct commitinfo *commit; }; }; struct reflist { struct refinfo **refs; int alloc; @@ -134,96 +135,97 @@ struct cgit_query { char *head; char *sha1; char *sha2; char *path; char *name; char *mimetype; char *url; char *period; int ofs; int nohead; char *sort; int showmsg; int ssdiff; }; struct cgit_config { char *agefile; char *cache_root; char *clone_prefix; char *css; char *favicon; char *footer; char *head_include; char *header; char *index_header; char *index_info; char *logo; char *logo_link; char *module_link; char *robots; char *root_title; char *root_desc; char *root_readme; char *script_name; char *section; char *virtual_root; int cache_size; int cache_dynamic_ttl; int cache_max_create_time; int cache_repo_ttl; int cache_root_ttl; int cache_scanrc_ttl; int cache_static_ttl; int embedded; int enable_filter_overrides; int enable_index_links; int enable_log_filecount; int enable_log_linecount; + int enable_remote_branches; int enable_tree_linenumbers; int local_time; int max_repo_count; int max_commit_count; int max_lock_attempts; int max_msg_len; int max_repodesc_len; int max_blob_size; int max_stats; int nocache; int noplainemail; int noheader; int renamelimit; int snapshots; int summary_branches; int summary_log; int summary_tags; int ssdiff; struct string_list mimetypes; struct cgit_filter *about_filter; struct cgit_filter *commit_filter; struct cgit_filter *source_filter; }; struct cgit_page { time_t modified; time_t expires; size_t size; char *mimetype; char *charset; char *filename; char *etag; char *title; int status; char *statusmsg; }; struct cgit_environment { char *cgit_config; char *http_host; char *https; char *no_http; char *path_info; char *query_string; char *request_method; char *script_name; char *server_name; char *server_port; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 70e4c78..d74d9e7 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -65,96 +65,101 @@ cache-size:: The maximum number of entries in the cgit cache. Default value: "0" (i.e. caching is disabled). cache-static-ttl:: Number which specifies the time-to-live, in minutes, for the cached version of repository pages accessed with a fixed SHA1. Default value: "5". 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. 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. css:: Url which specifies the css document to include in all cgit pages. Default value: "/cgit.css". 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-filter-overrides:: Flag which, when set to "1", allows all filter settings to be overridden in repository-specific cgitrc files. Default value: none. 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-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-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". favicon:: Url used as link to a shortcut icon for cgit. If specified, it is suggested to use the value "/favicon.ico" since certain browsers will ignore other values. Default value: none. 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. 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", makes cgit print commit and tag times in the servers timezone. Default value: "0". logo:: Url which specifies the source of an image which will be used as a logo on all cgit pages. Default value: "/cgit.png". logo-link:: Url loaded when clicking on the cgit logo image. If unspecified the @@ -267,96 +272,100 @@ summary-branches:: view. Default value: "10". summary-log:: Specifies the number of log entries to display in the repository "summary" view. Default value: "10". summary-tags:: Specifies the number of tags to display in the repository "summary" view. Default value: "10". virtual-root:: Url which, if specified, will be used as root for all cgit links. It will also cause cgit to generate 'virtual urls', i.e. urls like '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default value: none. NOTE: cgit has recently learned how to use PATH_INFO to achieve the same kind of virtual urls, so this option will probably be deprecated. REPOSITORY SETTINGS ------------------- repo.about-filter:: Override the default about-filter. Default value: none. See also: "enable-filter-overrides". repo.clone-url:: A list of space-separated urls which can be used to clone this repo. Default value: none. repo.commit-filter:: Override the default commit-filter. Default value: none. See also: "enable-filter-overrides". repo.defbranch:: The name of the default branch for this repository. If no such branch exists in the repository, the first branch name (when sorted) is used as default instead. Default value: "master". repo.desc:: The value to show as repository description. Default value: none. repo.enable-log-filecount:: A flag which can be used to disable the global setting `enable-log-filecount'. Default value: none. repo.enable-log-linecount:: A flag which can be used to disable the global setting `enable-log-linecount'. Default value: none. +repo.enable-remote-branches:: + Flag which, when set to "1", will make cgit display remote branches + in the summary and refs views. Default value: <enable-remote-branches>. + repo.max-stats:: Override the default maximum statistics period. Valid values are equal to the values specified for the global "max-stats" setting. Default value: none. repo.name:: The value to show as repository name. Default value: <repo.url>. repo.owner:: A value used to identify the owner of the repository. Default value: none. repo.path:: An absolute path to the repository directory. For non-bare repositories this is the .git-directory. Default value: none. repo.readme:: A path (relative to <repo.path>) which specifies a file to include verbatim as the "About" page for this repo. Default value: none. repo.snapshots:: A mask of allowed snapshot-formats for this repo, restricted by the "snapshots" global setting. Default value: <snapshots>. repo.section:: Override the current section name for this repository. Default value: none. repo.source-filter:: Override the default source-filter. Default value: none. See also: "enable-filter-overrides". repo.url:: The relative url used to access the repository. This must be the first setting specified for each repo. Default value: none. REPOSITORY-SPECIFIC CGITRC FILE ------------------------------- When the option "scan-path" is used to auto-discover git repositories, cgit will try to parse the file "cgitrc" within any found repository. Such a repo-specific config file may contain any of the repo-specific options described above, except "repo.url" and "repo.path". Additionally, the "filter" options are only acknowledged in repo-specific config files when "enable-filter-overrides" is set to "1". Note: the "repo." prefix is dropped from the option names in repo-specific config files, e.g. "repo.desc" becomes "desc". @@ -14,96 +14,97 @@ int cgit_cmd; int chk_zero(int result, char *msg) { if (result != 0) die("%s: %s", msg, strerror(errno)); return result; } int chk_positive(int result, char *msg) { if (result <= 0) die("%s: %s", msg, strerror(errno)); return result; } int chk_non_negative(int result, char *msg) { if (result < 0) die("%s: %s",msg, strerror(errno)); return result; } struct cgit_repo *cgit_add_repo(const char *url) { struct cgit_repo *ret; if (++cgit_repolist.count > cgit_repolist.length) { if (cgit_repolist.length == 0) cgit_repolist.length = 8; else cgit_repolist.length *= 2; cgit_repolist.repos = xrealloc(cgit_repolist.repos, cgit_repolist.length * sizeof(struct cgit_repo)); } ret = &cgit_repolist.repos[cgit_repolist.count-1]; memset(ret, 0, sizeof(struct cgit_repo)); ret->url = trim_end(url, '/'); ret->name = ret->url; ret->path = NULL; ret->desc = "[no description]"; ret->owner = NULL; ret->section = ctx.cfg.section; ret->defbranch = "master"; ret->snapshots = ctx.cfg.snapshots; ret->enable_log_filecount = ctx.cfg.enable_log_filecount; ret->enable_log_linecount = ctx.cfg.enable_log_linecount; + ret->enable_remote_branches = ctx.cfg.enable_remote_branches; ret->max_stats = ctx.cfg.max_stats; ret->module_link = ctx.cfg.module_link; ret->readme = NULL; ret->mtime = -1; ret->about_filter = ctx.cfg.about_filter; ret->commit_filter = ctx.cfg.commit_filter; ret->source_filter = ctx.cfg.source_filter; return ret; } struct cgit_repo *cgit_get_repoinfo(const char *url) { int i; struct cgit_repo *repo; for (i=0; i<cgit_repolist.count; i++) { repo = &cgit_repolist.repos[i]; if (!strcmp(repo->url, url)) return repo; } return NULL; } void *cgit_free_commitinfo(struct commitinfo *info) { free(info->author); free(info->author_email); free(info->committer); free(info->committer_email); free(info->subject); free(info->msg); free(info->msg_encoding); free(info); return NULL; } char *trim_end(const char *str, char c) { int len; char *s, *t; if (str == NULL) return NULL; t = (char *)str; len = strlen(t); while(len > 0 && t[len - 1] == c) len--; @@ -142,96 +142,98 @@ static int print_tag(struct refinfo *ref) html("</td><td>"); if (info->tagger) html(info->tagger); html("</td><td colspan='2'>"); if (info->tagger_date > 0) cgit_print_age(info->tagger_date, -1, NULL); html("</td></tr>\n"); } else { if (!header) print_tag_header(); html("<tr><td>"); cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); html("</td><td>"); if (ctx.repo->snapshots && (ref->object->type == OBJ_COMMIT)) print_tag_downloads(ctx.repo, name); else cgit_object_link(ref->object); html("</td><td>"); if (ref->object->type == OBJ_COMMIT) html(ref->commit->author); html("</td><td colspan='2'>"); if (ref->object->type == OBJ_COMMIT) cgit_print_age(ref->commit->commit->date, -1, NULL); html("</td></tr>\n"); } return 0; } static void print_refs_link(char *path) { html("<tr class='nohover'><td colspan='4'>"); cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); html("</td></tr>"); } void cgit_print_branches(int maxcount) { struct reflist list; int i; html("<tr class='nohover'><th class='left'>Branch</th>" "<th class='left'>Commit message</th>" "<th class='left'>Author</th>" "<th class='left' colspan='2'>Age</th></tr>\n"); list.refs = NULL; list.alloc = list.count = 0; for_each_branch_ref(cgit_refs_cb, &list); + if (ctx.repo->enable_remote_branches) + for_each_remote_ref(cgit_refs_cb, &list); if (maxcount == 0 || maxcount > list.count) maxcount = list.count; if (maxcount < list.count) { qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); } for(i=0; i<maxcount; i++) print_branch(list.refs[i]); if (maxcount < list.count) print_refs_link("heads"); } void cgit_print_tags(int maxcount) { struct reflist list; int i; header = 0; list.refs = NULL; list.alloc = list.count = 0; for_each_tag_ref(cgit_refs_cb, &list); if (list.count == 0) return; qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); if (!maxcount) maxcount = list.count; else if (maxcount > list.count) maxcount = list.count; print_tag_header(); for(i=0; i<maxcount; i++) print_tag(list.refs[i]); if (maxcount < list.count) print_refs_link("tags"); } void cgit_print_refs() { html("<table class='list nowrap'>"); if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5)) cgit_print_branches(0); else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4)) |