summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--Makefile2
m---------git0
-rw-r--r--shared.c2
3 files changed, 2 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index e39be18..a258f64 100644
--- a/Makefile
+++ b/Makefile
@@ -1,83 +1,83 @@
1CGIT_VERSION = v0.7.2 1CGIT_VERSION = v0.7.2
2CGIT_SCRIPT_NAME = cgit.cgi 2CGIT_SCRIPT_NAME = cgit.cgi
3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit 3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
4CGIT_CONFIG = /etc/cgitrc 4CGIT_CONFIG = /etc/cgitrc
5CACHE_ROOT = /var/cache/cgit 5CACHE_ROOT = /var/cache/cgit
6SHA1_HEADER = <openssl/sha.h> 6SHA1_HEADER = <openssl/sha.h>
7GIT_VER = 1.5.3.8 7GIT_VER = 1.5.4.rc4
8GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 8GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
9 9
10# 10#
11# Let the user override the above settings. 11# Let the user override the above settings.
12# 12#
13-include cgit.conf 13-include cgit.conf
14 14
15 15
16EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto 16EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
17OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ 17OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
18 ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ 18 ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \
19 ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o ui-patch.o 19 ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o ui-patch.o
20 20
21 21
22ifdef NEEDS_LIBICONV 22ifdef NEEDS_LIBICONV
23 EXTLIBS += -liconv 23 EXTLIBS += -liconv
24endif 24endif
25 25
26 26
27.PHONY: all git test install clean distclean emptycache force-version get-git 27.PHONY: all git test install clean distclean emptycache force-version get-git
28 28
29all: cgit git 29all: cgit git
30 30
31VERSION: force-version 31VERSION: force-version
32 @./gen-version.sh "$(CGIT_VERSION)" 32 @./gen-version.sh "$(CGIT_VERSION)"
33-include VERSION 33-include VERSION
34 34
35 35
36CFLAGS += -g -Wall -Igit 36CFLAGS += -g -Wall -Igit
37CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' 37CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
38CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' 38CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
39CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' 39CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
40CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' 40CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
41CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' 41CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
42 42
43 43
44cgit: cgit.c $(OBJECTS) 44cgit: cgit.c $(OBJECTS)
45 $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) 45 $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS)
46 46
47$(OBJECTS): cgit.h git/xdiff/lib.a git/libgit.a VERSION 47$(OBJECTS): cgit.h git/xdiff/lib.a git/libgit.a VERSION
48 48
49git/xdiff/lib.a: | git 49git/xdiff/lib.a: | git
50 50
51git/libgit.a: | git 51git/libgit.a: | git
52 52
53git: 53git:
54 cd git && $(MAKE) xdiff/lib.a 54 cd git && $(MAKE) xdiff/lib.a
55 cd git && $(MAKE) libgit.a 55 cd git && $(MAKE) libgit.a
56 56
57test: all 57test: all
58 $(MAKE) -C tests 58 $(MAKE) -C tests
59 59
60install: all 60install: all
61 mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH) 61 mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH)
62 install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) 62 install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
63 install cgit.css $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css 63 install cgit.css $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css
64 install cgit.png $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.png 64 install cgit.png $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.png
65 65
66uninstall: 66uninstall:
67 rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) 67 rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
68 rm -f $(CGIT_SCRIPT_PATH)/cgit.css 68 rm -f $(CGIT_SCRIPT_PATH)/cgit.css
69 rm -f $(CGIT_SCRIPT_PATH)/cgit.png 69 rm -f $(CGIT_SCRIPT_PATH)/cgit.png
70 70
71clean: 71clean:
72 rm -f cgit VERSION *.o 72 rm -f cgit VERSION *.o
73 cd git && $(MAKE) clean 73 cd git && $(MAKE) clean
74 74
75distclean: clean 75distclean: clean
76 git clean -d -x 76 git clean -d -x
77 cd git && git clean -d -x 77 cd git && git clean -d -x
78 78
79emptycache: 79emptycache:
80 rm -rf $(DESTDIR)$(CACHE_ROOT)/* 80 rm -rf $(DESTDIR)$(CACHE_ROOT)/*
81 81
82get-git: 82get-git:
83 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git 83 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git
diff --git a/git b/git
Subproject aadd4efa715f56e0eac5ac459c8ff4933b56d4c Subproject ce33288ea6b81a2f4f5aecd72177bcc8174562a
diff --git a/shared.c b/shared.c
index bf0581f..f063894 100644
--- a/shared.c
+++ b/shared.c
@@ -399,123 +399,123 @@ void cgit_diff_tree_cb(struct diff_queue_struct *q,
399 } 399 }
400} 400}
401 401
402static int load_mmfile(mmfile_t *file, const unsigned char *sha1) 402static int load_mmfile(mmfile_t *file, const unsigned char *sha1)
403{ 403{
404 enum object_type type; 404 enum object_type type;
405 405
406 if (is_null_sha1(sha1)) { 406 if (is_null_sha1(sha1)) {
407 file->ptr = (char *)""; 407 file->ptr = (char *)"";
408 file->size = 0; 408 file->size = 0;
409 } else { 409 } else {
410 file->ptr = read_sha1_file(sha1, &type, 410 file->ptr = read_sha1_file(sha1, &type,
411 (unsigned long *)&file->size); 411 (unsigned long *)&file->size);
412 } 412 }
413 return 1; 413 return 1;
414} 414}
415 415
416/* 416/*
417 * Receive diff-buffers from xdiff and concatenate them as 417 * Receive diff-buffers from xdiff and concatenate them as
418 * needed across multiple callbacks. 418 * needed across multiple callbacks.
419 * 419 *
420 * This is basically a copy of xdiff-interface.c/xdiff_outf(), 420 * This is basically a copy of xdiff-interface.c/xdiff_outf(),
421 * ripped from git and modified to use globals instead of 421 * ripped from git and modified to use globals instead of
422 * a special callback-struct. 422 * a special callback-struct.
423 */ 423 */
424char *diffbuf = NULL; 424char *diffbuf = NULL;
425int buflen = 0; 425int buflen = 0;
426 426
427int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) 427int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf)
428{ 428{
429 int i; 429 int i;
430 430
431 for (i = 0; i < nbuf; i++) { 431 for (i = 0; i < nbuf; i++) {
432 if (mb[i].ptr[mb[i].size-1] != '\n') { 432 if (mb[i].ptr[mb[i].size-1] != '\n') {
433 /* Incomplete line */ 433 /* Incomplete line */
434 diffbuf = xrealloc(diffbuf, buflen + mb[i].size); 434 diffbuf = xrealloc(diffbuf, buflen + mb[i].size);
435 memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); 435 memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size);
436 buflen += mb[i].size; 436 buflen += mb[i].size;
437 continue; 437 continue;
438 } 438 }
439 439
440 /* we have a complete line */ 440 /* we have a complete line */
441 if (!diffbuf) { 441 if (!diffbuf) {
442 ((linediff_fn)priv)(mb[i].ptr, mb[i].size); 442 ((linediff_fn)priv)(mb[i].ptr, mb[i].size);
443 continue; 443 continue;
444 } 444 }
445 diffbuf = xrealloc(diffbuf, buflen + mb[i].size); 445 diffbuf = xrealloc(diffbuf, buflen + mb[i].size);
446 memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); 446 memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size);
447 ((linediff_fn)priv)(diffbuf, buflen + mb[i].size); 447 ((linediff_fn)priv)(diffbuf, buflen + mb[i].size);
448 free(diffbuf); 448 free(diffbuf);
449 diffbuf = NULL; 449 diffbuf = NULL;
450 buflen = 0; 450 buflen = 0;
451 } 451 }
452 if (diffbuf) { 452 if (diffbuf) {
453 ((linediff_fn)priv)(diffbuf, buflen); 453 ((linediff_fn)priv)(diffbuf, buflen);
454 free(diffbuf); 454 free(diffbuf);
455 diffbuf = NULL; 455 diffbuf = NULL;
456 buflen = 0; 456 buflen = 0;
457 } 457 }
458 return 0; 458 return 0;
459} 459}
460 460
461int cgit_diff_files(const unsigned char *old_sha1, 461int cgit_diff_files(const unsigned char *old_sha1,
462 const unsigned char *new_sha1, 462 const unsigned char *new_sha1,
463 linediff_fn fn) 463 linediff_fn fn)
464{ 464{
465 mmfile_t file1, file2; 465 mmfile_t file1, file2;
466 xpparam_t diff_params; 466 xpparam_t diff_params;
467 xdemitconf_t emit_params; 467 xdemitconf_t emit_params;
468 xdemitcb_t emit_cb; 468 xdemitcb_t emit_cb;
469 469
470 if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) 470 if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1))
471 return 1; 471 return 1;
472 472
473 diff_params.flags = XDF_NEED_MINIMAL; 473 diff_params.flags = XDF_NEED_MINIMAL;
474 emit_params.ctxlen = 3; 474 emit_params.ctxlen = 3;
475 emit_params.flags = XDL_EMIT_FUNCNAMES; 475 emit_params.flags = XDL_EMIT_FUNCNAMES;
476 emit_params.find_func = NULL; 476 emit_params.find_func = NULL;
477 emit_cb.outf = filediff_cb; 477 emit_cb.outf = filediff_cb;
478 emit_cb.priv = fn; 478 emit_cb.priv = fn;
479 xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); 479 xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb);
480 return 0; 480 return 0;
481} 481}
482 482
483void cgit_diff_tree(const unsigned char *old_sha1, 483void cgit_diff_tree(const unsigned char *old_sha1,
484 const unsigned char *new_sha1, 484 const unsigned char *new_sha1,
485 filepair_fn fn, const char *prefix) 485 filepair_fn fn, const char *prefix)
486{ 486{
487 struct diff_options opt; 487 struct diff_options opt;
488 int ret; 488 int ret;
489 int prefixlen; 489 int prefixlen;
490 490
491 diff_setup(&opt); 491 diff_setup(&opt);
492 opt.output_format = DIFF_FORMAT_CALLBACK; 492 opt.output_format = DIFF_FORMAT_CALLBACK;
493 opt.detect_rename = 1; 493 opt.detect_rename = 1;
494 opt.rename_limit = cgit_renamelimit; 494 opt.rename_limit = cgit_renamelimit;
495 opt.recursive = 1; 495 DIFF_OPT_SET(&opt, RECURSIVE);
496 opt.format_callback = cgit_diff_tree_cb; 496 opt.format_callback = cgit_diff_tree_cb;
497 opt.format_callback_data = fn; 497 opt.format_callback_data = fn;
498 if (prefix) { 498 if (prefix) {
499 opt.nr_paths = 1; 499 opt.nr_paths = 1;
500 opt.paths = &prefix; 500 opt.paths = &prefix;
501 prefixlen = strlen(prefix); 501 prefixlen = strlen(prefix);
502 opt.pathlens = &prefixlen; 502 opt.pathlens = &prefixlen;
503 } 503 }
504 diff_setup_done(&opt); 504 diff_setup_done(&opt);
505 505
506 if (old_sha1 && !is_null_sha1(old_sha1)) 506 if (old_sha1 && !is_null_sha1(old_sha1))
507 ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); 507 ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt);
508 else 508 else
509 ret = diff_root_tree_sha1(new_sha1, "", &opt); 509 ret = diff_root_tree_sha1(new_sha1, "", &opt);
510 diffcore_std(&opt); 510 diffcore_std(&opt);
511 diff_flush(&opt); 511 diff_flush(&opt);
512} 512}
513 513
514void cgit_diff_commit(struct commit *commit, filepair_fn fn) 514void cgit_diff_commit(struct commit *commit, filepair_fn fn)
515{ 515{
516 unsigned char *old_sha1 = NULL; 516 unsigned char *old_sha1 = NULL;
517 517
518 if (commit->parents) 518 if (commit->parents)
519 old_sha1 = commit->parents->item->object.sha1; 519 old_sha1 = commit->parents->item->object.sha1;
520 cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); 520 cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL);
521} 521}