summaryrefslogtreecommitdiffabout
path: root/ui-tree.c
Unidiff
Diffstat (limited to 'ui-tree.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-tree.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ui-tree.c b/ui-tree.c
index df05ad3..7912784 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -1,33 +1,34 @@
1/* ui-tree.c: functions for tree output 1/* ui-tree.c: functions for tree output
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#include "html.h"
10 11
11char *curr_rev; 12char *curr_rev;
12char *match_path; 13char *match_path;
13int header = 0; 14int header = 0;
14 15
15static void print_object(const unsigned char *sha1, char *path) 16static void print_object(const unsigned char *sha1, char *path)
16{ 17{
17 enum object_type type; 18 enum object_type type;
18 char *buf; 19 char *buf;
19 unsigned long size, lineno, start, idx; 20 unsigned long size, lineno, start, idx;
20 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'>"; 21 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'>";
21 22
22 type = sha1_object_info(sha1, &size); 23 type = sha1_object_info(sha1, &size);
23 if (type == OBJ_BAD) { 24 if (type == OBJ_BAD) {
24 cgit_print_error(fmt("Bad object name: %s", 25 cgit_print_error(fmt("Bad object name: %s",
25 sha1_to_hex(sha1))); 26 sha1_to_hex(sha1)));
26 return; 27 return;
27 } 28 }
28 29
29 buf = read_sha1_file(sha1, &type, &size); 30 buf = read_sha1_file(sha1, &type, &size);
30 if (!buf) { 31 if (!buf) {
31 cgit_print_error(fmt("Error reading object %s", 32 cgit_print_error(fmt("Error reading object %s",
32 sha1_to_hex(sha1))); 33 sha1_to_hex(sha1)));
33 return; 34 return;
@@ -58,49 +59,49 @@ static void print_object(const unsigned char *sha1, char *path)
58} 59}
59 60
60 61
61static int ls_item(const unsigned char *sha1, const char *base, int baselen, 62static int ls_item(const unsigned char *sha1, const char *base, int baselen,
62 const char *pathname, unsigned int mode, int stage) 63 const char *pathname, unsigned int mode, int stage)
63{ 64{
64 char *name; 65 char *name;
65 char *fullpath; 66 char *fullpath;
66 enum object_type type; 67 enum object_type type;
67 unsigned long size = 0; 68 unsigned long size = 0;
68 69
69 name = xstrdup(pathname); 70 name = xstrdup(pathname);
70 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", 71 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "",
71 ctx.qry.path ? "/" : "", name); 72 ctx.qry.path ? "/" : "", name);
72 73
73 type = sha1_object_info(sha1, &size); 74 type = sha1_object_info(sha1, &size);
74 if (type == OBJ_BAD && !S_ISGITLINK(mode)) { 75 if (type == OBJ_BAD && !S_ISGITLINK(mode)) {
75 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", 76 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
76 name, 77 name,
77 sha1_to_hex(sha1)); 78 sha1_to_hex(sha1));
78 return 0; 79 return 0;
79 } 80 }
80 81
81 html("<tr><td class='ls-mode'>"); 82 html("<tr><td class='ls-mode'>");
82 html_filemode(mode); 83 cgit_print_filemode(mode);
83 html("</td><td>"); 84 html("</td><td>");
84 if (S_ISGITLINK(mode)) { 85 if (S_ISGITLINK(mode)) {
85 htmlf("<a class='ls-mod' href='"); 86 htmlf("<a class='ls-mod' href='");
86 html_attr(fmt(ctx.repo->module_link, 87 html_attr(fmt(ctx.repo->module_link,
87 name, 88 name,
88 sha1_to_hex(sha1))); 89 sha1_to_hex(sha1)));
89 html("'>"); 90 html("'>");
90 html_txt(name); 91 html_txt(name);
91 html("</a>"); 92 html("</a>");
92 } else if (S_ISDIR(mode)) { 93 } else if (S_ISDIR(mode)) {
93 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 94 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
94 curr_rev, fullpath); 95 curr_rev, fullpath);
95 } else { 96 } else {
96 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, 97 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head,
97 curr_rev, fullpath); 98 curr_rev, fullpath);
98 } 99 }
99 htmlf("</td><td class='ls-size'>%li</td>", size); 100 htmlf("</td><td class='ls-size'>%li</td>", size);
100 101
101 html("<td>"); 102 html("<td>");
102 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, 103 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,
103 fullpath, 0, NULL, NULL); 104 fullpath, 0, NULL, NULL);
104 html("</td></tr>\n"); 105 html("</td></tr>\n");
105 free(name); 106 free(name);
106 return 0; 107 return 0;