summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-blob.c2
-rw-r--r--ui-tree.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/ui-blob.c b/ui-blob.c
index 11589db..ab44659 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -15,29 +15,29 @@ void cgit_print_blob(const char *hex, char *path)
unsigned char sha1[20];
enum object_type type;
unsigned char *buf;
unsigned long size;
if (get_sha1_hex(hex, sha1)){
cgit_print_error(fmt("Bad hex value: %s", hex));
return;
}
type = sha1_object_info(sha1, &size);
if (type == OBJ_BAD) {
cgit_print_error(fmt("Bad object name: %s", hex));
return;
}
buf = read_sha1_file(sha1, &type, &size);
if (!buf) {
cgit_print_error(fmt("Error reading object %s", hex));
return;
}
buf[size] = '\0';
- ctx.page.mimetype = "text/plain";
+ ctx.page.mimetype = NULL;
ctx.page.filename = path;
cgit_print_http_headers(&ctx);
write(htmlfd, buf, size);
}
diff --git a/ui-tree.c b/ui-tree.c
index 9be3140..2f052c7 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -15,49 +15,50 @@ char *match_path;
int header = 0;
static void print_object(const unsigned char *sha1, char *path)
{
enum object_type type;
char *buf;
unsigned long size, lineno, start, idx;
const char *linefmt = "<tr><td class='no'><a id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a></td><td class='txt'>";
type = sha1_object_info(sha1, &size);
if (type == OBJ_BAD) {
cgit_print_error(fmt("Bad object name: %s",
sha1_to_hex(sha1)));
return;
}
buf = read_sha1_file(sha1, &type, &size);
if (!buf) {
cgit_print_error(fmt("Error reading object %s",
sha1_to_hex(sha1)));
return;
}
html(" blob: <a href='");
- html_attr(cgit_pageurl(ctx.qry.repo, "blob", fmt("id=%s", sha1_to_hex(sha1))));
+ html_attr(cgit_pageurl(ctx.qry.repo, "blob",
+ fmt("id=%s&path=%s", sha1_to_hex(sha1), path)));
htmlf("'>%s</a>",sha1_to_hex(sha1));
html("<table summary='blob content' class='blob'>\n");
idx = 0;
start = 0;
lineno = 0;
while(idx < size) {
if (buf[idx] == '\n') {
buf[idx] = '\0';
htmlf(linefmt, ++lineno);
html_txt(buf + start);
html("</td></tr>\n");
start = idx + 1;
}
idx++;
}
htmlf(linefmt, ++lineno);
html_txt(buf + start);
html("</td></tr>\n");
html("</table>\n");
}
static int ls_item(const unsigned char *sha1, const char *base, int baselen,