aboutsummaryrefslogtreecommitdiffstats
path: root/ui-tree.c
diff options
context:
space:
mode:
authorJeff Smith <whydoubt@gmail.com>2017-10-01 23:39:06 -0500
committerJohn Keeping <john@keeping.me.uk>2017-10-03 19:19:34 +0100
commit9337c7ee83221d48d02c3c7b5c9dcbaca23ad92f (patch)
treed78c2311f4cffe8870e3966d09b5045c6166c4a7 /ui-tree.c
parent70787254b270b1505aa8427813f64131be5df86c (diff)
downloadcgit-9337c7ee83221d48d02c3c7b5c9dcbaca23ad92f.tar.gz
cgit-9337c7ee83221d48d02c3c7b5c9dcbaca23ad92f.tar.bz2
cgit-9337c7ee83221d48d02c3c7b5c9dcbaca23ad92f.zip
ui-tree: move set_title_from_path to ui-shared
The ui-blame code will also need to call set_title_from_path, so go ahead and move it to ui-shared. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: John Keeping <john@keeping.me.uk>
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)
html("</table>\n");
}
-static void set_title_from_path(const char *path)
-{
- size_t path_len, path_index, path_last_end;
- char *new_title;
-
- if (!path)
- return;
-
- path_len = strlen(path);
- new_title = xmalloc(path_len + 3 + strlen(ctx.page.title) + 1);
- new_title[0] = '\0';
-
- for (path_index = path_len, path_last_end = path_len; path_index-- > 0;) {
- if (path[path_index] == '/') {
- if (path_index == path_len - 1) {
- path_last_end = path_index - 1;
- continue;
- }
- strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1);
- strcat(new_title, "\\");
- path_last_end = path_index;
- }
- }
- if (path_last_end)
- strncat(new_title, path, path_last_end);
-
- strcat(new_title, " - ");
- strcat(new_title, ctx.page.title);
- ctx.page.title = new_title;
-}
-
static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
{
enum object_type type;
@@ -135,7 +104,7 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
return;
}
- set_title_from_path(path);
+ cgit_set_title_from_path(path);
cgit_print_layout_start();
htmlf("blob: %s (", sha1_to_hex(sha1));
@@ -335,7 +304,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
if (S_ISDIR(mode)) {
walk_tree_ctx->state = 1;
- set_title_from_path(buffer.buf);
+ cgit_set_title_from_path(buffer.buf);
strbuf_release(&buffer);
ls_head();
return READ_TREE_RECURSIVE;