summaryrefslogtreecommitdiffabout
path: root/ui-tree.c
Unidiff
Diffstat (limited to 'ui-tree.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 7cae85a..df05ad3 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -38,97 +38,97 @@ static void print_object(const unsigned char *sha1, char *path)
38 htmlf("'>%s</a>",sha1_to_hex(sha1)); 38 htmlf("'>%s</a>",sha1_to_hex(sha1));
39 39
40 html("<table summary='blob content' class='blob'>\n"); 40 html("<table summary='blob content' class='blob'>\n");
41 idx = 0; 41 idx = 0;
42 start = 0; 42 start = 0;
43 lineno = 0; 43 lineno = 0;
44 while(idx < size) { 44 while(idx < size) {
45 if (buf[idx] == '\n') { 45 if (buf[idx] == '\n') {
46 buf[idx] = '\0'; 46 buf[idx] = '\0';
47 htmlf(linefmt, ++lineno); 47 htmlf(linefmt, ++lineno);
48 html_txt(buf + start); 48 html_txt(buf + start);
49 html("</td></tr>\n"); 49 html("</td></tr>\n");
50 start = idx + 1; 50 start = idx + 1;
51 } 51 }
52 idx++; 52 idx++;
53 } 53 }
54 htmlf(linefmt, ++lineno); 54 htmlf(linefmt, ++lineno);
55 html_txt(buf + start); 55 html_txt(buf + start);
56 html("</td></tr>\n"); 56 html("</td></tr>\n");
57 html("</table>\n"); 57 html("</table>\n");
58} 58}
59 59
60 60
61static int ls_item(const unsigned char *sha1, const char *base, int baselen, 61static int ls_item(const unsigned char *sha1, const char *base, int baselen,
62 const char *pathname, unsigned int mode, int stage) 62 const char *pathname, unsigned int mode, int stage)
63{ 63{
64 char *name; 64 char *name;
65 char *fullpath; 65 char *fullpath;
66 enum object_type type; 66 enum object_type type;
67 unsigned long size = 0; 67 unsigned long size = 0;
68 68
69 name = xstrdup(pathname); 69 name = xstrdup(pathname);
70 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", 70 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "",
71 ctx.qry.path ? "/" : "", name); 71 ctx.qry.path ? "/" : "", name);
72 72
73 type = sha1_object_info(sha1, &size); 73 type = sha1_object_info(sha1, &size);
74 if (type == OBJ_BAD && !S_ISGITLINK(mode)) { 74 if (type == OBJ_BAD && !S_ISGITLINK(mode)) {
75 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", 75 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
76 name, 76 name,
77 sha1_to_hex(sha1)); 77 sha1_to_hex(sha1));
78 return 0; 78 return 0;
79 } 79 }
80 80
81 html("<tr><td class='ls-mode'>"); 81 html("<tr><td class='ls-mode'>");
82 html_filemode(mode); 82 html_filemode(mode);
83 html("</td><td>"); 83 html("</td><td>");
84 if (S_ISGITLINK(mode)) { 84 if (S_ISGITLINK(mode)) {
85 htmlf("<a class='ls-mod' href='"); 85 htmlf("<a class='ls-mod' href='");
86 html_attr(fmt(cgit_repo->module_link, 86 html_attr(fmt(ctx.repo->module_link,
87 name, 87 name,
88 sha1_to_hex(sha1))); 88 sha1_to_hex(sha1)));
89 html("'>"); 89 html("'>");
90 html_txt(name); 90 html_txt(name);
91 html("</a>"); 91 html("</a>");
92 } else if (S_ISDIR(mode)) { 92 } else if (S_ISDIR(mode)) {
93 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 93 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
94 curr_rev, fullpath); 94 curr_rev, fullpath);
95 } else { 95 } else {
96 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, 96 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head,
97 curr_rev, fullpath); 97 curr_rev, fullpath);
98 } 98 }
99 htmlf("</td><td class='ls-size'>%li</td>", size); 99 htmlf("</td><td class='ls-size'>%li</td>", size);
100 100
101 html("<td>"); 101 html("<td>");
102 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, 102 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,
103 fullpath, 0, NULL, NULL); 103 fullpath, 0, NULL, NULL);
104 html("</td></tr>\n"); 104 html("</td></tr>\n");
105 free(name); 105 free(name);
106 return 0; 106 return 0;
107} 107}
108 108
109static void ls_head() 109static void ls_head()
110{ 110{
111 html("<table summary='tree listing' class='list'>\n"); 111 html("<table summary='tree listing' class='list'>\n");
112 html("<tr class='nohover'>"); 112 html("<tr class='nohover'>");
113 html("<th class='left'>Mode</th>"); 113 html("<th class='left'>Mode</th>");
114 html("<th class='left'>Name</th>"); 114 html("<th class='left'>Name</th>");
115 html("<th class='right'>Size</th>"); 115 html("<th class='right'>Size</th>");
116 html("<th/>"); 116 html("<th/>");
117 html("</tr>\n"); 117 html("</tr>\n");
118 header = 1; 118 header = 1;
119} 119}
120 120
121static void ls_tail() 121static void ls_tail()
122{ 122{
123 if (!header) 123 if (!header)
124 return; 124 return;
125 html("</table>\n"); 125 html("</table>\n");
126 header = 0; 126 header = 0;
127} 127}
128 128
129static void ls_tree(const unsigned char *sha1, char *path) 129static void ls_tree(const unsigned char *sha1, char *path)
130{ 130{
131 struct tree *tree; 131 struct tree *tree;
132 132
133 tree = parse_tree_indirect(sha1); 133 tree = parse_tree_indirect(sha1);
134 if (!tree) { 134 if (!tree) {