author | Lars Hjemli <hjemli@gmail.com> | 2009-11-07 18:10:58 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-11-07 18:10:58 (UTC) |
commit | 41934a3222cd3e5a5f214e4275929519c70d311d (patch) (unidiff) | |
tree | f938c5a2a595ce0b33bab53cd7d6872bfb8d62c5 | |
parent | e633ccf714eb423c4522924c3b611dac2e176c5e (diff) | |
download | cgit-41934a3222cd3e5a5f214e4275929519c70d311d.zip cgit-41934a3222cd3e5a5f214e4275929519c70d311d.tar.gz cgit-41934a3222cd3e5a5f214e4275929519c70d311d.tar.bz2 |
Add support for remote branches
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-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
@@ -51,24 +51,26 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
51 | else if (!strcmp(name, "desc")) | 51 | else if (!strcmp(name, "desc")) |
52 | repo->desc = xstrdup(value); | 52 | repo->desc = xstrdup(value); |
53 | else if (!strcmp(name, "owner")) | 53 | else if (!strcmp(name, "owner")) |
54 | repo->owner = xstrdup(value); | 54 | repo->owner = xstrdup(value); |
55 | else if (!strcmp(name, "defbranch")) | 55 | else if (!strcmp(name, "defbranch")) |
56 | repo->defbranch = xstrdup(value); | 56 | repo->defbranch = xstrdup(value); |
57 | else if (!strcmp(name, "snapshots")) | 57 | else if (!strcmp(name, "snapshots")) |
58 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); | 58 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); |
59 | else if (!strcmp(name, "enable-log-filecount")) | 59 | else if (!strcmp(name, "enable-log-filecount")) |
60 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 60 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
61 | else if (!strcmp(name, "enable-log-linecount")) | 61 | else if (!strcmp(name, "enable-log-linecount")) |
62 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 62 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
63 | else if (!strcmp(name, "enable-remote-branches")) | ||
64 | repo->enable_remote_branches = atoi(value); | ||
63 | else if (!strcmp(name, "max-stats")) | 65 | else if (!strcmp(name, "max-stats")) |
64 | repo->max_stats = cgit_find_stats_period(value, NULL); | 66 | repo->max_stats = cgit_find_stats_period(value, NULL); |
65 | else if (!strcmp(name, "module-link")) | 67 | else if (!strcmp(name, "module-link")) |
66 | repo->module_link= xstrdup(value); | 68 | repo->module_link= xstrdup(value); |
67 | else if (!strcmp(name, "section")) | 69 | else if (!strcmp(name, "section")) |
68 | repo->section = xstrdup(value); | 70 | repo->section = xstrdup(value); |
69 | else if (!strcmp(name, "readme") && value != NULL) { | 71 | else if (!strcmp(name, "readme") && value != NULL) { |
70 | if (*value == '/') | 72 | if (*value == '/') |
71 | ctx.repo->readme = xstrdup(value); | 73 | ctx.repo->readme = xstrdup(value); |
72 | else | 74 | else |
73 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); | 75 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); |
74 | } else if (ctx.cfg.enable_filter_overrides) { | 76 | } else if (ctx.cfg.enable_filter_overrides) { |
@@ -128,24 +130,26 @@ void config_cb(const char *name, const char *value) | |||
128 | else if (!strcmp(name, "noheader")) | 130 | else if (!strcmp(name, "noheader")) |
129 | ctx.cfg.noheader = atoi(value); | 131 | ctx.cfg.noheader = atoi(value); |
130 | else if (!strcmp(name, "snapshots")) | 132 | else if (!strcmp(name, "snapshots")) |
131 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 133 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
132 | else if (!strcmp(name, "enable-filter-overrides")) | 134 | else if (!strcmp(name, "enable-filter-overrides")) |
133 | ctx.cfg.enable_filter_overrides = atoi(value); | 135 | ctx.cfg.enable_filter_overrides = atoi(value); |
134 | else if (!strcmp(name, "enable-index-links")) | 136 | else if (!strcmp(name, "enable-index-links")) |
135 | ctx.cfg.enable_index_links = atoi(value); | 137 | ctx.cfg.enable_index_links = atoi(value); |
136 | else if (!strcmp(name, "enable-log-filecount")) | 138 | else if (!strcmp(name, "enable-log-filecount")) |
137 | ctx.cfg.enable_log_filecount = atoi(value); | 139 | ctx.cfg.enable_log_filecount = atoi(value); |
138 | else if (!strcmp(name, "enable-log-linecount")) | 140 | else if (!strcmp(name, "enable-log-linecount")) |
139 | ctx.cfg.enable_log_linecount = atoi(value); | 141 | ctx.cfg.enable_log_linecount = atoi(value); |
142 | else if (!strcmp(name, "enable-remote-branches")) | ||
143 | ctx.cfg.enable_remote_branches = atoi(value); | ||
140 | else if (!strcmp(name, "enable-tree-linenumbers")) | 144 | else if (!strcmp(name, "enable-tree-linenumbers")) |
141 | ctx.cfg.enable_tree_linenumbers = atoi(value); | 145 | ctx.cfg.enable_tree_linenumbers = atoi(value); |
142 | else if (!strcmp(name, "max-stats")) | 146 | else if (!strcmp(name, "max-stats")) |
143 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 147 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
144 | else if (!strcmp(name, "cache-size")) | 148 | else if (!strcmp(name, "cache-size")) |
145 | ctx.cfg.cache_size = atoi(value); | 149 | ctx.cfg.cache_size = atoi(value); |
146 | else if (!strcmp(name, "cache-root")) | 150 | else if (!strcmp(name, "cache-root")) |
147 | ctx.cfg.cache_root = xstrdup(value); | 151 | ctx.cfg.cache_root = xstrdup(value); |
148 | else if (!strcmp(name, "cache-root-ttl")) | 152 | else if (!strcmp(name, "cache-root-ttl")) |
149 | ctx.cfg.cache_root_ttl = atoi(value); | 153 | ctx.cfg.cache_root_ttl = atoi(value); |
150 | else if (!strcmp(name, "cache-repo-ttl")) | 154 | else if (!strcmp(name, "cache-repo-ttl")) |
151 | ctx.cfg.cache_repo_ttl = atoi(value); | 155 | ctx.cfg.cache_repo_ttl = atoi(value); |
@@ -63,24 +63,25 @@ struct cgit_repo { | |||
63 | char *name; | 63 | char *name; |
64 | char *path; | 64 | char *path; |
65 | char *desc; | 65 | char *desc; |
66 | char *owner; | 66 | char *owner; |
67 | char *defbranch; | 67 | char *defbranch; |
68 | char *module_link; | 68 | char *module_link; |
69 | char *readme; | 69 | char *readme; |
70 | char *section; | 70 | char *section; |
71 | char *clone_url; | 71 | char *clone_url; |
72 | int snapshots; | 72 | int snapshots; |
73 | int enable_log_filecount; | 73 | int enable_log_filecount; |
74 | int enable_log_linecount; | 74 | int enable_log_linecount; |
75 | int enable_remote_branches; | ||
75 | int max_stats; | 76 | int max_stats; |
76 | time_t mtime; | 77 | time_t mtime; |
77 | struct cgit_filter *about_filter; | 78 | struct cgit_filter *about_filter; |
78 | struct cgit_filter *commit_filter; | 79 | struct cgit_filter *commit_filter; |
79 | struct cgit_filter *source_filter; | 80 | struct cgit_filter *source_filter; |
80 | }; | 81 | }; |
81 | 82 | ||
82 | typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, | 83 | typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, |
83 | const char *value); | 84 | const char *value); |
84 | 85 | ||
85 | struct cgit_repolist { | 86 | struct cgit_repolist { |
86 | int length; | 87 | int length; |
@@ -169,24 +170,25 @@ struct cgit_config { | |||
169 | int cache_size; | 170 | int cache_size; |
170 | int cache_dynamic_ttl; | 171 | int cache_dynamic_ttl; |
171 | int cache_max_create_time; | 172 | int cache_max_create_time; |
172 | int cache_repo_ttl; | 173 | int cache_repo_ttl; |
173 | int cache_root_ttl; | 174 | int cache_root_ttl; |
174 | int cache_scanrc_ttl; | 175 | int cache_scanrc_ttl; |
175 | int cache_static_ttl; | 176 | int cache_static_ttl; |
176 | int embedded; | 177 | int embedded; |
177 | int enable_filter_overrides; | 178 | int enable_filter_overrides; |
178 | int enable_index_links; | 179 | int enable_index_links; |
179 | int enable_log_filecount; | 180 | int enable_log_filecount; |
180 | int enable_log_linecount; | 181 | int enable_log_linecount; |
182 | int enable_remote_branches; | ||
181 | int enable_tree_linenumbers; | 183 | int enable_tree_linenumbers; |
182 | int local_time; | 184 | int local_time; |
183 | int max_repo_count; | 185 | int max_repo_count; |
184 | int max_commit_count; | 186 | int max_commit_count; |
185 | int max_lock_attempts; | 187 | int max_lock_attempts; |
186 | int max_msg_len; | 188 | int max_msg_len; |
187 | int max_repodesc_len; | 189 | int max_repodesc_len; |
188 | int max_stats; | 190 | int max_stats; |
189 | int nocache; | 191 | int nocache; |
190 | int noplainemail; | 192 | int noplainemail; |
191 | int noheader; | 193 | int noheader; |
192 | int renamelimit; | 194 | int renamelimit; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0c13485..0bb429a 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -101,24 +101,29 @@ enable-index-links:: | |||
101 | "commit" and "tree" pages). Default value: "0". | 101 | "commit" and "tree" pages). Default value: "0". |
102 | 102 | ||
103 | enable-log-filecount:: | 103 | enable-log-filecount:: |
104 | Flag which, when set to "1", will make cgit print the number of | 104 | Flag which, when set to "1", will make cgit print the number of |
105 | modified files for each commit on the repository log page. Default | 105 | modified files for each commit on the repository log page. Default |
106 | value: "0". | 106 | value: "0". |
107 | 107 | ||
108 | enable-log-linecount:: | 108 | enable-log-linecount:: |
109 | Flag which, when set to "1", will make cgit print the number of added | 109 | Flag which, when set to "1", will make cgit print the number of added |
110 | and removed lines for each commit on the repository log page. Default | 110 | and removed lines for each commit on the repository log page. Default |
111 | value: "0". | 111 | value: "0". |
112 | 112 | ||
113 | enable-remote-branches:: | ||
114 | Flag which, when set to "1", will make cgit display remote branches | ||
115 | in the summary and refs views. Default value: "0". See also: | ||
116 | "repo.enable-remote-branches". | ||
117 | |||
113 | enable-tree-linenumbers:: | 118 | enable-tree-linenumbers:: |
114 | Flag which, when set to "1", will make cgit generate linenumber links | 119 | Flag which, when set to "1", will make cgit generate linenumber links |
115 | for plaintext blobs printed in the tree view. Default value: "1". | 120 | for plaintext blobs printed in the tree view. Default value: "1". |
116 | 121 | ||
117 | favicon:: | 122 | favicon:: |
118 | Url used as link to a shortcut icon for cgit. If specified, it is | 123 | Url used as link to a shortcut icon for cgit. If specified, it is |
119 | suggested to use the value "/favicon.ico" since certain browsers will | 124 | suggested to use the value "/favicon.ico" since certain browsers will |
120 | ignore other values. Default value: none. | 125 | ignore other values. Default value: none. |
121 | 126 | ||
122 | footer:: | 127 | footer:: |
123 | The content of the file specified with this option will be included | 128 | The content of the file specified with this option will be included |
124 | verbatim at the bottom of all pages (i.e. it replaces the standard | 129 | verbatim at the bottom of all pages (i.e. it replaces the standard |
@@ -295,24 +300,28 @@ repo.defbranch:: | |||
295 | 300 | ||
296 | repo.desc:: | 301 | repo.desc:: |
297 | The value to show as repository description. Default value: none. | 302 | The value to show as repository description. Default value: none. |
298 | 303 | ||
299 | repo.enable-log-filecount:: | 304 | repo.enable-log-filecount:: |
300 | A flag which can be used to disable the global setting | 305 | A flag which can be used to disable the global setting |
301 | `enable-log-filecount'. Default value: none. | 306 | `enable-log-filecount'. Default value: none. |
302 | 307 | ||
303 | repo.enable-log-linecount:: | 308 | repo.enable-log-linecount:: |
304 | A flag which can be used to disable the global setting | 309 | A flag which can be used to disable the global setting |
305 | `enable-log-linecount'. Default value: none. | 310 | `enable-log-linecount'. Default value: none. |
306 | 311 | ||
312 | repo.enable-remote-branches:: | ||
313 | Flag which, when set to "1", will make cgit display remote branches | ||
314 | in the summary and refs views. Default value: <enable-remote-branches>. | ||
315 | |||
307 | repo.max-stats:: | 316 | repo.max-stats:: |
308 | Override the default maximum statistics period. Valid values are equal | 317 | Override the default maximum statistics period. Valid values are equal |
309 | to the values specified for the global "max-stats" setting. Default | 318 | to the values specified for the global "max-stats" setting. Default |
310 | value: none. | 319 | value: none. |
311 | 320 | ||
312 | repo.name:: | 321 | repo.name:: |
313 | The value to show as repository name. Default value: <repo.url>. | 322 | The value to show as repository name. Default value: <repo.url>. |
314 | 323 | ||
315 | repo.owner:: | 324 | repo.owner:: |
316 | A value used to identify the owner of the repository. Default value: | 325 | A value used to identify the owner of the repository. Default value: |
317 | none. | 326 | none. |
318 | 327 | ||
@@ -50,24 +50,25 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
50 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | 50 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
51 | memset(ret, 0, sizeof(struct cgit_repo)); | 51 | memset(ret, 0, sizeof(struct cgit_repo)); |
52 | ret->url = trim_end(url, '/'); | 52 | ret->url = trim_end(url, '/'); |
53 | ret->name = ret->url; | 53 | ret->name = ret->url; |
54 | ret->path = NULL; | 54 | ret->path = NULL; |
55 | ret->desc = "[no description]"; | 55 | ret->desc = "[no description]"; |
56 | ret->owner = NULL; | 56 | ret->owner = NULL; |
57 | ret->section = ctx.cfg.section; | 57 | ret->section = ctx.cfg.section; |
58 | ret->defbranch = "master"; | 58 | ret->defbranch = "master"; |
59 | ret->snapshots = ctx.cfg.snapshots; | 59 | ret->snapshots = ctx.cfg.snapshots; |
60 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; | 60 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; |
61 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; | 61 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; |
62 | ret->enable_remote_branches = ctx.cfg.enable_remote_branches; | ||
62 | ret->max_stats = ctx.cfg.max_stats; | 63 | ret->max_stats = ctx.cfg.max_stats; |
63 | ret->module_link = ctx.cfg.module_link; | 64 | ret->module_link = ctx.cfg.module_link; |
64 | ret->readme = NULL; | 65 | ret->readme = NULL; |
65 | ret->mtime = -1; | 66 | ret->mtime = -1; |
66 | ret->about_filter = ctx.cfg.about_filter; | 67 | ret->about_filter = ctx.cfg.about_filter; |
67 | ret->commit_filter = ctx.cfg.commit_filter; | 68 | ret->commit_filter = ctx.cfg.commit_filter; |
68 | ret->source_filter = ctx.cfg.source_filter; | 69 | ret->source_filter = ctx.cfg.source_filter; |
69 | return ret; | 70 | return ret; |
70 | } | 71 | } |
71 | 72 | ||
72 | struct cgit_repo *cgit_get_repoinfo(const char *url) | 73 | struct cgit_repo *cgit_get_repoinfo(const char *url) |
73 | { | 74 | { |
@@ -178,24 +178,26 @@ void cgit_print_branches(int maxcount) | |||
178 | { | 178 | { |
179 | struct reflist list; | 179 | struct reflist list; |
180 | int i; | 180 | int i; |
181 | 181 | ||
182 | html("<tr class='nohover'><th class='left'>Branch</th>" | 182 | html("<tr class='nohover'><th class='left'>Branch</th>" |
183 | "<th class='left'>Commit message</th>" | 183 | "<th class='left'>Commit message</th>" |
184 | "<th class='left'>Author</th>" | 184 | "<th class='left'>Author</th>" |
185 | "<th class='left' colspan='2'>Age</th></tr>\n"); | 185 | "<th class='left' colspan='2'>Age</th></tr>\n"); |
186 | 186 | ||
187 | list.refs = NULL; | 187 | list.refs = NULL; |
188 | list.alloc = list.count = 0; | 188 | list.alloc = list.count = 0; |
189 | for_each_branch_ref(cgit_refs_cb, &list); | 189 | for_each_branch_ref(cgit_refs_cb, &list); |
190 | if (ctx.repo->enable_remote_branches) | ||
191 | for_each_remote_ref(cgit_refs_cb, &list); | ||
190 | 192 | ||
191 | if (maxcount == 0 || maxcount > list.count) | 193 | if (maxcount == 0 || maxcount > list.count) |
192 | maxcount = list.count; | 194 | maxcount = list.count; |
193 | 195 | ||
194 | if (maxcount < list.count) { | 196 | if (maxcount < list.count) { |
195 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); | 197 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); |
196 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | 198 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); |
197 | } | 199 | } |
198 | 200 | ||
199 | for(i=0; i<maxcount; i++) | 201 | for(i=0; i<maxcount; i++) |
200 | print_branch(list.refs[i]); | 202 | print_branch(list.refs[i]); |
201 | 203 | ||