Compare commits

..

No commits in common. "79e81e35ca472d6d0767eacce2520efce55fbd9d" and "b1739247b17524460282f63fa240b3f34501e000" have entirely different histories.

13 changed files with 86 additions and 94 deletions

View File

@ -2,11 +2,11 @@ all::
CGIT_VERSION = v1.2.3
CGIT_SCRIPT_NAME = cgit.cgi
CGIT_SCRIPT_PATH = /srv/cgit/
CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
CGIT_CONFIG = /dev/null
CACHE_ROOT = /srv/cgit/cache/cgit
prefix = /usr/server/cgit
CGIT_CONFIG = /etc/cgitrc
CACHE_ROOT = /var/cache/cgit
prefix = /usr/local
libdir = $(prefix)/lib
filterdir = $(libdir)/cgit/filters
docdir = $(prefix)/share/doc/cgit
@ -14,7 +14,7 @@ htmldir = $(docdir)
pdfdir = $(docdir)
mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h>
GIT_VER = 2.32.0
GIT_VER = 2.29.2
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
INSTALL = install
COPYTREE = cp -r

View File

@ -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 buf[64];
struct tm tm;
struct tm *tm;
if (!time)
return NULL;
gmtime_r(&time, &tm);
strftime(buf, sizeof(buf)-1, format, &tm);
tm = gmtime(&time);
strftime(buf, sizeof(buf)-1, format, tm);
return buf;
}

View File

@ -9,8 +9,6 @@
#include <git-compat-util.h>
#include "configfile.h"
#define CONFIG_GENERATOR_EXEC "/srv/etc/cgit-config-gen"
static int next_char(FILE *f)
{
int c = fgetc(f);
@ -68,23 +66,6 @@ static int read_config_line(FILE *f, struct strbuf *name, struct strbuf *value)
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)
{
static int nesting;
@ -95,10 +76,8 @@ int parse_configfile(const char *filename, configfile_value_fn fn)
/* cancel deeply nested include-commands */
if (nesting > 8)
return -1;
if (!(f = tmpfile()))
if (!(f = fopen(filename, "r")))
return -1;
gen_config(f);
rewind(f);
nesting++;
while (read_config_line(f, &name, &value))
fn(name.buf, value.buf);

View File

@ -86,7 +86,11 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#
margin: 15px 0;
}
.markdown-body hr {
border: 2px solid #ccc;
background: transparent url("/dirty-shade.png") repeat-x 0 0;
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 {
margin-top: 0;
@ -297,7 +301,6 @@ markdown.markdownFromFile(
"markdown.extensions.fenced_code",
"markdown.extensions.codehilite",
"markdown.extensions.tables",
"markdown.extensions.sane_lists",
TocExtension(anchorlink=True)],
extension_configs={
"markdown.extensions.codehilite":{"css_class":"highlight"}})

2
git

@ -1 +1 @@
Subproject commit ebf3c04b262aa27fbb97f8a0156c2347fecafafb
Subproject commit 898f80736c75878acc02dc55672317fcc0e0a5a6

View File

@ -25,7 +25,7 @@ test_expect_success 'verify gzip format' '
test_expect_success 'untar' '
rm -rf master &&
gzip -dc master.tar.gz | tar -xf -
tar -xzf master.tar.gz
'
test_expect_success 'count files' '
@ -66,7 +66,7 @@ test_expect_success LZIP 'verify lzip format' '
test_expect_success LZIP 'untar' '
rm -rf master &&
lzip -dc master.tar.lz | tar -xf -
tar --lzip -xf master.tar.lz
'
test_expect_success LZIP 'count files' '
@ -107,7 +107,7 @@ test_expect_success XZ 'verify xz format' '
test_expect_success XZ 'untar' '
rm -rf master &&
xz -dc master.tar.xz | tar -xf -
tar --xz -xf master.tar.xz
'
test_expect_success XZ 'count files' '
@ -148,7 +148,7 @@ test_expect_success ZSTD 'verify zstd format' '
test_expect_success ZSTD 'untar' '
rm -rf master &&
zstd -dc master.tar.zst | tar -xf -
tar --zstd -xf master.tar.zst
'
test_expect_success ZSTD 'count files' '

View File

@ -132,8 +132,7 @@ static void print_object(const struct object_id *oid, const char *path,
init_scoreboard(&sb);
sb.revs = &revs;
sb.repo = the_repository;
sb.path = path;
setup_scoreboard(&sb, &o);
setup_scoreboard(&sb, path, &o);
o->suspects = blame_entry_prepend(NULL, 0, sb.num_lines, o);
prio_queue_put(&sb.commits, o->commit);
blame_origin_decref(o);
@ -221,7 +220,8 @@ cleanup:
}
static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *cbdata)
const char *pathname, unsigned mode, int stage,
void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
@ -290,7 +290,9 @@ void cgit_print_blame(void)
walk_tree_ctx.match_baselen = (path_items.match) ?
basedir_len(path_items.match) : -1;
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
read_tree_recursive(the_repository,
repo_get_commit_tree(the_repository, commit),
"", 0, 0,
&paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.state)
cgit_print_error_page(404, "Not found", "Not found");

