diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | cgit.c | 17 | ||||
| -rw-r--r-- | cgit.css | 15 | ||||
| -rw-r--r-- | cgit.h | 8 | ||||
| -rw-r--r-- | cgitrc.5.txt | 16 | ||||
| -rw-r--r-- | cmd.c | 48 | ||||
| -rw-r--r-- | cmd.h | 3 | ||||
| -rw-r--r-- | parsing.c | 4 | ||||
| -rw-r--r-- | scan-tree.c | 2 | ||||
| -rw-r--r-- | shared.c | 15 | ||||
| -rw-r--r-- | ui-atom.c | 4 | ||||
| -rw-r--r-- | ui-commit.c | 30 | ||||
| -rw-r--r-- | ui-commit.h | 2 | ||||
| -rw-r--r-- | ui-diff.c | 22 | ||||
| -rw-r--r-- | ui-log.c | 40 | ||||
| -rw-r--r-- | ui-patch.c | 8 | ||||
| -rw-r--r-- | ui-patch.h | 2 | ||||
| -rw-r--r-- | ui-plain.c | 68 | ||||
| -rw-r--r-- | ui-refs.c | 2 | ||||
| -rw-r--r-- | ui-shared.c | 231 | ||||
| -rw-r--r-- | ui-shared.h | 72 | ||||
| -rw-r--r-- | ui-tree.c | 15 |
22 files changed, 435 insertions, 191 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | CGIT_VERSION = v0.8.3.1 | 1 | CGIT_VERSION = v0.8.3.2 |
| 2 | CGIT_SCRIPT_NAME = cgit.cgi | 2 | CGIT_SCRIPT_NAME = cgit.cgi |
| 3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | 3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
| 4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) | 4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) |
| @@ -62,6 +62,8 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
| 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")) | 63 | else if (!strcmp(name, "enable-remote-branches")) |
| 64 | repo->enable_remote_branches = atoi(value); | 64 | repo->enable_remote_branches = atoi(value); |
| 65 | else if (!strcmp(name, "enable-subject-links")) | ||
| 66 | repo->enable_subject_links = atoi(value); | ||
| 65 | else if (!strcmp(name, "max-stats")) | 67 | else if (!strcmp(name, "max-stats")) |
| 66 | repo->max_stats = cgit_find_stats_period(value, NULL); | 68 | repo->max_stats = cgit_find_stats_period(value, NULL); |
| 67 | else if (!strcmp(name, "module-link")) | 69 | else if (!strcmp(name, "module-link")) |
| @@ -141,6 +143,8 @@ void config_cb(const char *name, const char *value) | |||
| 141 | ctx.cfg.enable_log_linecount = atoi(value); | 143 | ctx.cfg.enable_log_linecount = atoi(value); |
| 142 | else if (!strcmp(name, "enable-remote-branches")) | 144 | else if (!strcmp(name, "enable-remote-branches")) |
| 143 | ctx.cfg.enable_remote_branches = atoi(value); | 145 | ctx.cfg.enable_remote_branches = atoi(value); |
| 146 | else if (!strcmp(name, "enable-subject-links")) | ||
| 147 | ctx.cfg.enable_subject_links = atoi(value); | ||
| 144 | else if (!strcmp(name, "enable-tree-linenumbers")) | 148 | else if (!strcmp(name, "enable-tree-linenumbers")) |
| 145 | ctx.cfg.enable_tree_linenumbers = atoi(value); | 149 | ctx.cfg.enable_tree_linenumbers = atoi(value); |
| 146 | else if (!strcmp(name, "max-stats")) | 150 | else if (!strcmp(name, "max-stats")) |
| @@ -165,6 +169,8 @@ void config_cb(const char *name, const char *value) | |||
| 165 | ctx.cfg.commit_filter = new_filter(value, 0); | 169 | ctx.cfg.commit_filter = new_filter(value, 0); |
| 166 | else if (!strcmp(name, "embedded")) | 170 | else if (!strcmp(name, "embedded")) |
| 167 | ctx.cfg.embedded = atoi(value); | 171 | ctx.cfg.embedded = atoi(value); |
| 172 | else if (!strcmp(name, "max-atom-items")) | ||
| 173 | ctx.cfg.max_atom_items = atoi(value); | ||
| 168 | else if (!strcmp(name, "max-message-length")) | 174 | else if (!strcmp(name, "max-message-length")) |
| 169 | ctx.cfg.max_msg_len = atoi(value); | 175 | ctx.cfg.max_msg_len = atoi(value); |
| 170 | else if (!strcmp(name, "max-repodesc-length")) | 176 | else if (!strcmp(name, "max-repodesc-length")) |
| @@ -250,6 +256,10 @@ static void querystring_cb(const char *name, const char *value) | |||
| 250 | ctx.qry.period = xstrdup(value); | 256 | ctx.qry.period = xstrdup(value); |
| 251 | } else if (!strcmp(name, "ss")) { | 257 | } else if (!strcmp(name, "ss")) { |
| 252 | ctx.qry.ssdiff = atoi(value); | 258 | ctx.qry.ssdiff = atoi(value); |
| 259 | } else if (!strcmp(name, "all")) { | ||
| 260 | ctx.qry.show_all = atoi(value); | ||
| 261 | } else if (!strcmp(name, "context")) { | ||
| 262 | ctx.qry.context = atoi(value); | ||
| 253 | } | 263 | } |
| 254 | } | 264 | } |
| 255 | 265 | ||
| @@ -292,6 +302,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
| 292 | ctx->cfg.summary_branches = 10; | 302 | ctx->cfg.summary_branches = 10; |
| 293 | ctx->cfg.summary_log = 10; | 303 | ctx->cfg.summary_log = 10; |
| 294 | ctx->cfg.summary_tags = 10; | 304 | ctx->cfg.summary_tags = 10; |
| 305 | ctx->cfg.max_atom_items = 10; | ||
| 295 | ctx->cfg.ssdiff = 0; | 306 | ctx->cfg.ssdiff = 0; |
| 296 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); | 307 | ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); |
| 297 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); | 308 | ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); |
| @@ -424,6 +435,12 @@ static void process_request(void *cbdata) | |||
| 424 | return; | 435 | return; |
| 425 | } | 436 | } |
| 426 | 437 | ||
| 438 | /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" | ||
| 439 | * in-project path limit to be made available at ctx->qry.vpath. | ||
| 440 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). | ||
| 441 | */ | ||
| 442 | ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL; | ||
| 443 | |||
| 427 | if (cmd->want_repo && !ctx->repo) { | 444 | if (cmd->want_repo && !ctx->repo) { |
| 428 | cgit_print_http_headers(ctx); | 445 | cgit_print_http_headers(ctx); |
| 429 | cgit_print_docstart(ctx); | 446 | cgit_print_docstart(ctx); |
| @@ -64,7 +64,7 @@ table#header td.sub { | |||
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | table.tabs { | 66 | table.tabs { |
| 67 | /* border-bottom: solid 2px #ccc; */ | 67 | border-bottom: solid 3px #ccc; |
| 68 | border-collapse: collapse; | 68 | border-collapse: collapse; |
| 69 | margin-top: 2em; | 69 | margin-top: 2em; |
| 70 | margin-bottom: 0px; | 70 | margin-bottom: 0px; |
| @@ -102,10 +102,16 @@ table.tabs td.form select { | |||
| 102 | font-size: 90%; | 102 | font-size: 90%; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | div.path { | ||
| 106 | margin: 0px; | ||
| 107 | padding: 5px 2em 2px 2em; | ||
| 108 | color: #000; | ||
| 109 | background-color: #eee; | ||
| 110 | } | ||
| 111 | |||
| 105 | div.content { | 112 | div.content { |
| 106 | margin: 0px; | 113 | margin: 0px; |
| 107 | padding: 2em; | 114 | padding: 2em; |
| 108 | border-top: solid 3px #ccc; | ||
| 109 | border-bottom: solid 3px #ccc; | 115 | border-bottom: solid 3px #ccc; |
| 110 | } | 116 | } |
| 111 | 117 | ||
| @@ -525,7 +531,10 @@ a.deco { | |||
| 525 | border: solid 1px #770000; | 531 | border: solid 1px #770000; |
| 526 | } | 532 | } |
| 527 | 533 | ||
| 528 | div.commit-subject a { | 534 | div.commit-subject a.branch-deco, |
| 535 | div.commit-subject a.tag-deco, | ||
| 536 | div.commit-subject a.remote-deco, | ||
| 537 | div.commit-subject a.deco { | ||
| 529 | margin-left: 1em; | 538 | margin-left: 1em; |
| 530 | font-size: 75%; | 539 | font-size: 75%; |
| 531 | } | 540 | } |
| @@ -73,6 +73,7 @@ struct cgit_repo { | |||
| 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 enable_remote_branches; |
| 76 | int enable_subject_links; | ||
| 76 | int max_stats; | 77 | int max_stats; |
| 77 | time_t mtime; | 78 | time_t mtime; |
| 78 | struct cgit_filter *about_filter; | 79 | struct cgit_filter *about_filter; |
| @@ -145,6 +146,9 @@ struct cgit_query { | |||
| 145 | char *sort; | 146 | char *sort; |
| 146 | int showmsg; | 147 | int showmsg; |
| 147 | int ssdiff; | 148 | int ssdiff; |
| 149 | int show_all; | ||
| 150 | int context; | ||
| 151 | char *vpath; | ||
| 148 | }; | 152 | }; |
| 149 | 153 | ||
| 150 | struct cgit_config { | 154 | struct cgit_config { |
| @@ -181,8 +185,10 @@ struct cgit_config { | |||
| 181 | int enable_log_filecount; | 185 | int enable_log_filecount; |
| 182 | int enable_log_linecount; | 186 | int enable_log_linecount; |
| 183 | int enable_remote_branches; | 187 | int enable_remote_branches; |
| 188 | int enable_subject_links; | ||
| 184 | int enable_tree_linenumbers; | 189 | int enable_tree_linenumbers; |
| 185 | int local_time; | 190 | int local_time; |
| 191 | int max_atom_items; | ||
| 186 | int max_repo_count; | 192 | int max_repo_count; |
| 187 | int max_commit_count; | 193 | int max_commit_count; |
| 188 | int max_lock_attempts; | 194 | int max_lock_attempts; |
| @@ -273,7 +279,7 @@ extern void *cgit_free_commitinfo(struct commitinfo *info); | |||
| 273 | extern int cgit_diff_files(const unsigned char *old_sha1, | 279 | extern int cgit_diff_files(const unsigned char *old_sha1, |
| 274 | const unsigned char *new_sha1, | 280 | const unsigned char *new_sha1, |
| 275 | unsigned long *old_size, unsigned long *new_size, | 281 | unsigned long *old_size, unsigned long *new_size, |
| 276 | int *binary, linediff_fn fn); | 282 | int *binary, int context, linediff_fn fn); |
| 277 | 283 | ||
| 278 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 284 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
| 279 | const unsigned char *new_sha1, | 285 | const unsigned char *new_sha1, |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index d74d9e7..a853522 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
| @@ -115,6 +115,12 @@ enable-remote-branches:: | |||
| 115 | in the summary and refs views. Default value: "0". See also: | 115 | in the summary and refs views. Default value: "0". See also: |
| 116 | "repo.enable-remote-branches". | 116 | "repo.enable-remote-branches". |
| 117 | 117 | ||
| 118 | enable-subject-links:: | ||
| 119 | Flag which, when set to "1", will make cgit use the subject of the | ||
| 120 | parent commit as link text when generating links to parent commits | ||
| 121 | in commit view. Default value: "0". See also: | ||
| 122 | "repo.enable-subject-links". | ||
| 123 | |||
| 118 | enable-tree-linenumbers:: | 124 | enable-tree-linenumbers:: |
| 119 | Flag which, when set to "1", will make cgit generate linenumber links | 125 | Flag which, when set to "1", will make cgit generate linenumber links |
| 120 | for plaintext blobs printed in the tree view. Default value: "1". | 126 | for plaintext blobs printed in the tree view. Default value: "1". |
| @@ -166,6 +172,10 @@ logo-link:: | |||
| 166 | calculated url of the repository index page will be used. Default | 172 | calculated url of the repository index page will be used. Default |
| 167 | value: none. | 173 | value: none. |
| 168 | 174 | ||
| 175 | max-atom-items:: | ||
| 176 | Specifies the number of items to display in atom feeds view. Default | ||
| 177 | value: "10". | ||
| 178 | |||
| 169 | max-commit-count:: | 179 | max-commit-count:: |
| 170 | Specifies the number of entries to list per page in "log" view. Default | 180 | Specifies the number of entries to list per page in "log" view. Default |
| 171 | value: "50". | 181 | value: "50". |
| @@ -321,6 +331,10 @@ repo.enable-remote-branches:: | |||
| 321 | Flag which, when set to "1", will make cgit display remote branches | 331 | Flag which, when set to "1", will make cgit display remote branches |
| 322 | in the summary and refs views. Default value: <enable-remote-branches>. | 332 | in the summary and refs views. Default value: <enable-remote-branches>. |
| 323 | 333 | ||
| 334 | repo.enable-subject-links:: | ||
| 335 | A flag which can be used to override the global setting | ||
| 336 | `enable-subject-links'. Default value: none. | ||
| 337 | |||
| 324 | repo.max-stats:: | 338 | repo.max-stats:: |
| 325 | Override the default maximum statistics period. Valid values are equal | 339 | Override the default maximum statistics period. Valid values are equal |
| 326 | to the values specified for the global "max-stats" setting. Default | 340 | to the values specified for the global "max-stats" setting. Default |
| @@ -430,7 +444,7 @@ snapshots=tar.gz tar.bz2 zip | |||
| 430 | ## List of common mimetypes | 444 | ## List of common mimetypes |
| 431 | ## | 445 | ## |
| 432 | 446 | ||
| 433 | mimetype.git=image/git | 447 | mimetype.gif=image/gif |
| 434 | mimetype.html=text/html | 448 | mimetype.html=text/html |
| 435 | mimetype.jpg=image/jpeg | 449 | mimetype.jpg=image/jpeg |
| 436 | mimetype.jpeg=image/jpeg | 450 | mimetype.jpeg=image/jpeg |
| @@ -33,7 +33,7 @@ static void HEAD_fn(struct cgit_context *ctx) | |||
| 33 | 33 | ||
| 34 | static void atom_fn(struct cgit_context *ctx) | 34 | static void atom_fn(struct cgit_context *ctx) |
| 35 | { | 35 | { |
| 36 | cgit_print_atom(ctx->qry.head, ctx->qry.path, 10); | 36 | cgit_print_atom(ctx->qry.head, ctx->qry.path, ctx->cfg.max_atom_items); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | static void about_fn(struct cgit_context *ctx) | 39 | static void about_fn(struct cgit_context *ctx) |
| @@ -51,7 +51,7 @@ static void blob_fn(struct cgit_context *ctx) | |||
| 51 | 51 | ||
| 52 | static void commit_fn(struct cgit_context *ctx) | 52 | static void commit_fn(struct cgit_context *ctx) |
| 53 | { | 53 | { |
| 54 | cgit_print_commit(ctx->qry.sha1); | 54 | cgit_print_commit(ctx->qry.sha1, ctx->qry.path); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | static void diff_fn(struct cgit_context *ctx) | 57 | static void diff_fn(struct cgit_context *ctx) |
| @@ -90,7 +90,7 @@ static void repolist_fn(struct cgit_context *ctx) | |||
| 90 | 90 | ||
| 91 | static void patch_fn(struct cgit_context *ctx) | 91 | static void patch_fn(struct cgit_context *ctx) |
| 92 | { | 92 | { |
| 93 | cgit_print_patch(ctx->qry.sha1); | 93 | cgit_print_patch(ctx->qry.sha1, ctx->qry.path); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static void plain_fn(struct cgit_context *ctx) | 96 | static void plain_fn(struct cgit_context *ctx) |
| @@ -129,31 +129,31 @@ static void tree_fn(struct cgit_context *ctx) | |||
| 129 | cgit_print_tree(ctx->qry.sha1, ctx->qry.path); | 129 | cgit_print_tree(ctx->qry.sha1, ctx->qry.path); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | #define def_cmd(name, want_repo, want_layout) \ | 132 | #define def_cmd(name, want_repo, want_layout, want_vpath) \ |
| 133 | {#name, name##_fn, want_repo, want_layout} | 133 | {#name, name##_fn, want_repo, want_layout, want_vpath} |
| 134 | 134 | ||
| 135 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) | 135 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) |
| 136 | { | 136 | { |
| 137 | static struct cgit_cmd cmds[] = { | 137 | static struct cgit_cmd cmds[] = { |
| 138 | def_cmd(HEAD, 1, 0), | 138 | def_cmd(HEAD, 1, 0, 0), |
| 139 | def_cmd(atom, 1, 0), | 139 | def_cmd(atom, 1, 0, 0), |
| 140 | def_cmd(about, 0, 1), | 140 | def_cmd(about, 0, 1, 0), |
| 141 | def_cmd(blob, 1, 0), | 141 | def_cmd(blob, 1, 0, 0), |
| 142 | def_cmd(commit, 1, 1), | 142 | def_cmd(commit, 1, 1, 1), |
| 143 | def_cmd(diff, 1, 1), | 143 | def_cmd(diff, 1, 1, 1), |
| 144 | def_cmd(info, 1, 0), | 144 | def_cmd(info, 1, 0, 0), |
| 145 | def_cmd(log, 1, 1), | 145 | def_cmd(log, 1, 1, 1), |
| 146 | def_cmd(ls_cache, 0, 0), | 146 | def_cmd(ls_cache, 0, 0, 0), |
| 147 | def_cmd(objects, 1, 0), | 147 | def_cmd(objects, 1, 0, 0), |
| 148 | def_cmd(patch, 1, 0), | 148 | def_cmd(patch, 1, 0, 1), |
| 149 | def_cmd(plain, 1, 0), | 149 | def_cmd(plain, 1, 0, 0), |
| 150 | def_cmd(refs, 1, 1), | 150 | def_cmd(refs, 1, 1, 0), |
| 151 | def_cmd(repolist, 0, 0), | 151 | def_cmd(repolist, 0, 0, 0), |
| 152 | def_cmd(snapshot, 1, 0), | 152 | def_cmd(snapshot, 1, 0, 0), |
| 153 | def_cmd(stats, 1, 1), | 153 | def_cmd(stats, 1, 1, 1), |
| 154 | def_cmd(summary, 1, 1), | 154 | def_cmd(summary, 1, 1, 0), |
| 155 | def_cmd(tag, 1, 1), | 155 | def_cmd(tag, 1, 1, 0), |
| 156 | def_cmd(tree, 1, 1), | 156 | def_cmd(tree, 1, 1, 1), |
| 157 | }; | 157 | }; |
| 158 | int i; | 158 | int i; |
| 159 | 159 | ||
| @@ -7,7 +7,8 @@ struct cgit_cmd { | |||
| 7 | const char *name; | 7 | const char *name; |
| 8 | cgit_cmd_fn fn; | 8 | cgit_cmd_fn fn; |
| 9 | unsigned int want_repo:1, | 9 | unsigned int want_repo:1, |
| 10 | want_layout:1; | 10 | want_layout:1, |
| 11 | want_vpath:1; | ||
| 11 | }; | 12 | }; |
| 12 | 13 | ||
| 13 | extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx); | 14 | extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx); |
| @@ -190,6 +190,10 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) | |||
| 190 | ret->subject = xstrdup(p); | 190 | ret->subject = xstrdup(p); |
| 191 | 191 | ||
| 192 | if (ret->msg_encoding) { | 192 | if (ret->msg_encoding) { |
| 193 | reencode(&ret->author, PAGE_ENCODING, ret->msg_encoding); | ||
| 194 | reencode(&ret->author_email, PAGE_ENCODING, ret->msg_encoding); | ||
| 195 | reencode(&ret->committer, PAGE_ENCODING, ret->msg_encoding); | ||
| 196 | reencode(&ret->committer_email, PAGE_ENCODING, ret->msg_encoding); | ||
| 193 | reencode(&ret->subject, PAGE_ENCODING, ret->msg_encoding); | 197 | reencode(&ret->subject, PAGE_ENCODING, ret->msg_encoding); |
| 194 | reencode(&ret->msg, PAGE_ENCODING, ret->msg_encoding); | 198 | reencode(&ret->msg, PAGE_ENCODING, ret->msg_encoding); |
| 195 | } | 199 | } |
diff --git a/scan-tree.c b/scan-tree.c index dbca797..1e18f3c 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
| @@ -56,6 +56,8 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
| 56 | path, strerror(errno), errno); | 56 | path, strerror(errno), errno); |
| 57 | return; | 57 | return; |
| 58 | } | 58 | } |
| 59 | if (!stat(fmt("%s/noweb", path), &st)) | ||
| 60 | return; | ||
| 59 | if ((pwd = getpwuid(st.st_uid)) == NULL) { | 61 | if ((pwd = getpwuid(st.st_uid)) == NULL) { |
| 60 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", | 62 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", |
| 61 | path, strerror(errno), errno); | 63 | path, strerror(errno), errno); |
| @@ -10,7 +10,6 @@ | |||
| 10 | 10 | ||
| 11 | struct cgit_repolist cgit_repolist; | 11 | struct cgit_repolist cgit_repolist; |
| 12 | struct cgit_context ctx; | 12 | struct cgit_context ctx; |
| 13 | int cgit_cmd; | ||
| 14 | 13 | ||
| 15 | int chk_zero(int result, char *msg) | 14 | int chk_zero(int result, char *msg) |
| 16 | { | 15 | { |
| @@ -60,6 +59,7 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
| 60 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; | 59 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; |
| 61 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; | 60 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; |
| 62 | ret->enable_remote_branches = ctx.cfg.enable_remote_branches; | 61 | ret->enable_remote_branches = ctx.cfg.enable_remote_branches; |
| 62 | ret->enable_subject_links = ctx.cfg.enable_subject_links; | ||
| 63 | ret->max_stats = ctx.cfg.max_stats; | 63 | ret->max_stats = ctx.cfg.max_stats; |
| 64 | ret->module_link = ctx.cfg.module_link; | 64 | ret->module_link = ctx.cfg.module_link; |
| 65 | ret->readme = NULL; | 65 | ret->readme = NULL; |
| @@ -263,7 +263,8 @@ int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) | |||
| 263 | 263 | ||
| 264 | int cgit_diff_files(const unsigned char *old_sha1, | 264 | int cgit_diff_files(const unsigned char *old_sha1, |
| 265 | const unsigned char *new_sha1, unsigned long *old_size, | 265 | const unsigned char *new_sha1, unsigned long *old_size, |
| 266 | unsigned long *new_size, int *binary, linediff_fn fn) | 266 | unsigned long *new_size, int *binary, int context, |
| 267 | linediff_fn fn) | ||
| 267 | { | 268 | { |
| 268 | mmfile_t file1, file2; | 269 | mmfile_t file1, file2; |
| 269 | xpparam_t diff_params; | 270 | xpparam_t diff_params; |
| @@ -279,6 +280,10 @@ int cgit_diff_files(const unsigned char *old_sha1, | |||
| 279 | if ((file1.ptr && buffer_is_binary(file1.ptr, file1.size)) || | 280 | if ((file1.ptr && buffer_is_binary(file1.ptr, file1.size)) || |
| 280 | (file2.ptr && buffer_is_binary(file2.ptr, file2.size))) { | 281 | (file2.ptr && buffer_is_binary(file2.ptr, file2.size))) { |
| 281 | *binary = 1; | 282 | *binary = 1; |
| 283 | if (file1.size) | ||
| 284 | free(file1.ptr); | ||
| 285 | if (file2.size) | ||
| 286 | free(file2.ptr); | ||
| 282 | return 0; | 287 | return 0; |
| 283 | } | 288 | } |
| 284 | 289 | ||
| @@ -286,11 +291,15 @@ int cgit_diff_files(const unsigned char *old_sha1, | |||
| 286 | memset(&emit_params, 0, sizeof(emit_params)); | 291 | memset(&emit_params, 0, sizeof(emit_params)); |
| 287 | memset(&emit_cb, 0, sizeof(emit_cb)); | 292 | memset(&emit_cb, 0, sizeof(emit_cb)); |
| 288 | diff_params.flags = XDF_NEED_MINIMAL; | 293 | diff_params.flags = XDF_NEED_MINIMAL; |
| 289 | emit_params.ctxlen = 3; | 294 | emit_params.ctxlen = context > 0 ? context : 3; |
| 290 | emit_params.flags = XDL_EMIT_FUNCNAMES; | 295 | emit_params.flags = XDL_EMIT_FUNCNAMES; |
| 291 | emit_cb.outf = filediff_cb; | 296 | emit_cb.outf = filediff_cb; |
| 292 | emit_cb.priv = fn; | 297 | emit_cb.priv = fn; |
| 293 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); | 298 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); |
| 299 | if (file1.size) | ||
| 300 | free(file1.ptr); | ||
| 301 | if (file2.size) | ||
| 302 | free(file2.ptr); | ||
| 294 | return 0; | 303 | return 0; |
| 295 | } | 304 | } |
| 296 | 305 | ||
| @@ -85,7 +85,9 @@ void cgit_print_atom(char *tip, char *path, int max_count) | |||
| 85 | struct rev_info rev; | 85 | struct rev_info rev; |
| 86 | int argc = 2; | 86 | int argc = 2; |
| 87 | 87 | ||
| 88 | if (!tip) | 88 | if (ctx.qry.show_all) |
| 89 | argv[1] = "--all"; | ||
| 90 | else if (!tip) | ||
| 89 | argv[1] = ctx.qry.head; | 91 | argv[1] = ctx.qry.head; |
| 90 | 92 | ||
| 91 | if (path) { | 93 | if (path) { |
diff --git a/ui-commit.c b/ui-commit.c index b5e3c01..a11bc5f 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
| @@ -12,13 +12,13 @@ | |||
| 12 | #include "ui-diff.h" | 12 | #include "ui-diff.h" |
| 13 | #include "ui-log.h" | 13 | #include "ui-log.h" |
| 14 | 14 | ||
| 15 | void cgit_print_commit(char *hex) | 15 | void cgit_print_commit(char *hex, const char *prefix) |
| 16 | { | 16 | { |
| 17 | struct commit *commit, *parent; | 17 | struct commit *commit, *parent; |
| 18 | struct commitinfo *info; | 18 | struct commitinfo *info, *parent_info; |
| 19 | struct commit_list *p; | 19 | struct commit_list *p; |
| 20 | unsigned char sha1[20]; | 20 | unsigned char sha1[20]; |
| 21 | char *tmp; | 21 | char *tmp, *tmp2; |
| 22 | int parents = 0; | 22 | int parents = 0; |
| 23 | 23 | ||
| 24 | if (!hex) | 24 | if (!hex) |
| @@ -58,19 +58,23 @@ void cgit_print_commit(char *hex) | |||
| 58 | html("</td></tr>\n"); | 58 | html("</td></tr>\n"); |
| 59 | html("<tr><th>commit</th><td colspan='2' class='sha1'>"); | 59 | html("<tr><th>commit</th><td colspan='2' class='sha1'>"); |
| 60 | tmp = sha1_to_hex(commit->object.sha1); | 60 | tmp = sha1_to_hex(commit->object.sha1); |
| 61 | cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0); | 61 | cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0); |
| 62 | html(" ("); | 62 | html(" ("); |
| 63 | cgit_patch_link("patch", NULL, NULL, NULL, tmp); | 63 | cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix); |
| 64 | html(") ("); | 64 | html(") ("); |
| 65 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) | 65 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) |
| 66 | cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, 1); | 66 | cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); |
| 67 | else | 67 | else |
| 68 | cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1); | 68 | cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); |
| 69 | html(")</td></tr>\n"); | 69 | html(")</td></tr>\n"); |
| 70 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); | 70 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); |
| 71 | tmp = xstrdup(hex); | 71 | tmp = xstrdup(hex); |
| 72 | cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, | 72 | cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, |
| 73 | ctx.qry.head, tmp, NULL); | 73 | ctx.qry.head, tmp, NULL); |
| 74 | if (prefix) { | ||
| 75 | html(" /"); | ||
| 76 | cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); | ||
| 77 | } | ||
| 74 | html("</td></tr>\n"); | 78 | html("</td></tr>\n"); |
| 75 | for (p = commit->parents; p ; p = p->next) { | 79 | for (p = commit->parents; p ; p = p->next) { |
| 76 | parent = lookup_commit_reference(p->item->object.sha1); | 80 | parent = lookup_commit_reference(p->item->object.sha1); |
| @@ -82,11 +86,15 @@ void cgit_print_commit(char *hex) | |||
| 82 | } | 86 | } |
| 83 | html("<tr><th>parent</th>" | 87 | html("<tr><th>parent</th>" |
| 84 | "<td colspan='2' class='sha1'>"); | 88 | "<td colspan='2' class='sha1'>"); |
| 85 | cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, | 89 | tmp = tmp2 = sha1_to_hex(p->item->object.sha1); |
| 86 | ctx.qry.head, sha1_to_hex(p->item->object.sha1), 0); | 90 | if (ctx.repo->enable_subject_links) { |
| 91 | parent_info = cgit_parse_commit(parent); | ||
| 92 | tmp2 = parent_info->subject; | ||
| 93 | } | ||
| 94 | cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0); | ||
| 87 | html(" ("); | 95 | html(" ("); |
| 88 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, | 96 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, |
| 89 | sha1_to_hex(p->item->object.sha1), NULL, 0); | 97 | sha1_to_hex(p->item->object.sha1), prefix, 0); |
| 90 | html(")</td></tr>"); | 98 | html(")</td></tr>"); |
| 91 | parents++; | 99 | parents++; |
| 92 | } | 100 | } |
| @@ -117,7 +125,7 @@ void cgit_print_commit(char *hex) | |||
| 117 | tmp = sha1_to_hex(commit->parents->item->object.sha1); | 125 | tmp = sha1_to_hex(commit->parents->item->object.sha1); |
| 118 | else | 126 | else |
| 119 | tmp = NULL; | 127 | tmp = NULL; |
| 120 | cgit_print_diff(ctx.qry.sha1, tmp, NULL); | 128 | cgit_print_diff(ctx.qry.sha1, tmp, prefix); |
| 121 | } | 129 | } |
| 122 | cgit_free_commitinfo(info); | ||
