summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile4
-rw-r--r--cgit.c2
m---------git0
-rw-r--r--ui-commit.c2
-rw-r--r--ui-log.c2
-rw-r--r--ui-plain.c2
-rw-r--r--ui-stats.c8
7 files changed, 10 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 3e5a38d..2a15469 100644
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,32 @@
CGIT_VERSION = v0.8.3.3
CGIT_SCRIPT_NAME = cgit.cgi
CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
CGIT_CONFIG = /etc/cgitrc
CACHE_ROOT = /var/cache/cgit
SHA1_HEADER = <openssl/sha.h>
-GIT_VER = 1.7.0
+GIT_VER = 1.7.2.2
GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
INSTALL = install
# Define NO_STRCASESTR if you don't have strcasestr.
#
# Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
# implementation (slower).
#
# Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
#
#-include config.mak
#
# Platform specific tweaks
#
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
ifeq ($(uname_O),Cygwin)
NO_STRCASESTR = YesPlease
NEEDS_LIBICONV = YesPlease
@@ -50,49 +50,49 @@ else # "make -w"
NO_SUBDIR = :
endif
ifndef V
QUIET_CC = @echo ' ' CC $@;
QUIET_MM = @echo ' ' MM $@;
QUIET_SUBDIR0 = +@subdir=
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
$(MAKE) $(PRINT_DIR) -C $$subdir
endif
#
# Define a pattern rule for automatic dependency building
#
%.d: %.c
$(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
#
# Define a pattern rule for silent object building
#
%.o: %.c
$(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
-EXTLIBS = git/libgit.a git/xdiff/lib.a -lz
+EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
OBJECTS =
OBJECTS += cache.o
OBJECTS += cgit.o
OBJECTS += cmd.o
OBJECTS += configfile.o
OBJECTS += html.o
OBJECTS += parsing.o
OBJECTS += scan-tree.o
OBJECTS += shared.o
OBJECTS += ui-atom.o
OBJECTS += ui-blob.o
OBJECTS += ui-clone.o
OBJECTS += ui-commit.o
OBJECTS += ui-diff.o
OBJECTS += ui-log.o
OBJECTS += ui-patch.o
OBJECTS += ui-plain.o
OBJECTS += ui-refs.o
OBJECTS += ui-repolist.o
OBJECTS += ui-shared.o
OBJECTS += ui-snapshot.o
OBJECTS += ui-ssdiff.o
OBJECTS += ui-stats.o
OBJECTS += ui-summary.o
diff --git a/cgit.c b/cgit.c
index 4f2c752..d6146e2 100644
--- a/cgit.c
+++ b/cgit.c
@@ -1,49 +1,49 @@
/* cgit.c: cgi for the git scm
*
* Copyright (C) 2006 Lars Hjemli
* Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com>
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
#include "cache.h"
#include "cmd.h"
#include "configfile.h"
#include "html.h"
#include "ui-shared.h"
#include "ui-stats.h"
#include "scan-tree.h"
const char *cgit_version = CGIT_VERSION;
void add_mimetype(const char *name, const char *value)
{
struct string_list_item *item;
- item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes);
+ item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name));
item->util = xstrdup(value);
}
struct cgit_filter *new_filter(const char *cmd, int extra_args)
{
struct cgit_filter *f;
if (!cmd || !cmd[0])
return NULL;
f = xmalloc(sizeof(struct cgit_filter));
f->cmd = xstrdup(cmd);
f->argv = xmalloc((2 + extra_args) * sizeof(char *));
f->argv[0] = f->cmd;
f->argv[1] = NULL;
return f;
}
static void process_cached_repolist(const char *path);
void repo_config(struct cgit_repo *repo, const char *name, const char *value)
{
if (!strcmp(name, "name"))
repo->name = xstrdup(value);
diff --git a/git b/git
-Subproject e923eaeb901ff056421b9007adcbbce271caa7b
+Subproject 8c67c392e1620fc3b749aa9e0b8da13bd84226f
diff --git a/ui-commit.c b/ui-commit.c
index 45af450..2b4f677 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -15,49 +15,49 @@
void cgit_print_commit(char *hex, const char *prefix)
{
struct commit *commit, *parent;
struct commitinfo *info, *parent_info;
struct commit_list *p;
struct strbuf notes = STRBUF_INIT;
unsigned char sha1[20];
char *tmp, *tmp2;
int parents = 0;
if (!hex)
hex = ctx.qry.head;
if (get_sha1(hex, sha1)) {
cgit_print_error(fmt("Bad object id: %s", hex));
return;
}
commit = lookup_commit_reference(sha1);
if (!commit) {
cgit_print_error(fmt("Bad commit reference: %s", hex));
return;
}
info = cgit_parse_commit(commit);
- get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
+ format_note(NULL, sha1, &notes, PAGE_ENCODING, 0);
load_ref_decorations(DECORATE_FULL_REFS);
html("<table summary='commit info' class='commit-info'>\n");
html("<tr><th>author</th><td>");
html_txt(info->author);
if (!ctx.cfg.noplainemail) {
html(" ");
html_txt(info->author_email);
}
html("</td><td class='right'>");
cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>committer</th><td>");
html_txt(info->committer);
if (!ctx.cfg.noplainemail) {
html(" ");
html_txt(info->committer_email);
}
html("</td><td class='right'>");
cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>commit</th><td colspan='2' class='sha1'>");
tmp = sha1_to_hex(commit->object.sha1);
diff --git a/ui-log.c b/ui-log.c
index 7f38d2a..0536b23 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -91,49 +91,49 @@ void print_commit(struct commit *commit)
cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
html_link_close();
htmlf("</td><td%s>",
ctx.qry.showmsg ? " class='logsubject'" : "");
cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0);
show_commit_decorations(commit);
html("</td><td>");
html_txt(info->author);
if (ctx.repo->enable_log_filecount) {
files = 0;
add_lines = 0;
rem_lines = 0;
cgit_diff_commit(commit, inspect_files);
html("</td><td>");
htmlf("%d", files);
if (ctx.repo->enable_log_linecount) {
html("</td><td>");
htmlf("-%d/+%d", rem_lines, add_lines);
}
}
html("</td></tr>\n");
if (ctx.qry.showmsg) {
struct strbuf notes = STRBUF_INIT;
- get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
+ format_note(NULL, commit->object.sha1, &notes, PAGE_ENCODING, 0);
if (ctx.repo->enable_log_filecount) {
cols++;
if (ctx.repo->enable_log_linecount)
cols++;
}
htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
cols);
html_txt(info->msg);
html("</td></tr>\n");
if (notes.len != 0) {
html("<tr class='nohover'>");
html("<td class='lognotes-label'>Notes:</td>");
htmlf("<td colspan='%d' class='lognotes'>",
cols);
html_txt(notes.buf);
html("</td></tr>\n");
}
strbuf_release(&notes);
}
cgit_free_commitinfo(info);
}
static const char *disambiguate_ref(const char *ref)
diff --git a/ui-plain.c b/ui-plain.c
index da76406..1b2b672 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -13,49 +13,49 @@
int match_baselen;
int match;
static void print_object(const unsigned char *sha1, const char *path)
{
enum object_type type;
char *buf, *ext;
unsigned long size;
struct string_list_item *mime;
type = sha1_object_info(sha1, &size);
if (type == OBJ_BAD) {
html_status(404, "Not found", 0);
return;
}
buf = read_sha1_file(sha1, &type, &size);
if (!buf) {
html_status(404, "Not found", 0);
return;
}
ctx.page.mimetype = NULL;
ext = strrchr(path, '.');
if (ext && *(++ext)) {
- mime = string_list_lookup(ext, &ctx.cfg.mimetypes);
+ mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
if (mime)
ctx.page.mimetype = (char *)mime->util;
}
if (!ctx.page.mimetype) {
if (buffer_is_binary(buf, size))
ctx.page.mimetype = "application/octet-stream";
else
ctx.page.mimetype = "text/plain";
}
ctx.page.filename = fmt("%s", path);
ctx.page.size = size;
ctx.page.etag = sha1_to_hex(sha1);
cgit_print_http_headers(&ctx);
html_raw(buf, size);
match = 1;
}
static void print_dir(const unsigned char *sha1, const char *path,
const char *base)
{
char *fullpath;
if (path[0] || base[0])
fullpath = fmt("/%s%s/", base, path);
else
diff --git a/ui-stats.c b/ui-stats.c
index bdaf9cc..50c2540 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -154,60 +154,60 @@ int cgit_find_stats_period(const char *expr, struct cgit_period **period)
return 0;
}
const char *cgit_find_stats_periodname(int idx)
{
if (idx > 0 && idx < 4)
return periods[idx - 1].name;
else
return "";
}
static void add_commit(struct string_list *authors, struct commit *commit,
struct cgit_period *period)
{
struct commitinfo *info;
struct string_list_item *author, *item;
struct authorstat *authorstat;
struct string_list *items;
char *tmp;
struct tm *date;
time_t t;
info = cgit_parse_commit(commit);
tmp = xstrdup(info->author);
- author = string_list_insert(tmp, authors);
+ author = string_list_insert(authors, tmp);
if (!author->util)
author->util = xcalloc(1, sizeof(struct authorstat));
else
free(tmp);
authorstat = author->util;
items = &authorstat->list;
t = info->committer_date;
date = gmtime(&t);
period->trunc(date);
tmp = xstrdup(period->pretty(date));
- item = string_list_insert(tmp, items);
+ item = string_list_insert(items, tmp);
if (item->util)
free(tmp);
item->util++;
authorstat->total++;
cgit_free_commitinfo(info);
}
static int cmp_total_commits(const void *a1, const void *a2)
{
const struct string_list_item *i1 = a1;
const struct string_list_item *i2 = a2;
const struct authorstat *auth1 = i1->util;
const struct authorstat *auth2 = i2->util;
return auth2->total - auth1->total;
}
/* Walk the commit DAG and collect number of commits per author per
* timeperiod into a nested string_list collection.
*/
struct string_list collect_stats(struct cgit_context *ctx,
struct cgit_period *period)
{
struct string_list authors;
@@ -258,49 +258,49 @@ void print_combined_authorrow(struct string_list *authors, int from, int to,
struct string_list *items;
struct string_list_item *date;
time_t now;
long i, j, total, subtotal;
struct tm *tm;
char *tmp;
time(&now);
tm = gmtime(&now);
period->trunc(tm);
for (i = 1; i < period->count; i++)
period->dec(tm);
total = 0;
htmlf("<tr><td class='%s'>%s</td>", leftclass,
fmt(name, to - from + 1));
for (j = 0; j < period->count; j++) {
tmp = period->pretty(tm);
period->inc(tm);
subtotal = 0;
for (i = from; i <= to; i++) {
author = &authors->items[i];
authorstat = author->util;
items = &authorstat->list;
- date = string_list_lookup(tmp, items);
+ date = string_list_lookup(items, tmp);
if (date)
subtotal += (size_t)date->util;
}
htmlf("<td class='%s'>%d</td>", centerclass, subtotal);
total += subtotal;
}
htmlf("<td class='%s'>%d</td></tr>", rightclass, total);
}
void print_authors(struct string_list *authors, int top,
struct cgit_period *period)
{
struct string_list_item *author;
struct authorstat *authorstat;
struct string_list *items;
struct string_list_item *date;
time_t now;
long i, j, total;
struct tm *tm;
char *tmp;
time(&now);
tm = gmtime(&now);
period->trunc(tm);
@@ -310,49 +310,49 @@ void print_authors(struct string_list *authors, int top,
html("<table class='stats'><tr><th>Author</th>");
for (j = 0; j < period->count; j++) {
tmp = period->pretty(tm);
htmlf("<th>%s</th>", tmp);
period->inc(tm);
}
html("<th>Total</th></tr>\n");
if (top <= 0 || top > authors->nr)
top = authors->nr;
for (i = 0; i < top; i++) {
author = &authors->items[i];
html("<tr><td class='left'>");
html_txt(author->string);
html("</td>");
authorstat = author->util;
items = &authorstat->list;
total = 0;
for (j = 0; j < period->count; j++)
period->dec(tm);
for (j = 0; j < period->count; j++) {
tmp = period->pretty(tm);
period->inc(tm);
- date = string_list_lookup(tmp, items);
+ date = string_list_lookup(items, tmp);
if (!date)
html("<td>0</td>");
else {
htmlf("<td>%d</td>", date->util);
total += (size_t)date->util;
}
}
htmlf("<td class='sum'>%d</td></tr>", total);
}
if (top < authors->nr)
print_combined_authorrow(authors, top, authors->nr - 1,
"Others (%d)", "left", "", "sum", period);
print_combined_authorrow(authors, 0, authors->nr - 1, "Total",
"total", "sum", "sum", period);
html("</table>");
}
/* Create a sorted string_list with one entry per author. The util-field
* for each author is another string_list which is used to calculate the
* number of commits per time-interval.
*/
void cgit_show_stats(struct cgit_context *ctx)