X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/9a8f88658d51aeb86a79ac1121de13562ad2601f..f3c1a187fe2bc33f8423cd535d5045899699995b:/ui-commit.c diff --git a/ui-commit.c b/ui-commit.c index 1c0e7e5..ed25824 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -1,70 +1,205 @@ +/* ui-commit.c: generate commit view + * + * Copyright (C) 2006 Lars Hjemli + * + * Licensed under GNU General Public License v2 + * (see COPYING for full license text) + */ + #include "cgit.h" +#include "html.h" + +static int files, slots; +static int total_adds, total_rems, max_changes; +static int lines_added, lines_removed; +static char *curr_rev; + +static struct fileinfo { + char status; + unsigned char old_sha1[20]; + unsigned char new_sha1[20]; + unsigned short old_mode; + unsigned short new_mode; + char *old_path; + char *new_path; + unsigned int added; + unsigned int removed; +} *items; -void cgit_print_date(unsigned long secs) + +void print_fileinfo(struct fileinfo *info) { - char buf[32]; - struct tm *time; + char *class; - time = gmtime(&secs); - strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); - html_txt(buf); - + switch (info->status) { + case DIFF_STATUS_ADDED: + class = "add"; + break; + case DIFF_STATUS_COPIED: + class = "cpy"; + break; + case DIFF_STATUS_DELETED: + class = "del"; + break; + case DIFF_STATUS_MODIFIED: + class = "upd"; + break; + case DIFF_STATUS_RENAMED: + class = "mov"; + break; + case DIFF_STATUS_TYPE_CHANGED: + class = "typ"; + break; + case DIFF_STATUS_UNKNOWN: + class = "unk"; + break; + case DIFF_STATUS_UNMERGED: + class = "stg"; + break; + default: + die("bug: unhandled diff status %c", info->status); + } + + html("
| ", + info->added * 100.0 / max_changes); + htmlf(" | ", + info->removed * 100.0 / max_changes); + htmlf(" | ", + (max_changes - info->removed - info->added) * 100.0 / max_changes); + html(" |
| author | ");
+ html("
");
@@ -73,8 +208,20 @@ void cgit_print_commit(const char *hex)
html(" ");
html_txt(info->msg);
html(" ");
- free(info->author);
- free(info->committer);
- free(info->subject);
- free(info);
+ if (!(commit->parents && commit->parents->next && commit->parents->next->next)) {
+ html("Diffstat ");
+ html(" | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|