View File

@ -19,7 +19,7 @@ struct walk_tree_context {
};
static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *cbdata)
const char *pathname, unsigned mode, int stage, void *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;
if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
goto done;
read_tree(the_repository,
read_tree_recursive(the_repository,
repo_get_commit_tree(the_repository, lookup_commit_reference(the_repository, &oid)),
&paths, walk_tree, &walk_tree_ctx);
"", 0, 0, &paths, walk_tree, &walk_tree_ctx);
done:
free(path_items.match);
@ -92,8 +92,10 @@ int cgit_print_file(char *path, const char *head, int file_only)
type = oid_object_info(the_repository, &oid, &size);
if (type == OBJ_COMMIT) {
commit = lookup_commit_reference(the_repository, &oid);
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
&paths, walk_tree, &walk_tree_ctx);
read_tree_recursive(the_repository,
repo_get_commit_tree(the_repository, commit),
"", 0, 0, &paths, walk_tree,
&walk_tree_ctx);
if (!walk_tree_ctx.found_path)
return -1;
type = oid_object_info(the_repository, &oid, &size);
@ -149,8 +151,10 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
if ((!hex) && type == OBJ_COMMIT && path) {
commit = lookup_commit_reference(the_repository, &oid);
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
&paths, walk_tree, &walk_tree_ctx);
read_tree_recursive(the_repository,
repo_get_commit_tree(the_repository, commit),
"", 0, 0, &paths, walk_tree,
&walk_tree_ctx);
type = oid_object_info(the_repository, &oid, &size);
}

View File

@ -65,9 +65,8 @@ void show_commit_decorations(struct commit *commit)
return;
html("<span class='decoration'>");
while (deco) {
struct object_id oid_tag, peeled;
struct object_id peeled;
int is_annotated = 0;
strlcpy(buf, prettify_refname(deco->name), sizeof(buf));
switch(deco->type) {
case DECORATION_NONE:
@ -80,8 +79,8 @@ void show_commit_decorations(struct commit *commit)
ctx.qry.showmsg, 0);
break;
case DECORATION_REF_TAG:
if (!read_ref(deco->name, &oid_tag) && !peel_iterated_oid(&oid_tag, &peeled))
is_annotated = !oideq(&oid_tag, &peeled);
if (!peel_ref(deco->name, &peeled))
is_annotated = !oidcmp(&commit->object.oid, &peeled);
cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
break;
case DECORATION_REF_REMOTE:

View File

@ -130,7 +130,7 @@ static void print_dir_tail(void)
}
static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *cbdata)
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
@ -198,8 +198,9 @@ void cgit_print_plain(void)
}
else
walk_tree_ctx.match_baselen = basedir_len(path_items.match);
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
&paths, walk_tree, &walk_tree_ctx);
read_tree_recursive(the_repository,
repo_get_commit_tree(the_repository, commit),
"", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.match)
cgit_print_error_page(404, "Not found", "Not found");
else if (walk_tree_ctx.match == 2)

View File

@ -22,11 +22,10 @@ static char *http_date(time_t t)
static char month[][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
struct tm tm;
gmtime_r(&t, &tm);
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm.tm_wday],
tm.tm_mday, month[tm.tm_mon], 1900 + tm.tm_year,
tm.tm_hour, tm.tm_min, tm.tm_sec);
struct tm *tm = gmtime(&t);
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
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, ...)

View File

