summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2010-06-22 14:16:12 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-06-22 14:16:12 (UTC)
commit6f92f332e6a9ee3e16051bda9fe148607af67f65 (patch) (unidiff)
tree49cb7d145fbf40793b220efdc92cd80ab2c6ca05
parent37a24e4e39737edaa5cdde501346a65eeb280e63 (diff)
parentd20313e3daf855ee5d4808e050f54614c200d7b1 (diff)
downloadcgit-6f92f332e6a9ee3e16051bda9fe148607af67f65.zip
cgit-6f92f332e6a9ee3e16051bda9fe148607af67f65.tar.gz
cgit-6f92f332e6a9ee3e16051bda9fe148607af67f65.tar.bz2
Merge branch 'jh/context-lines'
Conflicts: cgit.c cgit.h
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h3
-rw-r--r--shared.c5
-rw-r--r--ui-diff.c14
-rw-r--r--ui-log.c2
-rw-r--r--ui-patch.c2
-rw-r--r--ui-shared.c14
7 files changed, 34 insertions, 8 deletions
diff --git a/cgit.c b/cgit.c
index d4fcfa7..ab25b6a 100644
--- a/cgit.c
+++ b/cgit.c
@@ -245,32 +245,34 @@ static void querystring_cb(const char *name, const char *value)
245 } else if (!strcmp(name, "path")) { 245 } else if (!strcmp(name, "path")) {
246 ctx.qry.path = trim_end(value, '/'); 246 ctx.qry.path = trim_end(value, '/');
247 } else if (!strcmp(name, "name")) { 247 } else if (!strcmp(name, "name")) {
248 ctx.qry.name = xstrdup(value); 248 ctx.qry.name = xstrdup(value);
249 } else if (!strcmp(name, "mimetype")) { 249 } else if (!strcmp(name, "mimetype")) {
250 ctx.qry.mimetype = xstrdup(value); 250 ctx.qry.mimetype = xstrdup(value);
251 } else if (!strcmp(name, "s")){ 251 } else if (!strcmp(name, "s")){
252 ctx.qry.sort = xstrdup(value); 252 ctx.qry.sort = xstrdup(value);
253 } else if (!strcmp(name, "showmsg")) { 253 } else if (!strcmp(name, "showmsg")) {
254 ctx.qry.showmsg = atoi(value); 254 ctx.qry.showmsg = atoi(value);
255 } else if (!strcmp(name, "period")) { 255 } else if (!strcmp(name, "period")) {
256 ctx.qry.period = xstrdup(value); 256 ctx.qry.period = xstrdup(value);
257 } else if (!strcmp(name, "ss")) { 257 } else if (!strcmp(name, "ss")) {
258 ctx.qry.ssdiff = atoi(value); 258 ctx.qry.ssdiff = atoi(value);
259 } else if (!strcmp(name, "all")) { 259 } else if (!strcmp(name, "all")) {
260 ctx.qry.show_all = atoi(value); 260 ctx.qry.show_all = atoi(value);
261 } else if (!strcmp(name, "context")) {
262 ctx.qry.context = atoi(value);
261 } 263 }
262} 264}
263 265
264char *xstrdupn(const char *str) 266char *xstrdupn(const char *str)
265{ 267{
266 return (str ? xstrdup(str) : NULL); 268 return (str ? xstrdup(str) : NULL);
267} 269}
268 270
269static void prepare_context(struct cgit_context *ctx) 271static void prepare_context(struct cgit_context *ctx)
270{ 272{
271 memset(ctx, 0, sizeof(*ctx)); 273 memset(ctx, 0, sizeof(*ctx));
272 ctx->cfg.agefile = "info/web/last-modified"; 274 ctx->cfg.agefile = "info/web/last-modified";
273 ctx->cfg.nocache = 0; 275 ctx->cfg.nocache = 0;
274 ctx->cfg.cache_size = 0; 276 ctx->cfg.cache_size = 0;
275 ctx->cfg.cache_dynamic_ttl = 5; 277 ctx->cfg.cache_dynamic_ttl = 5;
276 ctx->cfg.cache_max_create_time = 5; 278 ctx->cfg.cache_max_create_time = 5;
diff --git a/cgit.h b/cgit.h
index 80c3902..2b28d63 100644
--- a/cgit.h
+++ b/cgit.h
@@ -134,32 +134,33 @@ struct cgit_query {
134 char *search; 134 char *search;
135 char *grep; 135 char *grep;
136 char *head; 136 char *head;
137 char *sha1; 137 char *sha1;
138 char *sha2; 138 char *sha2;
139 char *path; 139 char *path;
140 char *name; 140 char *name;
141 char *mimetype; 141 char *mimetype;
142 char *url; 142 char *url;
143 char *period; 143 char *period;
144 int ofs; 144 int ofs;
145 int nohead; 145 int nohead;
146 char *sort; 146 char *sort;
147 int showmsg; 147 int showmsg;
148 int ssdiff; 148 int ssdiff;
149 int show_all; 149 int show_all;
150 int context;
150 char *vpath; 151 char *vpath;
151}; 152};
152 153
153struct cgit_config { 154struct cgit_config {
154 char *agefile; 155 char *agefile;
155 char *cache_root; 156 char *cache_root;
156 char *clone_prefix; 157 char *clone_prefix;
157 char *css; 158 char *css;
158 char *favicon; 159 char *favicon;
159 char *footer; 160 char *footer;
160 char *head_include; 161 char *head_include;
161 char *header; 162 char *header;
162 char *index_header; 163 char *index_header;
163 char *index_info; 164 char *index_info;
164 char *logo; 165 char *logo;
165 char *logo_link; 166 char *logo_link;
@@ -265,33 +266,33 @@ extern int chk_zero(int result, char *msg);
265extern int chk_positive(int result, char *msg); 266extern int chk_positive(int result, char *msg);
266extern int chk_non_negative(int result, char *msg); 267extern int chk_non_negative(int result, char *msg);
267 268
268extern char *trim_end(const char *str, char c); 269extern char *trim_end(const char *str, char c);
269extern char *strlpart(char *txt, int maxlen); 270extern char *strlpart(char *txt, int maxlen);
270extern char *strrpart(char *txt, int maxlen); 271extern char *strrpart(char *txt, int maxlen);
271 272
272extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); 273extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
273extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, 274extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
274 int flags, void *cb_data); 275 int flags, void *cb_data);
275 276
276extern void *cgit_free_commitinfo(struct commitinfo *info); 277extern void *cgit_free_commitinfo(struct commitinfo *info);
277 278
278extern int cgit_diff_files(const unsigned char *old_sha1, 279extern int cgit_diff_files(const unsigned char *old_sha1,
279 const unsigned char *new_sha1, 280 const unsigned char *new_sha1,
280 unsigned long *old_size, unsigned long *new_size, 281 unsigned long *old_size, unsigned long *new_size,
281 int *binary, linediff_fn fn); 282 int *binary, int context, linediff_fn fn);
282 283
283extern void cgit_diff_tree(const unsigned char *old_sha1, 284extern void cgit_diff_tree(const unsigned char *old_sha1,
284 const unsigned char *new_sha1, 285 const unsigned char *new_sha1,
285 filepair_fn fn, const char *prefix); 286 filepair_fn fn, const char *prefix);
286 287
287extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); 288extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
288 289
289extern char *fmt(const char *format,...); 290extern char *fmt(const char *format,...);
290 291
291extern struct commitinfo *cgit_parse_commit(struct commit *commit); 292extern struct commitinfo *cgit_parse_commit(struct commit *commit);
292extern struct taginfo *cgit_parse_tag(struct tag *tag); 293extern struct taginfo *cgit_parse_tag(struct tag *tag);
293extern void cgit_parse_url(const char *url); 294extern void cgit_parse_url(const char *url);
294 295
295extern const char *cgit_repobasename(const char *reponame); 296extern const char *cgit_repobasename(const char *reponame);
296 297
297extern int cgit_parse_snapshots_mask(const char *str); 298extern int cgit_parse_snapshots_mask(const char *str);
diff --git a/shared.c b/shared.c
index 58837dc..06f70bb 100644
--- a/shared.c
+++ b/shared.c
@@ -250,60 +250,61 @@ int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf)
250 ((linediff_fn)priv)(diffbuf, buflen + mb[i].size); 250 ((linediff_fn)priv)(diffbuf, buflen + mb[i].size);
251 free(diffbuf); 251 free(diffbuf);
252 diffbuf = NULL; 252 diffbuf = NULL;
253 buflen = 0; 253 buflen = 0;
254 } 254 }
255 if (diffbuf) { 255 if (diffbuf) {
256 ((linediff_fn)priv)(diffbuf, buflen); 256 ((linediff_fn)priv)(diffbuf, buflen);
257 free(diffbuf); 257 free(diffbuf);
258 diffbuf = NULL; 258 diffbuf = NULL;
259 buflen = 0; 259 buflen = 0;
260 } 260 }
261 return 0; 261 return 0;
262} 262}
263 263
264int cgit_diff_files(const unsigned char *old_sha1, 264int 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;
270 xdemitconf_t emit_params; 271 xdemitconf_t emit_params;
271 xdemitcb_t emit_cb; 272 xdemitcb_t emit_cb;
272 273
273 if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) 274 if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1))
274 return 1; 275 return 1;
275 276
276 *old_size = file1.size; 277 *old_size = file1.size;
277 *new_size = file2.size; 278 *new_size = file2.size;
278 279
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;
282 if (file1.size) 283 if (file1.size)
283 free(file1.ptr); 284 free(file1.ptr);
284 if (file2.size) 285 if (file2.size)
285 free(file2.ptr); 286 free(file2.ptr);
286 return 0; 287 return 0;
287 } 288 }
288 289
289 memset(&diff_params, 0, sizeof(diff_params)); 290 memset(&diff_params, 0, sizeof(diff_params));
290 memset(&emit_params, 0, sizeof(emit_params)); 291 memset(&emit_params, 0, sizeof(emit_params));
291 memset(&emit_cb, 0, sizeof(emit_cb)); 292 memset(&emit_cb, 0, sizeof(emit_cb));
292 diff_params.flags = XDF_NEED_MINIMAL; 293 diff_params.flags = XDF_NEED_MINIMAL;
293 emit_params.ctxlen = 3; 294 emit_params.ctxlen = context > 0 ? context : 3;
294 emit_params.flags = XDL_EMIT_FUNCNAMES; 295 emit_params.flags = XDL_EMIT_FUNCNAMES;
295 emit_cb.outf = filediff_cb; 296 emit_cb.outf = filediff_cb;
296 emit_cb.priv = fn; 297 emit_cb.priv = fn;
297 xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); 298 xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb);
298 if (file1.size) 299 if (file1.size)
299 free(file1.ptr); 300 free(file1.ptr);
300 if (file2.size) 301 if (file2.size)
301 free(file2.ptr); 302 free(file2.ptr);
302 return 0; 303 return 0;
303} 304}
304 305
305void cgit_diff_tree(const unsigned char *old_sha1, 306void cgit_diff_tree(const unsigned char *old_sha1,
306 const unsigned char *new_sha1, 307 const unsigned char *new_sha1,
307 filepair_fn fn, const char *prefix) 308 filepair_fn fn, const char *prefix)
308{ 309{
309 struct diff_options opt; 310 struct diff_options opt;
diff --git a/ui-diff.c b/ui-diff.c
index fb836df..e0a72f7 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -114,68 +114,76 @@ static void count_diff_lines(char *line, int len)
114 if (line[0] == '+') 114 if (line[0] == '+')
115 lines_added++; 115 lines_added++;
116 else if (line[0] == '-') 116 else if (line[0] == '-')
117 lines_removed++; 117 lines_removed++;
118 } 118 }
119} 119}
120 120
121static void inspect_filepair(struct diff_filepair *pair) 121static void inspect_filepair(struct diff_filepair *pair)
122{ 122{
123 int binary = 0; 123 int binary = 0;
124 unsigned long old_size = 0; 124 unsigned long old_size = 0;
125 unsigned long new_size = 0; 125 unsigned long new_size = 0;
126 files++; 126 files++;
127 lines_added = 0; 127 lines_added = 0;
128 lines_removed = 0; 128 lines_removed = 0;
129 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, 129 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size,
130 &binary, count_diff_lines); 130 &binary, 0, count_diff_lines);
131 if (files >= slots) { 131 if (files >= slots) {
132 if (slots == 0) 132 if (slots == 0)
133 slots = 4; 133 slots = 4;
134 else 134 else
135 slots = slots * 2; 135 slots = slots * 2;
136 items = xrealloc(items, slots * sizeof(struct fileinfo)); 136 items = xrealloc(items, slots * sizeof(struct fileinfo));
137 } 137 }
138 items[files-1].status = pair->status; 138 items[files-1].status = pair->status;
139 hashcpy(items[files-1].old_sha1, pair->one->sha1); 139 hashcpy(items[files-1].old_sha1, pair->one->sha1);
140 hashcpy(items[files-1].new_sha1, pair->two->sha1); 140 hashcpy(items[files-1].new_sha1, pair->two->sha1);
141 items[files-1].old_mode = pair->one->mode; 141 items[files-1].old_mode = pair->one->mode;
142 items[files-1].new_mode = pair->two->mode; 142 items[files-1].new_mode = pair->two->mode;
143 items[files-1].old_path = xstrdup(pair->one->path); 143 items[files-1].old_path = xstrdup(pair->one->path);
144 items[files-1].new_path = xstrdup(pair->two->path); 144 items[files-1].new_path = xstrdup(pair->two->path);
145 items[files-1].added = lines_added; 145 items[files-1].added = lines_added;
146 items[files-1].removed = lines_removed; 146 items[files-1].removed = lines_removed;
147 items[files-1].old_size = old_size; 147 items[files-1].old_size = old_size;
148 items[files-1].new_size = new_size; 148 items[files-1].new_size = new_size;
149 items[files-1].binary = binary; 149 items[files-1].binary = binary;
150 if (lines_added + lines_removed > max_changes) 150 if (lines_added + lines_removed > max_changes)
151 max_changes = lines_added + lines_removed; 151 max_changes = lines_added + lines_removed;
152 total_adds += lines_added; 152 total_adds += lines_added;
153 total_rems += lines_removed; 153 total_rems += lines_removed;
154} 154}
155 155
156void cgit_print_diffstat(const unsigned char *old_sha1, 156void cgit_print_diffstat(const unsigned char *old_sha1,
157 const unsigned char *new_sha1, const char *prefix) 157 const unsigned char *new_sha1, const char *prefix)
158{ 158{
159 int i; 159 int i, save_context = ctx.qry.context;
160 160
161 html("<div class='diffstat-header'>"); 161 html("<div class='diffstat-header'>");
162 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 162 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
163 ctx.qry.sha2, NULL, 0); 163 ctx.qry.sha2, NULL, 0);
164 if (prefix) 164 if (prefix)
165 htmlf(" (limited to '%s')", prefix); 165 htmlf(" (limited to '%s')", prefix);
166 html(" (");
167 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
168 cgit_self_link("more", NULL, NULL, &ctx);
169 html("/");
170 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
171 cgit_self_link("less", NULL, NULL, &ctx);
172 ctx.qry.context = save_context;
173 html(" context)");
166 html("</div>"); 174 html("</div>");
167 html("<table summary='diffstat' class='diffstat'>"); 175 html("<table summary='diffstat' class='diffstat'>");
168 max_changes = 0; 176 max_changes = 0;
169 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix); 177 cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix);
170 for(i = 0; i<files; i++) 178 for(i = 0; i<files; i++)
171 print_fileinfo(&items[i]); 179 print_fileinfo(&items[i]);
172 html("</table>"); 180 html("</table>");
173 html("<div class='diffstat-summary'>"); 181 html("<div class='diffstat-summary'>");
174 htmlf("%d files changed, %d insertions, %d deletions", 182 htmlf("%d files changed, %d insertions, %d deletions",
175 files, total_adds, total_rems); 183 files, total_adds, total_rems);
176 html("</div>"); 184 html("</div>");
177} 185}
178 186
179 187
180/* 188/*
181 * print a single line returned from xdiff 189 * print a single line returned from xdiff
@@ -275,33 +283,33 @@ static void filepair_cb(struct diff_filepair *pair)
275 print_line_fn = cgit_ssdiff_line_cb; 283 print_line_fn = cgit_ssdiff_line_cb;
276 } 284 }
277 header(pair->one->sha1, pair->one->path, pair->one->mode, 285 header(pair->one->sha1, pair->one->path, pair->one->mode,
278 pair->two->sha1, pair->two->path, pair->two->mode); 286 pair->two->sha1, pair->two->path, pair->two->mode);
279 if (use_ssdiff) 287 if (use_ssdiff)
280 cgit_ssdiff_header_end(); 288 cgit_ssdiff_header_end();
281 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { 289 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
282 if (S_ISGITLINK(pair->one->mode)) 290 if (S_ISGITLINK(pair->one->mode))
283 print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); 291 print_line_fn(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
284 if (S_ISGITLINK(pair->two->mode)) 292 if (S_ISGITLINK(pair->two->mode))
285 print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); 293 print_line_fn(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
286 if (use_ssdiff) 294 if (use_ssdiff)
287 cgit_ssdiff_footer(); 295 cgit_ssdiff_footer();
288 return; 296 return;
289 } 297 }
290 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, 298 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
291 &new_size, &binary, print_line_fn)) 299 &new_size, &binary, ctx.qry.context, print_line_fn))
292 cgit_print_error("Error running diff"); 300 cgit_print_error("Error running diff");
293 if (binary) { 301 if (binary) {
294 if (use_ssdiff) 302 if (use_ssdiff)
295 html("<tr><td colspan='4'>Binary files differ</td></tr>"); 303 html("<tr><td colspan='4'>Binary files differ</td></tr>");
296 else 304 else
297 html("Binary files differ"); 305 html("Binary files differ");
298 } 306 }
299 if (use_ssdiff) 307 if (use_ssdiff)
300 cgit_ssdiff_footer(); 308 cgit_ssdiff_footer();
301} 309}
302 310
303void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) 311void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix)
304{ 312{
305 enum object_type type; 313 enum object_type type;
306 unsigned long size; 314 unsigned long size;
307 struct commit *commit, *commit2; 315 struct commit *commit, *commit2;
diff --git a/ui-log.c b/ui-log.c
index bfbe436..5eb5c81 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -20,33 +20,33 @@ void count_lines(char *line, int size)
20 if (line[0] == '+') 20 if (line[0] == '+')
21 add_lines++; 21 add_lines++;
22 22
23 else if (line[0] == '-') 23 else if (line[0] == '-')
24 rem_lines++; 24 rem_lines++;
25} 25}
26 26
27void inspect_files(struct diff_filepair *pair) 27void inspect_files(struct diff_filepair *pair)
28{ 28{
29 unsigned long old_size = 0; 29 unsigned long old_size = 0;
30 unsigned long new_size = 0; 30 unsigned long new_size = 0;
31 int binary = 0; 31 int binary = 0;
32 32
33 files++; 33 files++;
34 if (ctx.repo->enable_log_linecount) 34 if (ctx.repo->enable_log_linecount)
35 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, 35 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
36 &new_size, &binary, count_lines); 36 &new_size, &binary, 0, count_lines);
37} 37}
38 38
39void show_commit_decorations(struct commit *commit) 39void show_commit_decorations(struct commit *commit)
40{ 40{
41 struct name_decoration *deco; 41 struct name_decoration *deco;
42 static char buf[1024]; 42 static char buf[1024];
43 43
44 buf[sizeof(buf) - 1] = 0; 44 buf[sizeof(buf) - 1] = 0;
45 deco = lookup_decoration(&name_decoration, &commit->object); 45 deco = lookup_decoration(&name_decoration, &commit->object);
46 while (deco) { 46 while (deco) {
47 if (!prefixcmp(deco->name, "refs/heads/")) { 47 if (!prefixcmp(deco->name, "refs/heads/")) {
48 strncpy(buf, deco->name + 11, sizeof(buf) - 1); 48 strncpy(buf, deco->name + 11, sizeof(buf) - 1);
49 cgit_log_link(buf, NULL, "branch-deco", buf, NULL, 49 cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
50 ctx.qry.vpath, 0, NULL, NULL, 50 ctx.qry.vpath, 0, NULL, NULL,
51 ctx.qry.showmsg); 51 ctx.qry.showmsg);
52 } 52 }
diff --git a/ui-patch.c b/ui-patch.c
index 25dc9fe..d13104c 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -58,33 +58,33 @@ static void header(unsigned char *sha1, char *path1, int mode1,
58static void filepair_cb(struct diff_filepair *pair) 58static void filepair_cb(struct diff_filepair *pair)
59{ 59{
60 unsigned long old_size = 0; 60 unsigned long old_size = 0;
61 unsigned long new_size = 0; 61 unsigned long new_size = 0;
62 int binary = 0; 62 int binary = 0;
63 63
64 header(pair->one->sha1, pair->one->path, pair->one->mode, 64 header(pair->one->sha1, pair->one->path, pair->one->mode,
65 pair->two->sha1, pair->two->path, pair->two->mode); 65 pair->two->sha1, pair->two->path, pair->two->mode);
66 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { 66 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
67 if (S_ISGITLINK(pair->one->mode)) 67 if (S_ISGITLINK(pair->one->mode))
68 print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); 68 print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
69 if (S_ISGITLINK(pair->two->mode)) 69 if (S_ISGITLINK(pair->two->mode))
70 print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); 70 print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
71 return; 71 return;
72 } 72 }
73 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, 73 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
74 &new_size, &binary, print_line)) 74 &new_size, &binary, 0, print_line))
75 html("Error running diff"); 75 html("Error running diff");
76 if (binary) 76 if (binary)
77 html("Binary files differ\n"); 77 html("Binary files differ\n");
78} 78}
79 79
80void cgit_print_patch(char *hex, const char *prefix) 80void cgit_print_patch(char *hex, const char *prefix)
81{ 81{
82 struct commit *commit; 82 struct commit *commit;
83 struct commitinfo *info; 83 struct commitinfo *info;
84 unsigned char sha1[20], old_sha1[20]; 84 unsigned char sha1[20], old_sha1[20];
85 char *patchname; 85 char *patchname;
86 86
87 if (!hex) 87 if (!hex)
88 hex = ctx.qry.head; 88 hex = ctx.qry.head;
89 89
90 if (get_sha1(hex, sha1)) { 90 if (get_sha1(hex, sha1)) {
diff --git a/ui-shared.c b/ui-shared.c
index e991799..c99bcec 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -328,32 +328,39 @@ void cgit_commit_link(char *name, const char *title, const char *class,
328 name[ctx.cfg.max_msg_len - 2] = '.'; 328 name[ctx.cfg.max_msg_len - 2] = '.';
329 name[ctx.cfg.max_msg_len - 3] = '.'; 329 name[ctx.cfg.max_msg_len - 3] = '.';
330 } 330 }
331 331
332 char *delim; 332 char *delim;
333 333
334 delim = repolink(title, class, "commit", head, path); 334 delim = repolink(title, class, "commit", head, path);
335 if (rev && strcmp(rev, ctx.qry.head)) { 335 if (rev && strcmp(rev, ctx.qry.head)) {
336 html(delim); 336 html(delim);
337 html("id="); 337 html("id=");
338 html_url_arg(rev); 338 html_url_arg(rev);
339 delim = "&amp;"; 339 delim = "&amp;";
340 } 340 }
341 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 341 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
342 html(delim); 342 html(delim);
343 html("ss=1"); 343 html("ss=1");
344 delim = "&amp;";
345 }
346 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
347 html(delim);
348 html("context=");
349 htmlf("%d", ctx.qry.context);
350 delim = "&amp;";
344 } 351 }
345 html("'>"); 352 html("'>");
346 html_txt(name); 353 html_txt(name);
347 html("</a>"); 354 html("</a>");
348} 355}
349 356
350void cgit_refs_link(const char *name, const char *title, const char *class, 357void cgit_refs_link(const char *name, const char *title, const char *class,
351 const char *head, const char *rev, const char *path) 358 const char *head, const char *rev, const char *path)
352{ 359{
353 reporevlink("refs", name, title, class, head, rev, path); 360 reporevlink("refs", name, title, class, head, rev, path);
354} 361}
355 362
356void cgit_snapshot_link(const char *name, const char *title, const char *class, 363void cgit_snapshot_link(const char *name, const char *title, const char *class,
357 const char *head, const char *rev, 364 const char *head, const char *rev,
358 const char *archivename) 365 const char *archivename)
359{ 366{
@@ -369,32 +376,39 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
369 delim = repolink(title, class, "diff", head, path); 376 delim = repolink(title, class, "diff", head, path);
370 if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) { 377 if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
371 html(delim); 378 html(delim);
372 html("id="); 379 html("id=");
373 html_url_arg(new_rev); 380 html_url_arg(new_rev);
374 delim = "&amp;"; 381 delim = "&amp;";
375 } 382 }
376 if (old_rev) { 383 if (old_rev) {
377 html(delim); 384 html(delim);
378 html("id2="); 385 html("id2=");
379 html_url_arg(old_rev); 386 html_url_arg(old_rev);
380 delim = "&amp;"; 387 delim = "&amp;";
381 } 388 }
382 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 389 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
383 html(delim); 390 html(delim);
384 html("ss=1"); 391 html("ss=1");
392 delim = "&amp;";
393 }
394 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
395 html(delim);
396 html("context=");
397 htmlf("%d", ctx.qry.context);
398 delim = "&amp;";
385 } 399 }
386 html("'>"); 400 html("'>");
387 html_txt(name); 401 html_txt(name);
388 html("</a>"); 402 html("</a>");
389} 403}
390 404
391void cgit_patch_link(const char *name, const char *title, const char *class, 405void cgit_patch_link(const char *name, const char *title, const char *class,
392 const char *head, const char *rev, const char *path) 406 const char *head, const char *rev, const char *path)
393{ 407{
394 reporevlink("patch", name, title, class, head, rev, path); 408 reporevlink("patch", name, title, class, head, rev, path);
395} 409}
396 410
397void cgit_stats_link(const char *name, const char *title, const char *class, 411void cgit_stats_link(const char *name, const char *title, const char *class,
398 const char *head, const char *path) 412 const char *head, const char *path)
399{ 413{
400 reporevlink("stats", name, title, class, head, NULL, path); 414 reporevlink("stats", name, title, class, head, NULL, path);