]>
git.cameronkatri.com Git - cgit.git/blob - ui-log.c
31331ef4c35028ab6fbcfe7cf5cf8cb49c875cad
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)
11 void print_commit(struct commit
*commit
)
14 struct commitinfo
*info
;
17 info
= cgit_parse_commit(commit
);
18 time
= gmtime(&commit
->date
);
20 strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M:%S", time
);
23 char *qry
= fmt("id=%s", sha1_to_hex(commit
->object
.sha1
));
24 char *url
= cgit_pageurl(cgit_query_repo
, "view", qry
);
25 html_link_open(url
, NULL
, NULL
);
26 html_txt(info
->subject
);
29 html_txt(info
->author
);
30 html("</td><td><a href='");
31 html_attr(cgit_pageurl(cgit_query_repo
, "tree",
33 sha1_to_hex(commit
->tree
->object
.sha1
))));
37 free(info
->committer
);
43 void cgit_print_log(const char *tip
, int ofs
, int cnt
)
46 struct commit
*commit
;
47 const char *argv
[2] = {NULL
, tip
};
50 init_revisions(&rev
, NULL
);
51 rev
.abbrev
= DEFAULT_ABBREV
;
52 rev
.commit_format
= CMIT_FMT_DEFAULT
;
53 rev
.verbose_header
= 1;
54 rev
.show_root_diff
= 0;
55 setup_revisions(2, argv
, &rev
, NULL
);
56 prepare_revision_walk(&rev
);
59 html("<table class='list'>");
60 html("<tr><th>Date</th><th>Message</th><th>Author</th><th>Link</th></tr>\n");
65 for (i
= 0; i
< ofs
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
67 commit
->buffer
= NULL
;
68 free_commit_list(commit
->parents
);
69 commit
->parents
= NULL
;
72 for (i
= 0; i
< cnt
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
75 commit
->buffer
= NULL
;
76 free_commit_list(commit
->parents
);
77 commit
->parents
= NULL
;
81 html("<div class='pager'>");
83 html(" <a href='");
84 html(cgit_pageurl(cgit_query_repo
, cgit_query_page
,
85 fmt("h=%s&ofs=%d", tip
, ofs
-cnt
)));
86 html("'>[prev]</a> ");
89 if ((commit
= get_revision(&rev
)) != NULL
) {
90 html(" <a href='");
91 html(cgit_pageurl(cgit_query_repo
, "log",
92 fmt("h=%s&ofs=%d", tip
, ofs
+cnt
)));
93 html("'>[next]</a> ");