]>
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)
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
, "commit", qry
);
25 html_link_open(url
, NULL
, NULL
);
26 html_txt(info
->subject
);
29 html_txt(info
->author
);
31 cgit_free_commitinfo(info
);
35 void cgit_print_log(const char *tip
, int ofs
, int cnt
)
38 struct commit
*commit
;
39 const char *argv
[2] = {NULL
, tip
};
42 init_revisions(&rev
, NULL
);
43 rev
.abbrev
= DEFAULT_ABBREV
;
44 rev
.commit_format
= CMIT_FMT_DEFAULT
;
45 rev
.verbose_header
= 1;
46 rev
.show_root_diff
= 0;
47 setup_revisions(2, argv
, &rev
, NULL
);
48 prepare_revision_walk(&rev
);
51 html("<table class='list log'>");
52 html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n");
57 for (i
= 0; i
< ofs
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
59 commit
->buffer
= NULL
;
60 free_commit_list(commit
->parents
);
61 commit
->parents
= NULL
;
64 for (i
= 0; i
< cnt
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
67 commit
->buffer
= NULL
;
68 free_commit_list(commit
->parents
);
69 commit
->parents
= NULL
;
73 html("<div class='pager'>");
75 html(" <a href='");
76 html(cgit_pageurl(cgit_query_repo
, cgit_query_page
,
77 fmt("h=%s&ofs=%d", tip
, ofs
-cnt
)));
78 html("'>[prev]</a> ");
81 if ((commit
= get_revision(&rev
)) != NULL
) {
82 html(" <a href='");
83 html(cgit_pageurl(cgit_query_repo
, "log",
84 fmt("h=%s&ofs=%d", tip
, ofs
+cnt
)));
85 html("'>[next]</a> ");