-rw-r--r-- | Makefile | 2 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | ui-log.c | 6 |
3 files changed, 3 insertions, 5 deletions
@@ -1,103 +1,103 @@ | |||
1 | CGIT_VERSION = v0.7.2 | 1 | CGIT_VERSION = v0.7.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_CONFIG = /etc/cgitrc | 4 | CGIT_CONFIG = /etc/cgitrc |
5 | CACHE_ROOT = /var/cache/cgit | 5 | CACHE_ROOT = /var/cache/cgit |
6 | SHA1_HEADER = <openssl/sha.h> | 6 | SHA1_HEADER = <openssl/sha.h> |
7 | GIT_VER = 1.6.0.1 | 7 | GIT_VER = 1.6.0.2 |
8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | 8 | GIT_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 | # |
16 | # Define a way to invoke make in subdirs quietly, shamelessly ripped | 16 | # Define a way to invoke make in subdirs quietly, shamelessly ripped |
17 | # from git.git | 17 | # from git.git |
18 | # | 18 | # |
19 | QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir | 19 | QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir |
20 | QUIET_SUBDIR1 = | 20 | QUIET_SUBDIR1 = |
21 | 21 | ||
22 | ifneq ($(findstring $(MAKEFLAGS),w),w) | 22 | ifneq ($(findstring $(MAKEFLAGS),w),w) |
23 | PRINT_DIR = --no-print-directory | 23 | PRINT_DIR = --no-print-directory |
24 | else # "make -w" | 24 | else # "make -w" |
25 | NO_SUBDIR = : | 25 | NO_SUBDIR = : |
26 | endif | 26 | endif |
27 | 27 | ||
28 | ifndef V | 28 | ifndef V |
29 | QUIET_CC = @echo ' ' CC $@; | 29 | QUIET_CC = @echo ' ' CC $@; |
30 | QUIET_MM = @echo ' ' MM $@; | 30 | QUIET_MM = @echo ' ' MM $@; |
31 | QUIET_SUBDIR0 = +@subdir= | 31 | QUIET_SUBDIR0 = +@subdir= |
32 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ | 32 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ |
33 | $(MAKE) $(PRINT_DIR) -C $$subdir | 33 | $(MAKE) $(PRINT_DIR) -C $$subdir |
34 | endif | 34 | endif |
35 | 35 | ||
36 | # | 36 | # |
37 | # Define a pattern rule for automatic dependency building | 37 | # Define a pattern rule for automatic dependency building |
38 | # | 38 | # |
39 | %.d: %.c | 39 | %.d: %.c |
40 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ | 40 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ |
41 | 41 | ||
42 | # | 42 | # |
43 | # Define a pattern rule for silent object building | 43 | # Define a pattern rule for silent object building |
44 | # | 44 | # |
45 | %.o: %.c | 45 | %.o: %.c |
46 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< | 46 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< |
47 | 47 | ||
48 | 48 | ||
49 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 49 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto |
50 | OBJECTS = | 50 | OBJECTS = |
51 | OBJECTS += cache.o | 51 | OBJECTS += cache.o |
52 | OBJECTS += cgit.o | 52 | OBJECTS += cgit.o |
53 | OBJECTS += cmd.o | 53 | OBJECTS += cmd.o |
54 | OBJECTS += configfile.o | 54 | OBJECTS += configfile.o |
55 | OBJECTS += html.o | 55 | OBJECTS += html.o |
56 | OBJECTS += parsing.o | 56 | OBJECTS += parsing.o |
57 | OBJECTS += scan-tree.o | 57 | OBJECTS += scan-tree.o |
58 | OBJECTS += shared.o | 58 | OBJECTS += shared.o |
59 | OBJECTS += ui-atom.o | 59 | OBJECTS += ui-atom.o |
60 | OBJECTS += ui-blob.o | 60 | OBJECTS += ui-blob.o |
61 | OBJECTS += ui-clone.o | 61 | OBJECTS += ui-clone.o |
62 | OBJECTS += ui-commit.o | 62 | OBJECTS += ui-commit.o |
63 | OBJECTS += ui-diff.o | 63 | OBJECTS += ui-diff.o |
64 | OBJECTS += ui-log.o | 64 | OBJECTS += ui-log.o |
65 | OBJECTS += ui-patch.o | 65 | OBJECTS += ui-patch.o |
66 | OBJECTS += ui-plain.o | 66 | OBJECTS += ui-plain.o |
67 | OBJECTS += ui-refs.o | 67 | OBJECTS += ui-refs.o |
68 | OBJECTS += ui-repolist.o | 68 | OBJECTS += ui-repolist.o |
69 | OBJECTS += ui-shared.o | 69 | OBJECTS += ui-shared.o |
70 | OBJECTS += ui-snapshot.o | 70 | OBJECTS += ui-snapshot.o |
71 | OBJECTS += ui-summary.o | 71 | OBJECTS += ui-summary.o |
72 | OBJECTS += ui-tag.o | 72 | OBJECTS += ui-tag.o |
73 | OBJECTS += ui-tree.o | 73 | OBJECTS += ui-tree.o |
74 | 74 | ||
75 | ifdef NEEDS_LIBICONV | 75 | ifdef NEEDS_LIBICONV |
76 | EXTLIBS += -liconv | 76 | EXTLIBS += -liconv |
77 | endif | 77 | endif |
78 | 78 | ||
79 | 79 | ||
80 | .PHONY: all libgit test install uninstall clean force-version get-git | 80 | .PHONY: all libgit test install uninstall clean force-version get-git |
81 | 81 | ||
82 | all: cgit | 82 | all: cgit |
83 | 83 | ||
84 | VERSION: force-version | 84 | VERSION: force-version |
85 | @./gen-version.sh "$(CGIT_VERSION)" | 85 | @./gen-version.sh "$(CGIT_VERSION)" |
86 | -include VERSION | 86 | -include VERSION |
87 | 87 | ||
88 | 88 | ||
89 | CFLAGS += -g -Wall -Igit | 89 | CFLAGS += -g -Wall -Igit |
90 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | 90 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
91 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | 91 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
92 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | 92 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
93 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | 93 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
94 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' | 94 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' |
95 | 95 | ||
96 | 96 | ||
97 | cgit: $(OBJECTS) libgit | 97 | cgit: $(OBJECTS) libgit |
98 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) | 98 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) |
99 | 99 | ||
100 | cgit.o: VERSION | 100 | cgit.o: VERSION |
101 | 101 | ||
102 | -include $(OBJECTS:.o=.d) | 102 | -include $(OBJECTS:.o=.d) |
103 | 103 | ||
diff --git a/git b/git | |||
Subproject 5760a6b094736e6f59eb32c7abb4cdbb7fca162 | Subproject 97a7a82f199f165f85fe39a3c318b18c621e633 | ||
@@ -1,157 +1,155 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | 12 | ||
13 | int files, add_lines, rem_lines; | 13 | int files, add_lines, rem_lines; |
14 | 14 | ||
15 | void count_lines(char *line, int size) | 15 | void count_lines(char *line, int size) |
16 | { | 16 | { |
17 | if (size <= 0) | 17 | if (size <= 0) |
18 | return; | 18 | return; |
19 | 19 | ||
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 | ||
27 | void inspect_files(struct diff_filepair *pair) | 27 | void inspect_files(struct diff_filepair *pair) |
28 | { | 28 | { |
29 | files++; | 29 | files++; |
30 | if (ctx.repo->enable_log_linecount) | 30 | if (ctx.repo->enable_log_linecount) |
31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); | 31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
32 | } | 32 | } |
33 | 33 | ||
34 | void print_commit(struct commit *commit) | 34 | void print_commit(struct commit *commit) |
35 | { | 35 | { |
36 | struct commitinfo *info; | 36 | struct commitinfo *info; |
37 | char *tmp; | 37 | char *tmp; |
38 | 38 | ||
39 | info = cgit_parse_commit(commit); | 39 | info = cgit_parse_commit(commit); |
40 | html("<tr><td>"); | 40 | html("<tr><td>"); |
41 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 41 | tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
42 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); | 42 | tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); |
43 | html_link_open(tmp, NULL, NULL); | 43 | html_link_open(tmp, NULL, NULL); |
44 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 44 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
45 | html_link_close(); | 45 | html_link_close(); |
46 | html("</td><td>"); | 46 | html("</td><td>"); |
47 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, | 47 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
48 | sha1_to_hex(commit->object.sha1)); | 48 | sha1_to_hex(commit->object.sha1)); |
49 | html("</td><td>"); | 49 | html("</td><td>"); |
50 | html_txt(info->author); | 50 | html_txt(info->author); |
51 | if (ctx.repo->enable_log_filecount) { | 51 | if (ctx.repo->enable_log_filecount) { |
52 | files = 0; | 52 | files = 0; |
53 | add_lines = 0; | 53 | add_lines = 0; |
54 | rem_lines = 0; | 54 | rem_lines = 0; |
55 | cgit_diff_commit(commit, inspect_files); | 55 | cgit_diff_commit(commit, inspect_files); |
56 | html("</td><td>"); | 56 | html("</td><td>"); |
57 | htmlf("%d", files); | 57 | htmlf("%d", files); |
58 | if (ctx.repo->enable_log_linecount) { | 58 | if (ctx.repo->enable_log_linecount) { |
59 | html("</td><td>"); | 59 | html("</td><td>"); |
60 | htmlf("-%d/+%d", rem_lines, add_lines); | 60 | htmlf("-%d/+%d", rem_lines, add_lines); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | html("</td></tr>\n"); | 63 | html("</td></tr>\n"); |
64 | cgit_free_commitinfo(info); | 64 | cgit_free_commitinfo(info); |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, | 68 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
69 | char *path, int pager) | 69 | char *path, int pager) |
70 | { | 70 | { |
71 | struct rev_info rev; | 71 | struct rev_info rev; |
72 | struct commit *commit; | 72 | struct commit *commit; |
73 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; | 73 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
74 | int argc = 2; | 74 | int argc = 2; |
75 | int i, columns = 3; | 75 | int i, columns = 3; |
76 | 76 | ||
77 | if (!tip) | 77 | if (!tip) |
78 | argv[1] = ctx.qry.head; | 78 | argv[1] = ctx.qry.head; |
79 | 79 | ||
80 | if (grep && pattern && (!strcmp(grep, "grep") || | 80 | if (grep && pattern && (!strcmp(grep, "grep") || |
81 | !strcmp(grep, "author") || | 81 | !strcmp(grep, "author") || |
82 | !strcmp(grep, "committer"))) | 82 | !strcmp(grep, "committer"))) |
83 | argv[argc++] = fmt("--%s=%s", grep, pattern); | 83 | argv[argc++] = fmt("--%s=%s", grep, pattern); |
84 | 84 | ||
85 | if (path) { | 85 | if (path) { |
86 | argv[argc++] = "--"; | 86 | argv[argc++] = "--"; |
87 | argv[argc++] = path; | 87 | argv[argc++] = path; |
88 | } | 88 | } |
89 | init_revisions(&rev, NULL); | 89 | init_revisions(&rev, NULL); |
90 | rev.abbrev = DEFAULT_ABBREV; | 90 | rev.abbrev = DEFAULT_ABBREV; |
91 | rev.commit_format = CMIT_FMT_DEFAULT; | 91 | rev.commit_format = CMIT_FMT_DEFAULT; |
92 | rev.verbose_header = 1; | 92 | rev.verbose_header = 1; |
93 | rev.show_root_diff = 0; | 93 | rev.show_root_diff = 0; |
94 | setup_revisions(argc, argv, &rev, NULL); | 94 | setup_revisions(argc, argv, &rev, NULL); |
95 | if (rev.grep_filter) { | 95 | rev.grep_filter.regflags |= REG_ICASE; |
96 | rev.grep_filter->regflags |= REG_ICASE; | 96 | compile_grep_patterns(&rev.grep_filter); |
97 | compile_grep_patterns(rev.grep_filter); | ||
98 | } | ||
99 | prepare_revision_walk(&rev); | 97 | prepare_revision_walk(&rev); |
100 | 98 | ||
101 | if (pager) | 99 | if (pager) |
102 | html("<table class='list nowrap'>"); | 100 | html("<table class='list nowrap'>"); |
103 | 101 | ||
104 | html("<tr class='nohover'><th class='left'>Age</th>" | 102 | html("<tr class='nohover'><th class='left'>Age</th>" |
105 | "<th class='left'>Commit message</th>" | 103 | "<th class='left'>Commit message</th>" |
106 | "<th class='left'>Author</th>"); | 104 | "<th class='left'>Author</th>"); |
107 | if (ctx.repo->enable_log_filecount) { | 105 | if (ctx.repo->enable_log_filecount) { |
108 | html("<th class='left'>Files</th>"); | 106 | html("<th class='left'>Files</th>"); |
109 | columns++; | 107 | columns++; |
110 | if (ctx.repo->enable_log_linecount) { | 108 | if (ctx.repo->enable_log_linecount) { |
111 | html("<th class='left'>Lines</th>"); | 109 | html("<th class='left'>Lines</th>"); |
112 | columns++; | 110 | columns++; |
113 | } | 111 | } |
114 | } | 112 | } |
115 | html("</tr>\n"); | 113 | html("</tr>\n"); |
116 | 114 | ||
117 | if (ofs<0) | 115 | if (ofs<0) |
118 | ofs = 0; | 116 | ofs = 0; |
119 | 117 | ||
120 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 118 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
121 | free(commit->buffer); | 119 | free(commit->buffer); |
122 | commit->buffer = NULL; | 120 | commit->buffer = NULL; |
123 | free_commit_list(commit->parents); | 121 | free_commit_list(commit->parents); |
124 | commit->parents = NULL; | 122 | commit->parents = NULL; |
125 | } | 123 | } |
126 | 124 | ||
127 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 125 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
128 | print_commit(commit); | 126 | print_commit(commit); |
129 | free(commit->buffer); | 127 | free(commit->buffer); |
130 | commit->buffer = NULL; | 128 | commit->buffer = NULL; |
131 | free_commit_list(commit->parents); | 129 | free_commit_list(commit->parents); |
132 | commit->parents = NULL; | 130 | commit->parents = NULL; |
133 | } | 131 | } |
134 | if (pager) { | 132 | if (pager) { |
135 | htmlf("</table><div class='pager'>", | 133 | htmlf("</table><div class='pager'>", |
136 | columns); | 134 | columns); |
137 | if (ofs > 0) { | 135 | if (ofs > 0) { |
138 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, | 136 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
139 | ctx.qry.sha1, ctx.qry.path, | 137 | ctx.qry.sha1, ctx.qry.path, |
140 | ofs - cnt, ctx.qry.grep, | 138 | ofs - cnt, ctx.qry.grep, |
141 | ctx.qry.search); | 139 | ctx.qry.search); |
142 | html(" "); | 140 | html(" "); |
143 | } | 141 | } |
144 | if ((commit = get_revision(&rev)) != NULL) { | 142 | if ((commit = get_revision(&rev)) != NULL) { |
145 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, | 143 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
146 | ctx.qry.sha1, ctx.qry.path, | 144 | ctx.qry.sha1, ctx.qry.path, |
147 | ofs + cnt, ctx.qry.grep, | 145 | ofs + cnt, ctx.qry.grep, |
148 | ctx.qry.search); | 146 | ctx.qry.search); |
149 | } | 147 | } |
150 | html("</div>"); | 148 | html("</div>"); |
151 | } else if ((commit = get_revision(&rev)) != NULL) { | 149 | } else if ((commit = get_revision(&rev)) != NULL) { |
152 | html("<tr class='nohover'><td colspan='3'>"); | 150 | html("<tr class='nohover'><td colspan='3'>"); |
153 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, | 151 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, |
154 | NULL, NULL); | 152 | NULL, NULL); |
155 | html("</td></tr>\n"); | 153 | html("</td></tr>\n"); |
156 | } | 154 | } |
157 | } | 155 | } |