about summary refs log tree commit diff stats
path: root/ui-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-tree.c')
-rw-r--r--ui-tree.c35
1 files changed, 2 insertions, 33 deletions
diff --git a/ui-tree.c b/ui-tree.c index ca24a03..3925809 100644 --- a/ui-tree.c +++ b/ui-tree.c
@@ -84,37 +84,6 @@ static void print_binary_buffer(char *buf, unsigned long size)
84 html("</table>\n"); 84 html("</table>\n");
85} 85}
86 86
87static void set_title_from_path(const char *path)
88{
89 size_t path_len, path_index, path_last_end;
90 char *new_title;
91
92 if (!path)
93 return;
94
95 path_len = strlen(path);
96 new_title = xmalloc(path_len + 3 + strlen(ctx.page.title) + 1);
97 new_title[0] = '\0';
98
99 for (path_index = path_len, path_last_end = path_len; path_index-- > 0;) {
100 if (path[path_index] == '/') {
101 if (path_index == path_len - 1) {
102 path_last_end = path_index - 1;
103 continue;
104 }
105 strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1);
106 strcat(new_title, "\\");
107 path_last_end = path_index;
108 }
109 }
110 if (path_last_end)
111 strncat(new_title, path, path_last_end);
112
113 strcat(new_title, " - ");
114 strcat(new_title, ctx.page.title);
115 ctx.page.title = new_title;
116}
117
118static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev) 87static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
119{ 88{
120 enum object_type type; 89 enum object_type type;
@@ -135,7 +104,7 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
135 return; 104 return;
136 } 105 }
137 106
138 set_title_from_path(path); 107 cgit_set_title_from_path(path);
139 108
140 cgit_print_layout_start(); 109 cgit_print_layout_start();
141 htmlf("blob: %s (", sha1_to_hex(sha1)); 110 htmlf("blob: %s (", sha1_to_hex(sha1));
@@ -335,7 +304,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
335 304
336 if (S_ISDIR(mode)) { 305 if (S_ISDIR(mode)) {
337 walk_tree_ctx->state = 1; 306 walk_tree_ctx->state = 1;
338 set_title_from_path(buffer.buf); 307 cgit_set_title_from_path(buffer.buf);
339 strbuf_release(&buffer); 308 strbuf_release(&buffer);
340 ls_head(); 309 ls_head();
341 return READ_TREE_RECURSIVE; 310 return READ_TREE_RECURSIVE;