]>
git.cameronkatri.com Git - cgit.git/blob - ui-log.c
1 /* ui-log.c: functions for log output
3 * Copyright (C) 2006 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
13 void count_lines(char *line
, int size
)
15 if (size
>0 && (line
[0] == '+' || line
[0] == '-'))
19 void inspect_files(struct diff_filepair
*pair
)
22 cgit_diff_files(pair
->one
->sha1
, pair
->two
->sha1
, count_lines
);
25 void print_commit(struct commit
*commit
)
28 struct commitinfo
*info
;
31 info
= cgit_parse_commit(commit
);
32 time
= gmtime(&commit
->date
);
34 strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M", time
);
37 char *qry
= fmt("id=%s", sha1_to_hex(commit
->object
.sha1
));
38 char *url
= cgit_pageurl(cgit_query_repo
, "commit", qry
);
39 html_link_open(url
, NULL
, NULL
);
40 html_ntxt(cgit_max_msg_len
, info
->subject
);
44 cgit_diff_commit(commit
, inspect_files
);
45 html("</td><td class='right'>");
47 html("</td><td class='right'>");
50 html_txt(info
->author
);
52 cgit_free_commitinfo(info
);
56 void cgit_print_log(const char *tip
, int ofs
, int cnt
, char *grep
)
59 struct commit
*commit
;
60 const char *argv
[3] = {NULL
, tip
, NULL
};
65 argv
[argc
++] = fmt("--grep=%s", grep
);
66 init_revisions(&rev
, NULL
);
67 rev
.abbrev
= DEFAULT_ABBREV
;
68 rev
.commit_format
= CMIT_FMT_DEFAULT
;
69 rev
.verbose_header
= 1;
70 rev
.show_root_diff
= 0;
71 setup_revisions(argc
, argv
, &rev
, NULL
);
72 if (rev
.grep_filter
) {
73 rev
.grep_filter
->regflags
|= REG_ICASE
;
74 compile_grep_patterns(rev
.grep_filter
);
76 prepare_revision_walk(&rev
);
78 html("<table class='list nowrap'>");
79 html("<tr class='nohover'><th class='left'>Date</th>"
80 "<th class='left'>Message</th>"
81 "<th class='left'>Files</th>"
82 "<th class='left'>Lines</th>"
83 "<th class='left'>Author</th></tr>\n");
88 for (i
= 0; i
< ofs
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
90 commit
->buffer
= NULL
;
91 free_commit_list(commit
->parents
);
92 commit
->parents
= NULL
;
95 for (i
= 0; i
< cnt
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
98 commit
->buffer
= NULL
;
99 free_commit_list(commit
->parents
);
100 commit
->parents
= NULL
;
104 html("<div class='pager'>");
106 html(" <a href='");
107 html(cgit_pageurl(cgit_query_repo
, cgit_query_page
,
108 fmt("h=%s&ofs=%d", tip
, ofs
-cnt
)));
109 html("'>[prev]</a> ");
112 if ((commit
= get_revision(&rev
)) != NULL
) {
113 html(" <a href='");
114 html(cgit_pageurl(cgit_query_repo
, "log",
115 fmt("h=%s&ofs=%d", tip
, ofs
+cnt
)));
116 html("'>[next]</a> ");