From d14d77fe95c3b6224b40df9b101dded0deea913c Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 16 Feb 2008 11:53:40 +0100 Subject: Introduce struct cgit_context This struct will hold all the cgit runtime information currently found in a multitude of global variables. The first cleanup removes all querystring-related variables. Signed-off-by: Lars Hjemli --- ui-commit.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ui-commit.c') diff --git a/ui-commit.c b/ui-commit.c index bd55a33..3b0919b 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -75,7 +75,7 @@ void print_fileinfo(struct fileinfo *info) html("]"); } htmlf("", class); - cgit_diff_link(info->new_path, NULL, NULL, cgit_query_head, curr_rev, + cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, curr_rev, NULL, info->new_path); if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) htmlf(" (%s from %s)", @@ -143,7 +143,7 @@ void cgit_print_commit(char *hex) int i; if (!hex) - hex = cgit_query_head; + hex = ctx.qry.head; curr_rev = hex; if (get_sha1(hex, sha1)) { @@ -175,7 +175,7 @@ void cgit_print_commit(char *hex) html("tree"); tmp = xstrdup(hex); cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, - cgit_query_head, tmp, NULL); + ctx.qry.head, tmp, NULL); html("\n"); for (p = commit->parents; p ; p = p->next) { parent = lookup_commit_reference(p->item->object.sha1); @@ -188,15 +188,15 @@ void cgit_print_commit(char *hex) html("parent" ""); cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, - cgit_query_head, sha1_to_hex(p->item->object.sha1)); + ctx.qry.head, sha1_to_hex(p->item->object.sha1)); html(" ("); - cgit_diff_link("diff", NULL, NULL, cgit_query_head, hex, + cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, sha1_to_hex(p->item->object.sha1), NULL); html(")"); } if (cgit_repo->snapshots) { html("download"); - cgit_print_snapshot_links(cgit_query_repo, cgit_query_head, + cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, hex, cgit_repo->snapshots); html(""); } @@ -218,7 +218,7 @@ void cgit_print_commit(char *hex) html("
"); htmlf("%d files changed, %d insertions, %d deletions (", files, total_adds, total_rems); - cgit_diff_link("show diff", NULL, NULL, cgit_query_head, hex, + cgit_diff_link("show diff", NULL, NULL, ctx.qry.head, hex, NULL, NULL); html(")
"); } -- cgit v1.2.1 From d1f3bbe9d22029f45a77bb938c176ccc0c827d46 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 16 Feb 2008 13:56:09 +0100 Subject: Move cgit_repo into cgit_context This removes the global variable which is used to keep track of the currently selected repository, and adds a new variable in the cgit_context structure. Signed-off-by: Lars Hjemli --- ui-commit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui-commit.c') diff --git a/ui-commit.c b/ui-commit.c index 3b0919b..25721ca 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -194,10 +194,10 @@ void cgit_print_commit(char *hex) sha1_to_hex(p->item->object.sha1), NULL); html(")"); } - if (cgit_repo->snapshots) { + if (ctx.repo->snapshots) { html("download"); cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, - hex, cgit_repo->snapshots); + hex, ctx.repo->snapshots); html(""); } html("\n"); -- cgit v1.2.1 From b1f9b9c1459cb9a30ebf80721aff6ef788d1f891 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 23 Feb 2008 22:45:33 +0100 Subject: Introduce html.h All html-functions can be quite easily separated from the rest of cgit, so lets do it; the only issue was html_filemode which uses some git-defined macros so the function is moved into ui-shared.c::cgit_print_filemode(). Signed-off-by: Lars Hjemli --- ui-commit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ui-commit.c') diff --git a/ui-commit.c b/ui-commit.c index 25721ca..ed25824 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -7,6 +7,7 @@ */ #include "cgit.h" +#include "html.h" static int files, slots; static int total_adds, total_rems, max_changes; @@ -62,16 +63,16 @@ void print_fileinfo(struct fileinfo *info) html(""); htmlf(""); if (is_null_sha1(info->new_sha1)) { - html_filemode(info->old_mode); + cgit_print_filemode(info->old_mode); } else { - html_filemode(info->new_mode); + cgit_print_filemode(info->new_mode); } if (info->old_mode != info->new_mode && !is_null_sha1(info->old_sha1) && !is_null_sha1(info->new_sha1)) { html("["); - html_filemode(info->old_mode); + cgit_print_filemode(info->old_mode); html("]"); } htmlf("", class); -- cgit v1.2.1 From a4d1ca1dc6ff8171694d9e2280b6075a1beced0c Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Mar 2008 16:50:57 +0100 Subject: Add ui-shared.h This is finally a proper headerfile for the shared ui-functions which used to reside in cgit.h Signed-off-by: Lars Hjemli --- ui-commit.c | 1 + 1 file changed, 1 insertion(+) (limited to 'ui-commit.c') diff --git a/ui-commit.c b/ui-commit.c index ed25824..8019e36 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -8,6 +8,7 @@ #include "cgit.h" #include "html.h" +#include "ui-shared.h" static int files, slots; static int total_adds, total_rems, max_changes; -- cgit v1.2.1