@ -166,7 +166,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
struct authorstat *authorstat;
struct string_list *items;
char *tmp;
struct tm date;
struct tm *date;
time_t t;
uintptr_t *counter;
@ -180,9 +180,9 @@ static void add_commit(struct string_list *authors, struct commit *commit,
authorstat = author->util;
items = &authorstat->list;
t = info->committer_date;
gmtime_r(&t, &date);
period->trunc(&date);
tmp = xstrdup(period->pretty(&date));
date = gmtime(&t);
period->trunc(date);
tmp = xstrdup(period->pretty(date));
item = string_list_insert(items, tmp);
counter = (uintptr_t *)&item->util;
if (*counter)
@ -215,15 +215,15 @@ static struct string_list collect_stats(const struct cgit_period *period)
int argc = 3;
time_t now;
long i;
struct tm tm;
struct tm *tm;
char tmp[11];
time(&now);
gmtime_r(&now, &tm);
period->trunc(&tm);
tm = gmtime(&now);
period->trunc(tm);
for (i = 1; i < period->count; i++)
period->dec(&tm);
strftime(tmp, sizeof(tmp), "%Y-%m-%d", &tm);
period->dec(tm);
strftime(tmp, sizeof(tmp), "%Y-%m-%d", tm);
argv[2] = xstrdup(fmt("--since=%s", tmp));
if (ctx.qry.path) {
argv[3] = "--";
@ -261,21 +261,21 @@ static void print_combined_authorrow(struct string_list *authors, int from,
struct string_list_item *date;
time_t now;
long i, j, total, subtotal;
struct tm tm;
struct tm *tm;
char *tmp;
time(&now);
gmtime_r(&now, &tm);
period->trunc(&tm);
tm = gmtime(&now);
period->trunc(tm);
for (i = 1; i < period->count; i++)
period->dec(&tm);
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);
tmp = period->pretty(tm);
period->inc(tm);
subtotal = 0;
for (i = from; i <= to; i++) {
author = &authors->items[i];
@ -300,20 +300,20 @@ static void print_authors(struct string_list *authors, int top,
struct string_list_item *date;
time_t now;
long i, j, total;
struct tm tm;
struct tm *tm;
char *tmp;
time(&now);
gmtime_r(&now, &tm);
period->trunc(&tm);
tm = gmtime(&now);
period->trunc(tm);
for (i = 1; i < period->count; i++)
period->dec(&tm);
period->dec(tm);
html("<table class='stats'><tr><th>Author</th>");
for (j = 0; j < period->count; j++) {
tmp = period->pretty(&tm);
tmp = period->pretty(tm);
htmlf("<th>%s</th>", tmp);
period->inc(&tm);
period->inc(tm);
}
html("<th>Total</th></tr>\n");
@ -329,10 +329,10 @@ static void print_authors(struct string_list *authors, int top,
items = &authorstat->list;
total = 0;
for (j = 0; j < period->count; j++)
period->dec(&tm);
period->dec(tm);
for (j = 0; j < period->count; j++) {
tmp = period->pretty(&tm);
period->inc(&tm);
tmp = period->pretty(tm);
period->inc(tm);
date = string_list_lookup(items, tmp);
if (!date)
html("<td>0</td>");

View File

@ -139,7 +139,8 @@ struct single_tree_ctx {
};
static int single_tree_cb(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *cbdata)
const char *pathname, unsigned mode, int stage,
void *cbdata)
{
struct single_tree_ctx *ctx = cbdata;
@ -184,7 +185,8 @@ static void write_tree_link(const struct object_id *oid, char *name,
tree_ctx.name = NULL;
tree_ctx.count = 0;
read_tree(the_repository, tree, &paths, single_tree_cb, &tree_ctx);
read_tree_recursive(the_repository, tree, "", 0, 1,
&paths, single_tree_cb, &tree_ctx);
if (tree_ctx.count != 1)
break;
@ -197,7 +199,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,
const char *pathname, unsigned mode, void *cbdata)
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
char *name;
@ -292,13 +294,14 @@ static void ls_tree(const struct object_id *oid, const char *path, struct walk_t
}
ls_head();
read_tree(the_repository, tree, &paths, ls_item, walk_tree_ctx);
read_tree_recursive(the_repository, tree, "", 0, 1,
&paths, ls_item, walk_tree_ctx);
ls_tail();
}
static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *cbdata)
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
@ -323,7 +326,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base,
return 0;
}
}
ls_item(oid, base, pathname, mode, walk_tree_ctx);
ls_item(oid, base, pathname, mode, stage, walk_tree_ctx);
return 0;
}
@ -371,7 +374,9 @@ void cgit_print_tree(const char *rev, char *path)
goto cleanup;
}
read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
read_tree_recursive(the_repository,
repo_get_commit_tree(the_repository, commit),
"", 0, 0,
&paths, walk_tree, &walk_tree_ctx);
if (walk_tree_ctx.state == 1)
ls_tail();