author | Lars Hjemli <hjemli@gmail.com> | 2007-05-08 20:40:59 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-08 21:38:49 (UTC) |
commit | 61c3ca978c586c673aec618cb94210657278dda8 (patch) (unidiff) | |
tree | 7011987769e65ad0e7aa8b79f648357e9cd88c30 /ui-view.c | |
parent | 66cacd053ba900c8eb3b7962027370c84a97f990 (diff) | |
download | cgit-61c3ca978c586c673aec618cb94210657278dda8.zip cgit-61c3ca978c586c673aec618cb94210657278dda8.tar.gz cgit-61c3ca978c586c673aec618cb94210657278dda8.tar.bz2 |
Update to libgit 1.5.2-rc2
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-view.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1,41 +1,43 @@ | |||
1 | /* ui-view.c: functions to output _any_ object, given it's sha1 | 1 | /* ui-view.c: functions to output _any_ object, given it's sha1 |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | void cgit_print_view(const char *hex) | 11 | void cgit_print_view(const char *hex) |
12 | { | 12 | { |
13 | unsigned char sha1[20]; | 13 | unsigned char sha1[20]; |
14 | char type[20]; | 14 | enum object_type type; |
15 | unsigned char *buf; | 15 | unsigned char *buf; |
16 | unsigned long size; | 16 | unsigned long size; |
17 | 17 | ||
18 | if (get_sha1_hex(hex, sha1)){ | 18 | if (get_sha1_hex(hex, sha1)){ |
19 | cgit_print_error(fmt("Bad hex value: %s", hex)); | 19 | cgit_print_error(fmt("Bad hex value: %s", hex)); |
20 | return; | 20 | return; |
21 | } | 21 | } |
22 | 22 | ||
23 | if (sha1_object_info(sha1, type, &size)){ | 23 | type = sha1_object_info(sha1, &size); |
24 | cgit_print_error("Bad object name"); | 24 | if (type == OBJ_BAD) { |
25 | cgit_print_error(fmt("Bad object name: %s", hex)); | ||
25 | return; | 26 | return; |
26 | } | 27 | } |
27 | 28 | ||
28 | buf = read_sha1_file(sha1, type, &size); | 29 | buf = read_sha1_file(sha1, &type, &size); |
29 | if (!buf) { | 30 | if (!buf) { |
30 | cgit_print_error("Error reading object"); | 31 | cgit_print_error(fmt("Error reading object %s", hex)); |
31 | return; | 32 | return; |
32 | } | 33 | } |
33 | 34 | ||
34 | buf[size] = '\0'; | 35 | buf[size] = '\0'; |
35 | html("<table class='list'>\n"); | 36 | html("<table class='list'>\n"); |
36 | htmlf("<tr class='nohover'><th class='left'>%s %s, %li bytes</th></tr>\n", type, hex, size); | 37 | htmlf("<tr class='nohover'><th class='left'>%s %s, %li bytes</th></tr>\n", |
38 | typename(type), hex, size); | ||
37 | html("<tr><td class='blob'>\n"); | 39 | html("<tr><td class='blob'>\n"); |
38 | html_txt(buf); | 40 | html_txt(buf); |
39 | html("\n</td></tr>\n"); | 41 | html("\n</td></tr>\n"); |
40 | html("</table>\n"); | 42 | html("</table>\n"); |
41 | } | 43 | } |