html("<tr><td class='linenumbers'><pre>");
idx = 0;
lineno = 0;
-
+
if (size) {
htmlf(numberfmt, ++lineno);
- while(idx < size - 1) { // skip absolute last newline
+ while (idx < size - 1) { // skip absolute last newline
if (buf[idx] == '\n')
htmlf(numberfmt, ++lineno);
idx++;
html("</table>\n");
}
-static void print_object(const unsigned char *sha1, char *path, const char *basename)
+static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
{
enum object_type type;
char *buf;
htmlf("blob: %s (", sha1_to_hex(sha1));
cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
- curr_rev, path);
+ rev, path);
html(")\n");
if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) {
static void ls_tree(const unsigned char *sha1, char *path)
{
struct tree *tree;
+ struct pathspec paths = {
+ .nr = 0
+ };
tree = parse_tree_indirect(sha1);
if (!tree) {
}
ls_head();
- read_tree_recursive(tree, "", 0, 1, NULL, ls_item, NULL);
+ read_tree_recursive(tree, "", 0, 1, &paths, ls_item, NULL);
ls_tail();
}
if (state == 0) {
memcpy(buffer, base, baselen);
- strcpy(buffer+baselen, pathname);
+ strcpy(buffer + baselen, pathname);
if (strcmp(match_path, buffer))
return READ_TREE_RECURSIVE;
ls_head();
return READ_TREE_RECURSIVE;
} else {
- print_object(sha1, buffer, pathname);
+ print_object(sha1, buffer, pathname, curr_rev);
return 0;
}
}
{
unsigned char sha1[20];
struct commit *commit;
- const char *paths[] = {path, NULL};
+ struct pathspec_item path_items = {
+ .match = path,
+ .len = path ? strlen(path) : 0
+ };
+ struct pathspec paths = {
+ .nr = path ? 1 : 0,
+ .items = &path_items
+ };
if (!rev)
rev = ctx.qry.head;
}
match_path = path;
- read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL);
+ read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, NULL);
ls_tail();
}