Author: Lars Hjemli <hjemli@gmail.com>
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>
Makefile | 2 +- cgit.c | 3 +++ cgit.h | 2 ++ shared.c | 2 +- ui-refs.c | 30 ++++++++++++++++++++++++++++++
diff --git a/Makefile b/Makefile index 8e3da72f6cbc78a7d7237958f041f538ecd80fce..36b5ff68d6018751aa867ce5ee04c48a9e97401f 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ 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 diff --git a/cgit.c b/cgit.c index 1b85b1518818e47b2780f87e8a47081c05a38668..cc18ed4c5e336e900dca080e3f7062fbec916feb 100644 --- a/cgit.c +++ b/cgit.c @@ -103,6 +103,9 @@ 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; diff --git a/cgit.h b/cgit.h index a1fe5276f70b6faf02b0c9234fb4f23e38ff6c59..d9a15f42e5418143135036c0346daecef2878f47 100644 --- a/cgit.h +++ b/cgit.h @@ -28,6 +28,7 @@ #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 @@ -260,6 +261,7 @@ 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, diff --git a/shared.c b/shared.c index ff600db498a77664e1effa628bf7272e39c385e9..7eb2b0e26d8db080159f6ce3ee9fe9251853c6ce 100644 --- a/shared.c +++ b/shared.c @@ -66,7 +66,7 @@ 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++) diff --git a/ui-refs.c b/ui-refs.c new file mode 100644 index 0000000000000000000000000000000000000000..295f5ba5ba8698ed2fe088c01023baf50678d404 --- /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'> </td></tr>"); + cgit_print_tags(0); + } + + html("</table>"); +}