summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-10-27 08:36:53 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-27 08:53:27 (UTC)
commit7937d06090dd5e19145ec6fa8befc5770954b30c (patch) (side-by-side diff)
treebb058aa0b5e54aabcad6a2ca6416bcac4b636615
parent8efb05f98ad389d1b7f5aac17838401908622dad (diff)
downloadcgit-7937d06090dd5e19145ec6fa8befc5770954b30c.zip
cgit-7937d06090dd5e19145ec6fa8befc5770954b30c.tar.gz
cgit-7937d06090dd5e19145ec6fa8befc5770954b30c.tar.bz2
Add support for refs view
This enables the new urls $repo/refs, $repo/refs/heads and $repo/refs/tags, which can be used to print _all_ branches and/or tags. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--cgit.c3
-rw-r--r--cgit.h2
-rw-r--r--shared.c2
-rw-r--r--ui-refs.c30
5 files changed, 37 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 8e3da72..36b5ff6 100644
--- a/Makefile
+++ b/Makefile
@@ -13,13 +13,13 @@ GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
-include cgit.conf
EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \
- ui-snapshot.o ui-blob.o ui-tag.o
+ ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o
.PHONY: all git install clean distclean force-version get-git
all: cgit git
diff --git a/cgit.c b/cgit.c
index 1b85b15..cc18ed4 100644
--- a/cgit.c
+++ b/cgit.c
@@ -100,12 +100,15 @@ static void cgit_print_repo_page(struct cacheitem *item)
case CMD_TREE:
cgit_print_tree(cgit_query_sha1, cgit_query_path);
break;
case CMD_COMMIT:
cgit_print_commit(cgit_query_sha1);
break;
+ case CMD_REFS:
+ cgit_print_refs();
+ break;
case CMD_TAG:
cgit_print_tag(cgit_query_sha1);
break;
case CMD_DIFF:
cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path);
break;
diff --git a/cgit.h b/cgit.h
index a1fe527..d9a15f4 100644
--- a/cgit.h
+++ b/cgit.h
@@ -25,12 +25,13 @@
#define CMD_COMMIT 2
#define CMD_DIFF 3
#define CMD_TREE 4
#define CMD_BLOB 5
#define CMD_SNAPSHOT 6
#define CMD_TAG 7
+#define CMD_REFS 8
/*
* Dateformats used on misc. pages
*/
#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
#define FMT_SHORTDATE "%Y-%m-%d"
@@ -257,12 +258,13 @@ extern void cgit_print_tags(int maxcount);
extern void cgit_print_repolist(struct cacheitem *item);
extern void cgit_print_summary();
extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager);
extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
extern void cgit_print_tree(const char *rev, char *path);
extern void cgit_print_commit(char *hex);
+extern void cgit_print_refs();
extern void cgit_print_tag(char *revname);
extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
extern void cgit_print_snapshot(struct cacheitem *item, const char *head,
const char *hex, const char *prefix,
const char *filename, int snapshot);
extern void cgit_print_snapshot_links(const char *repo, const char *head,
diff --git a/shared.c b/shared.c
index ff600db..7eb2b0e 100644
--- a/shared.c
+++ b/shared.c
@@ -63,13 +63,13 @@ int cgit_query_ofs = 0;
int htmlfd = 0;
int cgit_get_cmd_index(const char *cmd)
{
static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
- "snapshot", "tag", NULL};
+ "snapshot", "tag", "refs", NULL};
int i;
for(i = 0; cmds[i]; i++)
if (!strcmp(cmd, cmds[i]))
return i + 1;
return 0;
diff --git a/ui-refs.c b/ui-refs.c
new file mode 100644
index 0000000..295f5ba
--- a/dev/null
+++ b/ui-refs.c
@@ -0,0 +1,30 @@
+/* ui-refs.c: browse symbolic refs
+ *
+ * Copyright (C) 2006 Lars Hjemli
+ *
+ * Licensed under GNU General Public License v2
+ * (see COPYING for full license text)
+ */
+
+#include "cgit.h"
+
+
+
+
+void cgit_print_refs()
+{
+
+ html("<table class='list nowrap'>");
+
+ if (cgit_query_path && !strncmp(cgit_query_path, "heads", 5))
+ cgit_print_branches(0);
+ else if (cgit_query_path && !strncmp(cgit_query_path, "tags", 4))
+ cgit_print_tags(0);
+ else {
+ cgit_print_branches(0);
+ html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
+ cgit_print_tags(0);
+ }
+
+ html("</table>");
+}