]>
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 static int get_one_line(char *txt
)
15 for(t
=txt
; *t
!= '\n' && t
!= '\0'; t
++)
21 static void cgit_print_commit_shortlog(struct commit
*commit
)
24 char *tree
= NULL
, *author
= NULL
, *subject
= NULL
;
30 h
= t
= commit
->buffer
;
32 if (strncmp(h
, "tree ", 5))
33 die("Bad commit format: %s",
34 sha1_to_hex(commit
->object
.sha1
));
36 len
= get_one_line(h
);
40 while (!strncmp(h
, "parent ", 7))
41 h
+= get_one_line(h
) + 2;
43 if (!strncmp(h
, "author ", 7)) {
45 h
+= get_one_line(h
) + 2;
47 while(t
!=h
&& *t
!='<')
51 while(--t
!=author
&& *t
==' ')
53 while(++p
!=h
&& *p
!='>')
55 while(++p
!=h
&& !isdigit(*p
))
59 while(++p
&& isdigit(*p
))
66 while((len
= get_one_line(h
)) > 0)
70 len
= get_one_line(h
);
75 strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M:%S", time
);
78 char *qry
= fmt("id=%s", sha1_to_hex(commit
->object
.sha1
));
79 char *url
= cgit_pageurl(cgit_query_repo
, "view", qry
);
80 html_link_open(url
, NULL
, NULL
);
88 void cgit_print_log(const char *tip
, int ofs
, int cnt
)
91 struct commit
*commit
;
92 const char *argv
[2] = {NULL
, tip
};
95 init_revisions(&rev
, NULL
);
96 rev
.abbrev
= DEFAULT_ABBREV
;
97 rev
.commit_format
= CMIT_FMT_DEFAULT
;
98 rev
.verbose_header
= 1;
99 rev
.show_root_diff
= 0;
100 setup_revisions(2, argv
, &rev
, NULL
);
101 prepare_revision_walk(&rev
);
103 html("<h2>Log</h2>");
104 html("<table class='list'>");
105 html("<tr><th>Date</th><th>Message</th><th>Author</th></tr>\n");
106 while ((commit
= get_revision(&rev
)) != NULL
&& n
++ < 100) {
107 cgit_print_commit_shortlog(commit
);
108 free(commit
->buffer
);
109 commit
->buffer
= NULL
;
110 free_commit_list(commit
->parents
);
111 commit
->parents
= NULL
;