Compare commits
10 Commits
b1739247b1
...
79e81e35ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79e81e35ca | ||
|
|
e2e7177718 | ||
|
|
5258c297ba | ||
|
|
6dbbffe015 | ||
|
|
62eb8db452 | ||
|
|
d889cae811 | ||
|
|
4ffadc1e0c | ||
|
|
bd6f5683f6 | ||
|
|
f69626c68e | ||
|
|
cef27b670a |
10
Makefile
10
Makefile
@ -2,11 +2,11 @@ all::
|
|||||||
|
|
||||||
CGIT_VERSION = v1.2.3
|
CGIT_VERSION = v1.2.3
|
||||||
CGIT_SCRIPT_NAME = cgit.cgi
|
CGIT_SCRIPT_NAME = cgit.cgi
|
||||||
CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
|
CGIT_SCRIPT_PATH = /srv/cgit/
|
||||||
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
|
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
|
||||||
CGIT_CONFIG = /etc/cgitrc
|
CGIT_CONFIG = /dev/null
|
||||||
CACHE_ROOT = /var/cache/cgit
|
CACHE_ROOT = /srv/cgit/cache/cgit
|
||||||
prefix = /usr/local
|
prefix = /usr/server/cgit
|
||||||
libdir = $(prefix)/lib
|
libdir = $(prefix)/lib
|
||||||
filterdir = $(libdir)/cgit/filters
|
filterdir = $(libdir)/cgit/filters
|
||||||
docdir = $(prefix)/share/doc/cgit
|
docdir = $(prefix)/share/doc/cgit
|
||||||
@ -14,7 +14,7 @@ htmldir = $(docdir)
|
|||||||
pdfdir = $(docdir)
|
pdfdir = $(docdir)
|
||||||
mandir = $(prefix)/share/man
|
mandir = $(prefix)/share/man
|
||||||
SHA1_HEADER = <openssl/sha.h>
|
SHA1_HEADER = <openssl/sha.h>
|
||||||
GIT_VER = 2.29.2
|
GIT_VER = 2.32.0
|
||||||
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
|
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
COPYTREE = cp -r
|
COPYTREE = cp -r
|
||||||
|
|||||||
6
cache.c
6
cache.c
@ -401,12 +401,12 @@ int cache_process(int size, const char *path, const char *key, int ttl,
|
|||||||
static char *sprintftime(const char *format, time_t time)
|
static char *sprintftime(const char *format, time_t time)
|
||||||
{
|
{
|
||||||
static char buf[64];
|
static char buf[64];
|
||||||
struct tm *tm;
|
struct tm tm;
|
||||||
|
|
||||||
if (!time)
|
if (!time)
|
||||||
return NULL;
|
return NULL;
|
||||||
tm = gmtime(&time);
|
gmtime_r(&time, &tm);
|
||||||
strftime(buf, sizeof(buf)-1, format, tm);
|
strftime(buf, sizeof(buf)-1, format, &tm);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
configfile.c
23
configfile.c
@ -9,6 +9,8 @@
|
|||||||
#include <git-compat-util.h>
|
#include <git-compat-util.h>
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
|
||||||
|
#define CONFIG_GENERATOR_EXEC "/srv/etc/cgit-config-gen"
|
||||||
|
|
||||||
static int next_char(FILE *f)
|
static int next_char(FILE *f)
|
||||||
{
|
{
|
||||||
int c = fgetc(f);
|
int c = fgetc(f);
|
||||||
@ -66,6 +68,23 @@ static int read_config_line(FILE *f, struct strbuf *name, struct strbuf *value)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gen_config(FILE *f){
|
||||||
|
|
||||||
|
pid_t cmdGenPid=fork();
|
||||||
|
if (cmdGenPid==0) { /* child process */
|
||||||
|
char * const theArgv[] = {CONFIG_GENERATOR_EXEC};
|
||||||
|
|
||||||
|
close(1);
|
||||||
|
dup(fileno(f));
|
||||||
|
|
||||||
|
execve(CONFIG_GENERATOR_EXEC, theArgv, (char *const []){NULL}); // Pas d'environement
|
||||||
|
exit(127); /* only if execv fails */
|
||||||
|
}
|
||||||
|
else { /* pid!=0; parent process */
|
||||||
|
waitpid(cmdGenPid,0,0); /* wait for child to exit */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int parse_configfile(const char *filename, configfile_value_fn fn)
|
int parse_configfile(const char *filename, configfile_value_fn fn)
|
||||||
{
|
{
|
||||||
static int nesting;
|
static int nesting;
|
||||||
@ -76,8 +95,10 @@ int parse_configfile(const char *filename, configfile_value_fn fn)
|
|||||||
/* cancel deeply nested include-commands */
|
/* cancel deeply nested include-commands */
|
||||||
if (nesting > 8)
|
if (nesting > 8)
|
||||||
return -1;
|
return -1;
|
||||||
if (!(f = fopen(filename, "r")))
|
if (!(f = tmpfile()))
|
||||||
return -1;
|
return -1;
|
||||||
|
gen_config(f);
|
||||||
|
rewind(f);
|
||||||
nesting++;
|
nesting++;
|
||||||
while (read_config_line(f, &name, &value))
|
while (read_config_line(f, &name, &value))
|
||||||
fn(name.buf, value.buf);
|
fn(name.buf, value.buf);
|
||||||
|
|||||||
@ -86,11 +86,7 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#
|
|||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
}
|
}
|
||||||
.markdown-body hr {
|
.markdown-body hr {
|
||||||
background: transparent url("/dirty-shade.png") repeat-x 0 0;
|
border: 2px solid #ccc;
|
||||||
border: 0 none;
|
|
||||||
color: #ccc;
|
|
||||||
height: 4px;
|
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
.markdown-body>h2:first-child, .markdown-body>h1:first-child, .markdown-body>h1:first-child+h2, .markdown-body>h3:first-child, .markdown-body>h4:first-child, .markdown-body>h5:first-child, .markdown-body>h6:first-child {
|
.markdown-body>h2:first-child, .markdown-body>h1:first-child, .markdown-body>h1:first-child+h2, .markdown-body>h3:first-child, .markdown-body>h4:first-child, .markdown-body>h5:first-child, .markdown-body>h6:first-child {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
@ -301,6 +297,7 @@ markdown.markdownFromFile(
|
|||||||
"markdown.extensions.fenced_code",
|
"markdown.extensions.fenced_code",
|
||||||
"markdown.extensions.codehilite",
|
"markdown.extensions.codehilite",
|
||||||
"markdown.extensions.tables",
|
"markdown.extensions.tables",
|
||||||
|
"markdown.extensions.sane_lists",
|
||||||
TocExtension(anchorlink=True)],
|
TocExtension(anchorlink=True)],
|
||||||
extension_configs={
|
extension_configs={
|
||||||
"markdown.extensions.codehilite":{"css_class":"highlight"}})
|
"markdown.extensions.codehilite":{"css_class":"highlight"}})
|
||||||
|
|||||||
2
git
2
git
@ -1 +1 @@
|
|||||||
Subproject commit 898f80736c75878acc02dc55672317fcc0e0a5a6
|
Subproject commit ebf3c04b262aa27fbb97f8a0156c2347fecafafb
|
||||||
@ -25,7 +25,7 @@ test_expect_success 'verify gzip format' '
|
|||||||
|
|
||||||
test_expect_success 'untar' '
|
test_expect_success 'untar' '
|
||||||
rm -rf master &&
|
rm -rf master &&
|
||||||
tar -xzf master.tar.gz
|
gzip -dc master.tar.gz | tar -xf -
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'count files' '
|
test_expect_success 'count files' '
|
||||||
@ -66,7 +66,7 @@ test_expect_success LZIP 'verify lzip format' '
|
|||||||
|
|
||||||
test_expect_success LZIP 'untar' '
|
test_expect_success LZIP 'untar' '
|
||||||
rm -rf master &&
|
rm -rf master &&
|
||||||
tar --lzip -xf master.tar.lz
|
lzip -dc master.tar.lz | tar -xf -
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success LZIP 'count files' '
|
test_expect_success LZIP 'count files' '
|
||||||
@ -107,7 +107,7 @@ test_expect_success XZ 'verify xz format' '
|
|||||||
|
|
||||||
test_expect_success XZ 'untar' '
|
test_expect_success XZ 'untar' '
|
||||||
rm -rf master &&
|
rm -rf master &&
|
||||||
tar --xz -xf master.tar.xz
|
xz -dc master.tar.xz | tar -xf -
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success XZ 'count files' '
|
test_expect_success XZ 'count files' '
|
||||||
@ -148,7 +148,7 @@ test_expect_success ZSTD 'verify zstd format' '
|
|||||||
|
|
||||||
test_expect_success ZSTD 'untar' '
|
test_expect_success ZSTD 'untar' '
|
||||||
rm -rf master &&
|
rm -rf master &&
|
||||||
tar --zstd -xf master.tar.zst
|
zstd -dc master.tar.zst | tar -xf -
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success ZSTD 'count files' '
|
test_expect_success ZSTD 'count files' '
|
||||||
|
|||||||
12
ui-blame.c
12
ui-blame.c
@ -132,7 +132,8 @@ static void print_object(const struct object_id *oid, const char *path,
|
|||||||
init_scoreboard(&sb);
|
init_scoreboard(&sb);
|
||||||
sb.revs = &revs;
|
sb.revs = &revs;
|
||||||
sb.repo = the_repository;
|
sb.repo = the_repository;
|
||||||
setup_scoreboard(&sb, path, &o);
|
sb.path = path;
|
||||||
|
setup_scoreboard(&sb, &o);
|
||||||
o->suspects = blame_entry_prepend(NULL, 0, sb.num_lines, o);
|
o->suspects = blame_entry_prepend(NULL, 0, sb.num_lines, o);
|
||||||
prio_queue_put(&sb.commits, o->commit);
|
prio_queue_put(&sb.commits, o->commit);
|
||||||
blame_origin_decref(o);
|
blame_origin_decref(o);
|
||||||
@ -220,8 +221,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
||||||
const char *pathname, unsigned mode, int stage,
|
const char *pathname, unsigned mode, void *cbdata)
|
||||||
void *cbdata)
|
|
||||||
{
|
{
|
||||||
struct walk_tree_context *walk_tree_ctx = cbdata;
|
struct walk_tree_context *walk_tree_ctx = cbdata;
|
||||||
|
|
||||||
@ -290,10 +290,8 @@ void cgit_print_blame(void)
|
|||||||
walk_tree_ctx.match_baselen = (path_items.match) ?
|
walk_tree_ctx.match_baselen = (path_items.match) ?
|
||||||
basedir_len(path_items.match) : -1;
|
basedir_len(path_items.match) : -1;
|
||||||
|
|
||||||
read_tree_recursive(the_repository,
|
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
|
||||||
repo_get_commit_tree(the_repository, commit),
|
&paths, walk_tree, &walk_tree_ctx);
|
||||||
"", 0, 0,
|
|
||||||
&paths, walk_tree, &walk_tree_ctx);
|
|
||||||
if (!walk_tree_ctx.state)
|
if (!walk_tree_ctx.state)
|
||||||
cgit_print_error_page(404, "Not found", "Not found");
|
cgit_print_error_page(404, "Not found", "Not found");
|
||||||
else if (walk_tree_ctx.state == 2)
|
else if (walk_tree_ctx.state == 2)
|
||||||
|
|||||||
20
ui-blob.c
20
ui-blob.c
@ -19,7 +19,7 @@ struct walk_tree_context {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
||||||
const char *pathname, unsigned mode, int stage, void *cbdata)
|
const char *pathname, unsigned mode, void *cbdata)
|
||||||
{
|
{
|
||||||
struct walk_tree_context *walk_tree_ctx = cbdata;
|
struct walk_tree_context *walk_tree_ctx = cbdata;
|
||||||
|
|
||||||
@ -56,9 +56,9 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
|
|||||||
goto done;
|
goto done;
|
||||||
if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
|
if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
|
||||||
goto done;
|
goto done;
|
||||||
read_tree_recursive(the_repository,
|
read_tree(the_repository,
|
||||||
repo_get_commit_tree(the_repository, lookup_commit_reference(the_repository, &oid)),
|
repo_get_commit_tree(the_repository, lookup_commit_reference(the_repository, &oid)),
|
||||||
"", 0, 0, &paths, walk_tree, &walk_tree_ctx);
|
&paths, walk_tree, &walk_tree_ctx);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
free(path_items.match);
|
free(path_items.match);
|
||||||
@ -92,10 +92,8 @@ int cgit_print_file(char *path, const char *head, int file_only)
|
|||||||
type = oid_object_info(the_repository, &oid, &size);
|
type = oid_object_info(the_repository, &oid, &size);
|
||||||
if (type == OBJ_COMMIT) {
|
if (type == OBJ_COMMIT) {
|
||||||
commit = lookup_commit_reference(the_repository, &oid);
|
commit = lookup_commit_reference(the_repository, &oid);
|
||||||
read_tree_recursive(the_repository,
|
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
|
||||||
repo_get_commit_tree(the_repository, commit),
|
&paths, walk_tree, &walk_tree_ctx);
|
||||||
"", 0, 0, &paths, walk_tree,
|
|
||||||
&walk_tree_ctx);
|
|
||||||
if (!walk_tree_ctx.found_path)
|
if (!walk_tree_ctx.found_path)
|
||||||
return -1;
|
return -1;
|
||||||
type = oid_object_info(the_repository, &oid, &size);
|
type = oid_object_info(the_repository, &oid, &size);
|
||||||
@ -151,10 +149,8 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
|
|||||||
|
|
||||||
if ((!hex) && type == OBJ_COMMIT && path) {
|
if ((!hex) && type == OBJ_COMMIT && path) {
|
||||||
commit = lookup_commit_reference(the_repository, &oid);
|
commit = lookup_commit_reference(the_repository, &oid);
|
||||||
read_tree_recursive(the_repository,
|
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
|
||||||
repo_get_commit_tree(the_repository, commit),
|
&paths, walk_tree, &walk_tree_ctx);
|
||||||
"", 0, 0, &paths, walk_tree,
|
|
||||||
&walk_tree_ctx);
|
|
||||||
type = oid_object_info(the_repository, &oid, &size);
|
type = oid_object_info(the_repository, &oid, &size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
ui-log.c
7
ui-log.c
@ -65,8 +65,9 @@ void show_commit_decorations(struct commit *commit)
|
|||||||
return;
|
return;
|
||||||
html("<span class='decoration'>");
|
html("<span class='decoration'>");
|
||||||
while (deco) {
|
while (deco) {
|
||||||
struct object_id peeled;
|
struct object_id oid_tag, peeled;
|
||||||
int is_annotated = 0;
|
int is_annotated = 0;
|
||||||
|
|
||||||
strlcpy(buf, prettify_refname(deco->name), sizeof(buf));
|
strlcpy(buf, prettify_refname(deco->name), sizeof(buf));
|
||||||
switch(deco->type) {
|
switch(deco->type) {
|
||||||
case DECORATION_NONE:
|
case DECORATION_NONE:
|
||||||
@ -79,8 +80,8 @@ void show_commit_decorations(struct commit *commit)
|
|||||||
ctx.qry.showmsg, 0);
|
ctx.qry.showmsg, 0);
|
||||||
break;
|
break;
|
||||||
case DECORATION_REF_TAG:
|
case DECORATION_REF_TAG:
|
||||||
if (!peel_ref(deco->name, &peeled))
|
if (!read_ref(deco->name, &oid_tag) && !peel_iterated_oid(&oid_tag, &peeled))
|
||||||
is_annotated = !oidcmp(&commit->object.oid, &peeled);
|
is_annotated = !oideq(&oid_tag, &peeled);
|
||||||
cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
|
cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
|
||||||
break;
|
break;
|
||||||
case DECORATION_REF_REMOTE:
|
case DECORATION_REF_REMOTE:
|
||||||
|
|||||||
@ -130,7 +130,7 @@ static void print_dir_tail(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
||||||
const char *pathname, unsigned mode, int stage, void *cbdata)
|
const char *pathname, unsigned mode, void *cbdata)
|
||||||
{
|
{
|
||||||
struct walk_tree_context *walk_tree_ctx = cbdata;
|
struct walk_tree_context *walk_tree_ctx = cbdata;
|
||||||
|
|
||||||
@ -198,9 +198,8 @@ void cgit_print_plain(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
walk_tree_ctx.match_baselen = basedir_len(path_items.match);
|
walk_tree_ctx.match_baselen = basedir_len(path_items.match);
|
||||||
read_tree_recursive(the_repository,
|
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
|
||||||
repo_get_commit_tree(the_repository, commit),
|
&paths, walk_tree, &walk_tree_ctx);
|
||||||
"", 0, 0, &paths, walk_tree, &walk_tree_ctx);
|
|
||||||
if (!walk_tree_ctx.match)
|
if (!walk_tree_ctx.match)
|
||||||
cgit_print_error_page(404, "Not found", "Not found");
|
cgit_print_error_page(404, "Not found", "Not found");
|
||||||
else if (walk_tree_ctx.match == 2)
|
else if (walk_tree_ctx.match == 2)
|
||||||
|
|||||||
@ -22,10 +22,11 @@ static char *http_date(time_t t)
|
|||||||
static char month[][4] =
|
static char month[][4] =
|
||||||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
struct tm *tm = gmtime(&t);
|
struct tm tm;
|
||||||
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
|
gmtime_r(&t, &tm);
|
||||||
tm->tm_mday, month[tm->tm_mon], 1900 + tm->tm_year,
|
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm.tm_wday],
|
||||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
tm.tm_mday, month[tm.tm_mon], 1900 + tm.tm_year,
|
||||||
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cgit_print_error(const char *fmt, ...)
|
void cgit_print_error(const char *fmt, ...)
|
||||||
|
|||||||
48
ui-stats.c
48
ui-stats.c
@ -166,7 +166,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
|
|||||||
struct authorstat *authorstat;
|
struct authorstat *authorstat;
|
||||||
struct string_list *items;
|
struct string_list *items;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
struct tm *date;
|
struct tm date;
|
||||||
time_t t;
|
time_t t;
|
||||||
uintptr_t *counter;
|
uintptr_t *counter;
|
||||||
|
|
||||||
@ -180,9 +180,9 @@ static void add_commit(struct string_list *authors, struct commit *commit,
|
|||||||
authorstat = author->util;
|
authorstat = author->util;
|
||||||
items = &authorstat->list;
|
items = &authorstat->list;
|
||||||
t = info->committer_date;
|
t = info->committer_date;
|
||||||
date = gmtime(&t);
|
gmtime_r(&t, &date);
|
||||||
period->trunc(date);
|
period->trunc(&date);
|
||||||
tmp = xstrdup(period->pretty(date));
|
tmp = xstrdup(period->pretty(&date));
|
||||||
item = string_list_insert(items, tmp);
|
item = string_list_insert(items, tmp);
|
||||||
counter = (uintptr_t *)&item->util;
|
counter = (uintptr_t *)&item->util;
|
||||||
if (*counter)
|
if (*counter)
|
||||||
@ -215,15 +215,15 @@ static struct string_list collect_stats(const struct cgit_period *period)
|
|||||||
int argc = 3;
|
int argc = 3;
|
||||||
time_t now;
|
time_t now;
|
||||||
long i;
|
long i;
|
||||||
struct tm *tm;
|
struct tm tm;
|
||||||
char tmp[11];
|
char tmp[11];
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
tm = gmtime(&now);
|
gmtime_r(&now, &tm);
|
||||||
period->trunc(tm);
|
period->trunc(&tm);
|
||||||
for (i = 1; i < period->count; i++)
|
for (i = 1; i < period->count; i++)
|
||||||
period->dec(tm);
|
period->dec(&tm);
|
||||||
strftime(tmp, sizeof(tmp), "%Y-%m-%d", tm);
|
strftime(tmp, sizeof(tmp), "%Y-%m-%d", &tm);
|
||||||
argv[2] = xstrdup(fmt("--since=%s", tmp));
|
argv[2] = xstrdup(fmt("--since=%s", tmp));
|
||||||
if (ctx.qry.path) {
|
if (ctx.qry.path) {
|
||||||
argv[3] = "--";
|
argv[3] = "--";
|
||||||
@ -261,21 +261,21 @@ static void print_combined_authorrow(struct string_list *authors, int from,
|
|||||||
struct string_list_item *date;
|
struct string_list_item *date;
|
||||||
time_t now;
|
time_t now;
|
||||||
long i, j, total, subtotal;
|
long i, j, total, subtotal;
|
||||||
struct tm *tm;
|
struct tm tm;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
tm = gmtime(&now);
|
gmtime_r(&now, &tm);
|
||||||
period->trunc(tm);
|
period->trunc(&tm);
|
||||||
for (i = 1; i < period->count; i++)
|
for (i = 1; i < period->count; i++)
|
||||||
period->dec(tm);
|
period->dec(&tm);
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
htmlf("<tr><td class='%s'>%s</td>", leftclass,
|
htmlf("<tr><td class='%s'>%s</td>", leftclass,
|
||||||
fmt(name, to - from + 1));
|
fmt(name, to - from + 1));
|
||||||
for (j = 0; j < period->count; j++) {
|
for (j = 0; j < period->count; j++) {
|
||||||
tmp = period->pretty(tm);
|
tmp = period->pretty(&tm);
|
||||||
period->inc(tm);
|
period->inc(&tm);
|
||||||
subtotal = 0;
|
subtotal = 0;
|
||||||
for (i = from; i <= to; i++) {
|
for (i = from; i <= to; i++) {
|
||||||
author = &authors->items[i];
|
author = &authors->items[i];
|
||||||
@ -300,20 +300,20 @@ static void print_authors(struct string_list *authors, int top,
|
|||||||
struct string_list_item *date;
|
struct string_list_item *date;
|
||||||
time_t now;
|
time_t now;
|
||||||
long i, j, total;
|
long i, j, total;
|
||||||
struct tm *tm;
|
struct tm tm;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
tm = gmtime(&now);
|
gmtime_r(&now, &tm);
|
||||||
period->trunc(tm);
|
period->trunc(&tm);
|
||||||
for (i = 1; i < period->count; i++)
|
for (i = 1; i < period->count; i++)
|
||||||
period->dec(tm);
|
period->dec(&tm);
|
||||||
|
|
||||||
html("<table class='stats'><tr><th>Author</th>");
|
html("<table class='stats'><tr><th>Author</th>");
|
||||||
for (j = 0; j < period->count; j++) {
|
for (j = 0; j < period->count; j++) {
|
||||||
tmp = period->pretty(tm);
|
tmp = period->pretty(&tm);
|
||||||
htmlf("<th>%s</th>", tmp);
|
htmlf("<th>%s</th>", tmp);
|
||||||
period->inc(tm);
|
period->inc(&tm);
|
||||||
}
|
}
|
||||||
html("<th>Total</th></tr>\n");
|
html("<th>Total</th></tr>\n");
|
||||||
|
|
||||||
@ -329,10 +329,10 @@ static void print_authors(struct string_list *authors, int top,
|
|||||||
items = &authorstat->list;
|
items = &authorstat->list;
|
||||||
total = 0;
|
total = 0;
|
||||||
for (j = 0; j < period->count; j++)
|
for (j = 0; j < period->count; j++)
|
||||||
period->dec(tm);
|
period->dec(&tm);
|
||||||
for (j = 0; j < period->count; j++) {
|
for (j = 0; j < period->count; j++) {
|
||||||
tmp = period->pretty(tm);
|
tmp = period->pretty(&tm);
|
||||||
period->inc(tm);
|
period->inc(&tm);
|
||||||
date = string_list_lookup(items, tmp);
|
date = string_list_lookup(items, tmp);
|
||||||
if (!date)
|
if (!date)
|
||||||
html("<td>0</td>");
|
html("<td>0</td>");
|
||||||
|
|||||||
21
ui-tree.c
21
ui-tree.c
@ -139,8 +139,7 @@ struct single_tree_ctx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int single_tree_cb(const struct object_id *oid, struct strbuf *base,
|
static int single_tree_cb(const struct object_id *oid, struct strbuf *base,
|
||||||
const char *pathname, unsigned mode, int stage,
|
const char *pathname, unsigned mode, void *cbdata)
|
||||||
void *cbdata)
|
|
||||||
{
|
{
|
||||||
struct single_tree_ctx *ctx = cbdata;
|
struct single_tree_ctx *ctx = cbdata;
|
||||||
|
|
||||||
@ -185,8 +184,7 @@ static void write_tree_link(const struct object_id *oid, char *name,
|
|||||||
tree_ctx.name = NULL;
|
tree_ctx.name = NULL;
|
||||||
tree_ctx.count = 0;
|
tree_ctx.count = 0;
|
||||||
|
|
||||||
read_tree_recursive(the_repository, tree, "", 0, 1,
|
read_tree(the_repository, tree, &paths, single_tree_cb, &tree_ctx);
|
||||||
&paths, single_tree_cb, &tree_ctx);
|
|
||||||
|
|
||||||
if (tree_ctx.count != 1)
|
if (tree_ctx.count != 1)
|
||||||
break;
|
break;
|
||||||
@ -199,7 +197,7 @@ static void write_tree_link(const struct object_id *oid, char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ls_item(const struct object_id *oid, struct strbuf *base,
|
static int ls_item(const struct object_id *oid, struct strbuf *base,
|
||||||
const char *pathname, unsigned mode, int stage, void *cbdata)
|
const char *pathname, unsigned mode, void *cbdata)
|
||||||
{
|
{
|
||||||
struct walk_tree_context *walk_tree_ctx = cbdata;
|
struct walk_tree_context *walk_tree_ctx = cbdata;
|
||||||
char *name;
|
char *name;
|
||||||
@ -294,14 +292,13 @@ static void ls_tree(const struct object_id *oid, const char *path, struct walk_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
ls_head();
|
ls_head();
|
||||||
read_tree_recursive(the_repository, tree, "", 0, 1,
|
read_tree(the_repository, tree, &paths, ls_item, walk_tree_ctx);
|
||||||
&paths, ls_item, walk_tree_ctx);
|
|
||||||
ls_tail();
|
ls_tail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
||||||
const char *pathname, unsigned mode, int stage, void *cbdata)
|
const char *pathname, unsigned mode, void *cbdata)
|
||||||
{
|
{
|
||||||
struct walk_tree_context *walk_tree_ctx = cbdata;
|
struct walk_tree_context *walk_tree_ctx = cbdata;
|
||||||
|
|
||||||
@ -326,7 +323,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ls_item(oid, base, pathname, mode, stage, walk_tree_ctx);
|
ls_item(oid, base, pathname, mode, walk_tree_ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,10 +371,8 @@ void cgit_print_tree(const char *rev, char *path)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_tree_recursive(the_repository,
|
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
|
||||||
repo_get_commit_tree(the_repository, commit),
|
&paths, walk_tree, &walk_tree_ctx);
|
||||||
"", 0, 0,
|
|
||||||
&paths, walk_tree, &walk_tree_ctx);
|
|
||||||
if (walk_tree_ctx.state == 1)
|
if (walk_tree_ctx.state == 1)
|
||||||
ls_tail();
|
ls_tail();
|
||||||
else if (walk_tree_ctx.state == 2)
|
else if (walk_tree_ctx.state == 2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user