Unidiff1 files changed, 11 insertions, 1 deletions
|
|
|
@@ -19,4 +19,5 @@ static void print_object(const unsigned char *sha1, const char *path) |
19 | enum object_type type; |
19 | enum object_type type; |
20 | char *buf; |
20 | char *buf, *ext; |
21 | unsigned long size; |
21 | unsigned long size; |
| |
22 | struct string_list_item *mime; |
22 | |
23 | |
@@ -33,2 +34,10 @@ static void print_object(const unsigned char *sha1, const char *path) |
33 | } |
34 | } |
| |
35 | ctx.page.mimetype = NULL; |
| |
36 | ext = strrchr(path, '.'); |
| |
37 | if (ext && *(++ext)) { |
| |
38 | mime = string_list_lookup(ext, &ctx.cfg.mimetypes); |
| |
39 | if (mime) |
| |
40 | ctx.page.mimetype = (char *)mime->util; |
| |
41 | } |
| |
42 | if (!ctx.page.mimetype) { |
34 | if (buffer_is_binary(buf, size)) |
43 | if (buffer_is_binary(buf, size)) |
@@ -37,2 +46,3 @@ static void print_object(const unsigned char *sha1, const char *path) |
37 | ctx.page.mimetype = "text/plain"; |
46 | ctx.page.mimetype = "text/plain"; |
| |
47 | } |
38 | ctx.page.filename = fmt("%s", path); |
48 | ctx.page.filename = fmt("%s", path); |
|