]>
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 inspect_files(struct diff_filepair
*pair
)
18 void print_commit(struct commit
*commit
)
21 struct commitinfo
*info
;
24 info
= cgit_parse_commit(commit
);
25 time
= gmtime(&commit
->date
);
27 strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M", time
);
30 char *qry
= fmt("id=%s", sha1_to_hex(commit
->object
.sha1
));
31 char *url
= cgit_pageurl(cgit_query_repo
, "commit", qry
);
32 html_link_open(url
, NULL
, NULL
);
33 html_ntxt(cgit_max_msg_len
, info
->subject
);
35 html("</td><td class='right'>");
38 cgit_diff_commit(commit
, inspect_files
);
41 html_txt(info
->author
);
43 cgit_free_commitinfo(info
);
47 void cgit_print_log(const char *tip
, int ofs
, int cnt
, char *grep
)
50 struct commit
*commit
;
51 const char *argv
[3] = {NULL
, tip
, NULL
};
56 argv
[argc
++] = fmt("--grep=%s", grep
);
57 init_revisions(&rev
, NULL
);
58 rev
.abbrev
= DEFAULT_ABBREV
;
59 rev
.commit_format
= CMIT_FMT_DEFAULT
;
60 rev
.verbose_header
= 1;
61 rev
.show_root_diff
= 0;
62 setup_revisions(argc
, argv
, &rev
, NULL
);
63 if (rev
.grep_filter
) {
64 rev
.grep_filter
->regflags
|= REG_ICASE
;
65 compile_grep_patterns(rev
.grep_filter
);
67 prepare_revision_walk(&rev
);
69 html("<table class='list nowrap'>");
70 html("<tr class='nohover'><th class='left'>Date</th>"
71 "<th class='left'>Message</th>"
72 "<th class='left'>Files</th>"
73 "<th class='left'>Author</th></tr>\n");
78 for (i
= 0; i
< ofs
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
80 commit
->buffer
= NULL
;
81 free_commit_list(commit
->parents
);
82 commit
->parents
= NULL
;
85 for (i
= 0; i
< cnt
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
88 commit
->buffer
= NULL
;
89 free_commit_list(commit
->parents
);
90 commit
->parents
= NULL
;
94 html("<div class='pager'>");
96 html(" <a href='");
97 html(cgit_pageurl(cgit_query_repo
, cgit_query_page
,
98 fmt("h=%s&ofs=%d", tip
, ofs
-cnt
)));
99 html("'>[prev]</a> ");
102 if ((commit
= get_revision(&rev
)) != NULL
) {
103 html(" <a href='");
104 html(cgit_pageurl(cgit_query_repo
, "log",
105 fmt("h=%s&ofs=%d", tip
, ofs
+cnt
)));
106 html("'>[next]</a> ");