diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Clean up the whole tree
Diffstat (limited to '')
-rw-r--r--source/cache.c63
-rw-r--r--source/cache.h3
-rw-r--r--source/cgit.c103
-rw-r--r--source/cgit.h3
-rw-r--r--source/cgit.mk9
-rw-r--r--source/cmd.c17
-rw-r--r--source/cmd.h4
-rw-r--r--source/filter.c48
-rw-r--r--source/html.c15
-rw-r--r--source/html.h10
-rw-r--r--source/parsing.c15
-rw-r--r--source/scan-tree.c30
-rw-r--r--source/shared.c47
-rw-r--r--source/shared.h19
-rw-r--r--source/ui-atom.c3
-rw-r--r--source/ui-blame.c70
-rw-r--r--source/ui-blob.c31
-rw-r--r--source/ui-blob.h9
-rw-r--r--source/ui-clone.c9
-rw-r--r--source/ui-commit.c42
-rw-r--r--source/ui-diff.c126
-rw-r--r--source/ui-diff.h4
-rw-r--r--source/ui-log.c125
-rw-r--r--source/ui-log.h5
-rw-r--r--source/ui-patch.c34
-rw-r--r--source/ui-patch.h3
-rw-r--r--source/ui-plain.c19
-rw-r--r--source/ui-refs.c24
-rw-r--r--source/ui-repolist.c18
-rw-r--r--source/ui-shared.c318
-rw-r--r--source/ui-shared.h81
-rw-r--r--source/ui-snapshot.c51
-rw-r--r--source/ui-snapshot.h3
-rw-r--r--source/ui-ssdiff.c52
-rw-r--r--source/ui-stats.c38
-rw-r--r--source/ui-stats.h3
-rw-r--r--source/ui-summary.c15
-rw-r--r--source/ui-tag.c25
-rw-r--r--source/ui-tree.c86
39 files changed, 596 insertions, 984 deletions
diff --git a/source/cache.c b/source/cache.c
index 2d546bb..28558b1 100644
--- a/source/cache.c
+++ b/source/cache.c
@@ -88,9 +88,10 @@ static int open_slot(struct cache_slot *slot)
keylen = nul - slot->buf;
if (slot->key)
- slot->key_matches = keylen >= 0 &&
- (size_t)keylen == slot->keylen &&
- !memcmp(slot->key, slot->buf, keylen + 1);
+ slot->key_matches =
+ keylen >= 0 &&
+ (size_t)keylen == slot->keylen &&
+ !memcmp(slot->key, slot->buf, keylen + 1);
return 0;
}
@@ -168,10 +169,7 @@ static int serve_slot(struct cache_slot *slot)
err = print_slot(slot);
if (err)
- log_error("[cgit] Error printing slot %s: %s (%d)\n",
- slot->path,
- strerror(err),
- err);
+ log_error("[cgit] Error printing slot %s: %s (%d)\n", slot->path, strerror(err), err);
return err;
}
@@ -192,9 +190,11 @@ static int is_modified(struct cache_slot *slot)
if (stat(slot->path, &current))
return 1;
- return (current.st_ino != slot->st.st_ino ||
- current.st_mtime != slot->st.st_mtime ||
- current.st_size != slot->st.st_size);
+ return (
+ current.st_ino != slot->st.st_ino ||
+ current.st_mtime != slot->st.st_mtime ||
+ current.st_size != slot->st.st_size
+ );
}
static int close_lock(struct cache_slot *slot)
@@ -225,8 +225,7 @@ static int lock_slot(struct cache_slot *slot)
};
struct stat held, named;
- slot->lock_fd = open(slot->lock_path, O_RDWR | O_CREAT,
- S_IRUSR | S_IWUSR);
+ slot->lock_fd = open(slot->lock_path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (slot->lock_fd == -1)
return errno;
if (fcntl(slot->lock_fd, F_SETLK, &lock) < 0) {
@@ -239,8 +238,12 @@ static int lock_slot(struct cache_slot *slot)
// finishing in between renames that inode into place as the live
// slot, and once the path is confirmed to still name this file that
// rename can no longer happen, because it takes the lock held here.
- if (fstat(slot->lock_fd, &held) || stat(slot->lock_path, &named) ||
- held.st_ino != named.st_ino || held.st_dev != named.st_dev) {
+ if (
+ fstat(slot->lock_fd, &held) ||
+ stat(slot->lock_path, &named) ||
+ held.st_ino != named.st_ino ||
+ held.st_dev != named.st_dev
+ ) {
close(slot->lock_fd);
slot->lock_fd = -1;
return EAGAIN;
@@ -386,23 +389,20 @@ static int process_slot(struct cache_slot *slot)
// and two popular pages sharing one slot evict each other on every
// alternating visit.
if (!err)
- log_error("[cgit] Cache slot %s holds a different key, "
- "consider a larger cache-size\n", slot->path);
+ log_error("[cgit] Cache slot %s holds a different key, consider a larger cache-size\n", slot->path);
// If any part of creating a slot fails the page is still rendered
// straight to the client and the caller is told the request succeeded,
// because it did.
close_slot(slot);
if ((err = lock_slot(slot)) != 0) {
- log_error("[cgit] Error locking slot %s: %s (%d)\n",
- slot->lock_path, strerror(err), err);
+ log_error("[cgit] Error locking slot %s: %s (%d)\n", slot->lock_path, strerror(err), err);
slot->fn();
return 0;
}
if ((err = fill_slot(slot)) != 0) {
- log_error("[cgit] Error filling slot %s: %s (%d)\n",
- slot->lock_path, strerror(err), err);
+ log_error("[cgit] Error filling slot %s: %s (%d)\n", slot->lock_path, strerror(err), err);
unlock_slot(slot, 0);
close_lock(slot);
// Rendering again is only right when nothing was delivered,
@@ -459,8 +459,7 @@ unsigned long cache_hash_str(const char *str)
return h;
}
-int cache_process(int size, const char *path, const char *key, int ttl,
- cache_fill_fn fn)
+int cache_process(int size, const char *path, const char *key, int ttl, cache_fill_fn fn)
{
unsigned long hash;
int i;
@@ -482,8 +481,7 @@ int cache_process(int size, const char *path, const char *key, int ttl,
if (!key)
key = "";
if (!key_fits_slot(key)) {
- log_error("[cgit] Cache key too long for a slot, caching is "
- "disabled for this request\n");
+ log_error("[cgit] Cache key too long for a slot, caching is disabled for this request\n");
fn();
return 0;
}
@@ -531,8 +529,7 @@ int cache_ls(const char *path)
dir = opendir(path);
if (!dir) {
err = errno;
- log_error("[cgit] Error opening %s: %s (%d)\n",
- path, strerror(err), err);
+ log_error("[cgit] Error opening %s: %s (%d)\n", path, strerror(err), err);
return err;
}
strbuf_addstr(&slot_path, path);
@@ -545,20 +542,18 @@ int cache_ls(const char *path)
strbuf_addstr(&slot_path, ent->d_name);
slot.path = slot_path.buf;
if ((err = open_slot(&slot)) != 0) {
- log_error("[cgit] Error opening %s: %s (%d)\n",
- slot_path.buf, strerror(err), err);
+ log_error("[cgit] Error opening %s: %s (%d)\n", slot_path.buf, strerror(err), err);
continue;
}
// A truncated or corrupt slot may hold no NUL, so the print is
// bounded by what was read and cannot run off the end.
nul = memchr(slot.buf, 0, slot.buflen);
keylen = nul ? (int)(nul - slot.buf) : slot.buflen;
- htmlf("%s %s %10"PRIuMAX" %.*s\n",
- slot_path.buf,
- format_time("%Y-%m-%d %H:%M:%S",
- slot.st.st_mtime),
- (uintmax_t)slot.st.st_size,
- keylen, slot.buf);
+ htmlf(
+ "%s %s %10"PRIuMAX" %.*s\n", slot_path.buf,
+ format_time("%Y-%m-%d %H:%M:%S", slot.st.st_mtime),
+ (uintmax_t)slot.st.st_size, keylen, slot.buf
+ );
close_slot(&slot);
}
closedir(dir);
diff --git a/source/cache.h b/source/cache.h
index db77999..a653108 100644
--- a/source/cache.h
+++ b/source/cache.h
@@ -17,8 +17,7 @@ typedef void (*cache_fill_fn)(void);
* ttl never expires and a ttl of zero skips the cache for this request.
* Returns 0 when the page was written, and an errno value when it was not.
*/
-extern int cache_process(int size, const char *path, const char *key, int ttl,
- cache_fill_fn fn);
+extern int cache_process(int size, const char *path, const char *key, int ttl, cache_fill_fn fn);
// Write one line per cache slot to stdout, giving its path, modification
// time, size and key.
diff --git a/source/cgit.c b/source/cgit.c
index dc56a0e..e6e8613 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -153,8 +153,7 @@ static void prepare_context(void)
ctx.env.server_port = getenv("SERVER_PORT");
ctx.env.http_cookie = getenv("HTTP_COOKIE");
ctx.env.http_referer = getenv("HTTP_REFERER");
- ctx.env.content_length = getenv("CONTENT_LENGTH") ?
- strtoul(getenv("CONTENT_LENGTH"), NULL, 10) : 0;
+ ctx.env.content_length = getenv("CONTENT_LENGTH") ? strtoul(getenv("CONTENT_LENGTH"), NULL, 10) : 0;
ctx.env.authenticated = 0;
ctx.page.mimetype = "text/html";
ctx.page.charset = PAGE_ENCODING;
@@ -171,8 +170,7 @@ static void prepare_context(void)
static void print_version(void)
{
- printf("CGit %s | https://github.com/brycekwon/cgit\n\n"
- "Compiled in features:\n", CGIT_VERSION);
+ printf("CGit %s | https://github.com/brycekwon/cgit\n\nCompiled in features:\n", CGIT_VERSION);
#ifdef NO_LUA
printf("[-] ");
#else
@@ -257,8 +255,7 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
if (repo->snapshot_prefix)
fprintf(f, "repo.snapshot-prefix=%s\n", repo->snapshot_prefix);
if (repo->max_stats != ctx.cfg.max_stats)
- fprintf(f, "repo.max-stats=%s\n",
- cgit_find_stats_periodname(repo->max_stats));
+ fprintf(f, "repo.max-stats=%s\n", cgit_find_stats_periodname(repo->max_stats));
if (repo->logo)
fprintf(f, "repo.logo=%s\n", repo->logo);
if (repo->logo_link)
@@ -316,8 +313,7 @@ static void parse_args(int argc, const char **argv)
ctx.qry.has_oid = 1;
} else if (skip_prefix(argv[i], "--ofs=", &arg)) {
ctx.qry.ofs = atoi(arg);
- } else if (skip_prefix(argv[i], "--scan-tree=", &arg) ||
- skip_prefix(argv[i], "--scan-path=", &arg)) {
+ } else if (skip_prefix(argv[i], "--scan-tree=", &arg) || skip_prefix(argv[i], "--scan-path=", &arg)) {
// A repository's snapshots setting is masked with the
// global one, and cgitrc has not been read here, so an
// empty mask would discard what the repository set.
@@ -327,8 +323,7 @@ static void parse_args(int argc, const char **argv)
}
}
if (scanned) {
- qsort(cgit_repolist.repos, cgit_repolist.count,
- sizeof(struct cgit_repo), cmp_repos);
+ qsort(cgit_repolist.repos, cgit_repolist.count, sizeof(struct cgit_repo), cmp_repos);
print_repolist(stdout, &cgit_repolist, 0);
exit(0);
}
@@ -358,8 +353,7 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
fd = open(locked_rc.buf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (fd == -1) {
err = errno;
- fprintf(stderr, "[cgit] Error opening %s: %s (%d)\n",
- locked_rc.buf, strerror(err), err);
+ fprintf(stderr, "[cgit] Error opening %s: %s (%d)\n", locked_rc.buf, strerror(err), err);
goto out;
}
if (fcntl(fd, F_SETLK, &lock) < 0) {
@@ -369,8 +363,7 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
// on every request and does deserve one.
err = errno;
if (err != EACCES && err != EAGAIN)
- fprintf(stderr, "[cgit] Error locking %s: %s (%d)\n",
- locked_rc.buf, strerror(err), err);
+ fprintf(stderr, "[cgit] Error locking %s: %s (%d)\n", locked_rc.buf, strerror(err), err);
close(fd);
goto out;
}
@@ -378,8 +371,12 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
// finishing in between renames that inode into place as the live
// list, and once the path is confirmed to still name this file that
// rename can no longer happen, because it takes the lock held here.
- if (fstat(fd, &held) || stat(locked_rc.buf, &named) ||
- held.st_ino != named.st_ino || held.st_dev != named.st_dev) {
+ if (
+ fstat(fd, &held) ||
+ stat(locked_rc.buf, &named) ||
+ held.st_ino != named.st_ino ||
+ held.st_dev != named.st_dev
+ ) {
err = EAGAIN;
close(fd);
goto out;
@@ -388,8 +385,7 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
// start from empty now that nobody else can be writing it.
if (ftruncate(fd, 0) < 0 || !(f = fdopen(fd, "w"))) {
err = errno;
- fprintf(stderr, "[cgit] Error writing %s: %s (%d)\n",
- locked_rc.buf, strerror(err), err);
+ fprintf(stderr, "[cgit] Error writing %s: %s (%d)\n", locked_rc.buf, strerror(err), err);
unlink(locked_rc.buf);
close(fd);
goto out;
@@ -405,8 +401,7 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
// that stops wherever the buffer happened to end.
if (fflush(f) || ferror(f)) {
err = errno;
- fprintf(stderr, "[cgit] Error writing %s: %s (%d)\n",
- locked_rc.buf, strerror(err), err);
+ fprintf(stderr, "[cgit] Error writing %s: %s (%d)\n", locked_rc.buf, strerror(err), err);
unlink(locked_rc.buf);
fclose(f);
goto out;
@@ -635,8 +630,7 @@ static void apply_config(const char *name, const char *value)
if (ctx.cfg.cache_size)
process_cached_repolist(cgit_expand_macros(value));
else if (ctx.cfg.project_list)
- scan_projects(cgit_expand_macros(value),
- ctx.cfg.project_list);
+ scan_projects(cgit_expand_macros(value), ctx.cfg.project_list);
else
scan_tree(cgit_expand_macros(value));
} else if (!strcmp(name, "scan-hidden-path"))
@@ -763,8 +757,7 @@ static void apply_query_param(const char *name, const char *value)
ctx.qry.has_difftype = 1;
} else if (!strcmp(name, "ss")) {
// No longer generated, but old links still carry it.
- ctx.qry.difftype = query_int(value, INT_MIN, INT_MAX) ?
- DIFF_SSDIFF : DIFF_UNIFIED;
+ ctx.qry.difftype = query_int(value, INT_MIN, INT_MAX) ? DIFF_SSDIFF : DIFF_UNIFIED;
ctx.qry.has_difftype = 1;
} else if (!strcmp(name, "all")) {
ctx.qry.show_all = query_int(value, INT_MIN, INT_MAX);
@@ -825,9 +818,13 @@ static void authenticate_cookie(void)
return;
}
- if (ctx.env.request_method && ctx.qry.page && !ctx.repo &&
- !strcmp(ctx.env.request_method, "POST") &&
- !strcmp(ctx.qry.page, "login")) {
+ if (
+ ctx.env.request_method &&
+ ctx.qry.page &&
+ !ctx.repo &&
+ !strcmp(ctx.env.request_method, "POST") &&
+ !strcmp(ctx.qry.page, "login")
+ ) {
authenticate_post();
return;
}
@@ -869,9 +866,11 @@ static int calc_ttl(void)
// Checked ahead of the snapshot ttl, because a tarball pinned to an
// object id can never come out differently and is the most expensive
// page to rebuild.
- if (ctx.qry.has_oid &&
- (!ctx.qry.oid || is_full_oid(ctx.qry.oid)) &&
- (!ctx.qry.oid2 || is_full_oid(ctx.qry.oid2)))
+ if (
+ ctx.qry.has_oid &&
+ (!ctx.qry.oid || is_full_oid(ctx.qry.oid)) &&
+ (!ctx.qry.oid2 || is_full_oid(ctx.qry.oid2))
+ )
return ctx.cfg.cache_static_ttl;
if (!strcmp(ctx.qry.page, "snapshot"))
@@ -927,8 +926,7 @@ static char *find_default_branch(struct cgit_repo *repo)
match.wanted = repo->defbranch;
match.first = NULL;
match.found = 0;
- refs_for_each_branch_ref(get_main_ref_store(the_repository),
- find_current_ref, &match);
+ refs_for_each_branch_ref(get_main_ref_store(the_repository), find_current_ref, &match);
if (match.found)
ref = match.wanted;
else
@@ -945,8 +943,7 @@ static char *guess_defbranch(void)
const char *ref, *refname;
struct object_id oid;
- ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
- "HEAD", 0, &oid, NULL);
+ ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository), "HEAD", 0, &oid, NULL);
if (!ref || !skip_prefix(ref, "refs/heads/", &refname))
return "master";
return xstrdup(refname);
@@ -956,8 +953,7 @@ static char *guess_defbranch(void)
* Split one readme setting into the file it names and the ref that file is
* read from, leaving the ref NULL for a file on disk. The caller frees both.
*/
-static void parse_readme(const char *readme, char **filename, char **ref,
- struct cgit_repo *repo)
+static void parse_readme(const char *readme, char **filename, char **ref, struct cgit_repo *repo)
{
const char *colon;
@@ -1007,8 +1003,7 @@ static void choose_readme(struct cgit_repo *repo)
found = 1;
break;
}
- }
- else if (!access(filename, R_OK)) {
+ } else if (!access(filename, R_OK)) {
found = 1;
break;
}
@@ -1042,14 +1037,12 @@ static int prepare_repo_cmd(int nongit)
if (nongit) {
const char *name = ctx.repo->name;
err = errno;
- ctx.page.title = cgit_fmtalloc("%s - %s", ctx.cfg.root_title,
- "config error");
+ ctx.page.title = cgit_fmtalloc("%s - %s", ctx.cfg.root_title, "config error");
ctx.repo = NULL;
cgit_print_http_headers();
cgit_print_docstart();
cgit_print_pageheader();
- cgit_print_error("Failed to open %s: %s", name,
- err ? strerror(err) : "Not a valid git repository");
+ cgit_print_error("Failed to open %s: %s", name, err ? strerror(err) : "Not a valid git repository");
cgit_print_docend();
return 1;
}
@@ -1080,8 +1073,7 @@ static int prepare_repo_cmd(int nongit)
if (repo_get_oid(the_repository, ctx.qry.head, &oid)) {
char *old_head = ctx.qry.head;
ctx.qry.head = xstrdup(ctx.repo->defbranch);
- cgit_print_error_page(404, "Not Found",
- "Invalid branch: %s", old_head);
+ cgit_print_error_page(404, "Not Found", "Invalid branch: %s", old_head);
free(old_head);
return 1;
}
@@ -1126,8 +1118,7 @@ static void process_request(void)
}
if (cmd->want_repo && !ctx.repo) {
- cgit_print_error_page(400, "Bad Request",
- "No repository selected");
+ cgit_print_error_page(400, "Bad Request", "No repository selected");
return;
}
@@ -1191,8 +1182,7 @@ void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *valu
else if (!strcmp(name, "module-link"))
repo->module_link = cgit_strdup_first_line(value);
else if (skip_prefix(name, "module-link.", &path)) {
- item = string_list_append(&repo->submodules,
- cgit_strdup_first_line(path));
+ item = string_list_append(&repo->submodules, cgit_strdup_first_line(path));
item->util = cgit_strdup_first_line(value);
} else if (!strcmp(name, "section"))
repo->section = cgit_strdup_first_line(value);
@@ -1210,11 +1200,14 @@ void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *valu
repo->hide = atoi(value);
else if (!strcmp(name, "ignore"))
repo->ignore = atoi(value);
- else if (!strcmp(name, "about-filter") || !strcmp(name, "commit-filter") ||
- !strcmp(name, "source-filter") || !strcmp(name, "email-filter")) {
+ else if (
+ !strcmp(name, "about-filter") ||
+ !strcmp(name, "commit-filter") ||
+ !strcmp(name, "source-filter") ||
+ !strcmp(name, "email-filter")
+ ) {
if (!ctx.cfg.enable_filter_overrides)
- fprintf(stderr, "[cgit] Ignoring repo %s: "
- "enable-filter-overrides is not set\n", name);
+ fprintf(stderr, "[cgit] Ignoring repo %s: enable-filter-overrides is not set\n", name);
else if (!strcmp(name, "about-filter"))
repo->about_filter = cgit_new_filter(value, ABOUT);
else if (!strcmp(name, "commit-filter"))
@@ -1282,13 +1275,11 @@ int cmd_main(int argc, const char **argv)
ctx.cfg.cache_size = 0;
build_cache_key(&cache_key);
- err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,
- cache_key.buf, ttl, process_request);
+ err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, cache_key.buf, ttl, process_request);
strbuf_release(&cache_key);
cgit_cleanup_filters();
if (err)
- cgit_print_error("Error processing page: %s (%d)",
- strerror(err), err);
+ cgit_print_error("Error processing page: %s (%d)", strerror(err), err);
return err;
}
diff --git a/source/cgit.h b/source/cgit.h
index 308fda2..cc4ac02 100644
--- a/source/cgit.h
+++ b/source/cgit.h
@@ -312,7 +312,6 @@ extern const char *cgit_version;
extern struct cgit_repolist cgit_repolist;
extern struct cgit_context ctx;
-extern void cgit_repo_config(struct cgit_repo *repo, const char *name,
- const char *value);
+extern void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *value);
#endif // CGIT_H
diff --git a/source/cgit.mk b/source/cgit.mk
index 1106b64..1199278 100644
--- a/source/cgit.mk
+++ b/source/cgit.mk
@@ -137,8 +137,7 @@ CGIT_OBJS := $(addprefix $(CGIT_BUILD)/,$(CGIT_OBJ_NAMES))
# version changes.
CGIT_VERSION_OBJS := $(addprefix $(CGIT_BUILD)/,cgit.o cgit.sp)
$(CGIT_VERSION_OBJS): $(CGIT_BUILD)/VERSION
-$(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \
- -DCGIT_VERSION='"$(CGIT_VERSION)"'
+$(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = -DCGIT_VERSION='"$(CGIT_VERSION)"'
# Git builds its list of dependency files with := before this file adds the
# cgit objects, so those are missing from it and have to be picked up here.
@@ -163,10 +162,8 @@ $(CGIT_BUILD)/CGIT-CFLAGS: FORCE
echo "$$FLAGS" >$(CGIT_BUILD)/CGIT-CFLAGS; \
fi
-$(CGIT_OBJS): $(CGIT_BUILD)/%.o: $(CGIT_SRC)/%.c GIT-CFLAGS \
- $(CGIT_BUILD)/CGIT-CFLAGS $(missing_dep_dirs)
- $(QUIET_CC)$(CC) -o $@ -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
- $(CGIT_CFLAGS) $<
+$(CGIT_OBJS): $(CGIT_BUILD)/%.o: $(CGIT_SRC)/%.c GIT-CFLAGS $(CGIT_BUILD)/CGIT-CFLAGS $(missing_dep_dirs)
+ $(QUIET_CC)$(CC) -o $@ -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $<
$(CGIT_BUILD)/cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
@echo 1>&2 " * $(LUA_MESSAGE)"
diff --git a/source/cmd.c b/source/cmd.c
index b6b1c67..2c6406f 100644
--- a/source/cmd.c
+++ b/source/cmd.c
@@ -46,9 +46,8 @@ static void about_fn(void)
// only works with a trailing slash.
path_info_len = ctx.env.path_info ? strlen(ctx.env.path_info) : 0;
if (!ctx.qry.path &&
- (!ctx.qry.url || !*ctx.qry.url ||
- ctx.qry.url[strlen(ctx.qry.url) - 1] != '/') &&
- (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) {
+ (!ctx.qry.url || !*ctx.qry.url || ctx.qry.url[strlen(ctx.qry.url) - 1] != '/') &&
+ (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) {
currenturl = cgit_currenturl();
redirect = cgit_fmtalloc("%s/", currenturl);
cgit_redirect(redirect, true);
@@ -100,10 +99,11 @@ static void info_fn(void)
static void log_fn(void)
{
- cgit_print_log(ctx.qry.oid, ctx.qry.ofs, ctx.cfg.max_commit_count,
- ctx.qry.grep, ctx.qry.search, ctx.qry.path, 1,
- ctx.repo->enable_commit_graph,
- ctx.repo->commit_sort);
+ cgit_print_log(
+ ctx.qry.oid, ctx.qry.ofs, ctx.cfg.max_commit_count, ctx.qry.grep,
+ ctx.qry.search, ctx.qry.path, 1, ctx.repo->enable_commit_graph,
+ ctx.repo->commit_sort
+ );
}
static void ls_cache_fn(void)
@@ -156,8 +156,7 @@ static void repolist_fn(void)
static void snapshot_fn(void)
{
- cgit_print_snapshot(ctx.qry.head, ctx.qry.oid, ctx.qry.path,
- ctx.qry.nohead);
+ cgit_print_snapshot(ctx.qry.head, ctx.qry.oid, ctx.qry.path, ctx.qry.nohead);
}
static void stats_fn(void)
diff --git a/source/cmd.h b/source/cmd.h
index 7299028..a75cdd0 100644
--- a/source/cmd.h
+++ b/source/cmd.h
@@ -13,9 +13,7 @@ typedef void (*cgit_cmd_fn)(void);
struct cgit_cmd {
const char *name;
cgit_cmd_fn fn;
- unsigned int want_repo:1,
- want_vpath:1,
- is_clone:1;
+ unsigned int want_repo:1, want_vpath:1, is_clone:1;
};
// The entry naming ctx.qry.page, or NULL when no page goes by that name.
diff --git a/source/filter.c b/source/filter.c
index a7efe56..2731d58 100644
--- a/source/filter.c
+++ b/source/filter.c
@@ -27,22 +27,17 @@ static int open_exec_filter(struct cgit_filter *base, va_list ap)
for (i = 0; i < filter->base.argument_count; i++)
filter->argv[i + 1] = va_arg(ap, char *);
- filter->old_stdout = cgit_die_unless_positive(dup(STDOUT_FILENO),
- "Unable to duplicate STDOUT");
- cgit_die_unless_zero(pipe(pipefd),
- "Unable to create pipe to subprocess");
- filter->pid = cgit_die_unless_non_negative(fork(),
- "Unable to create subprocess");
+ filter->old_stdout = cgit_die_unless_positive(dup(STDOUT_FILENO), "Unable to duplicate STDOUT");
+ cgit_die_unless_zero(pipe(pipefd), "Unable to create pipe to subprocess");
+ filter->pid = cgit_die_unless_non_negative(fork(), "Unable to create subprocess");
if (filter->pid == 0) {
close(pipefd[1]);
- cgit_die_unless_non_negative(dup2(pipefd[0], STDIN_FILENO),
- "Unable to use pipe as STDIN");
+ cgit_die_unless_non_negative(dup2(pipefd[0], STDIN_FILENO), "Unable to use pipe as STDIN");
execvp(filter->cmd, filter->argv);
die_errno("Unable to exec subprocess %s", filter->cmd);
}
close(pipefd[0]);
- cgit_die_unless_non_negative(dup2(pipefd[1], STDOUT_FILENO),
- "Unable to use pipe as STDOUT");
+ cgit_die_unless_non_negative(dup2(pipefd[1], STDOUT_FILENO), "Unable to use pipe as STDOUT");
close(pipefd[1]);
return 0;
}
@@ -52,8 +47,7 @@ static int close_exec_filter(struct cgit_filter *base)
struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base;
int i, exit_status = 0;
- cgit_die_unless_non_negative(dup2(filter->old_stdout, STDOUT_FILENO),
- "Unable to restore STDOUT");
+ cgit_die_unless_non_negative(dup2(filter->old_stdout, STDOUT_FILENO), "Unable to restore STDOUT");
close(filter->old_stdout);
if (filter->pid < 0)
goto done;
@@ -68,8 +62,7 @@ done:
return WEXITSTATUS(exit_status);
}
-static void fprintf_exec_filter(struct cgit_filter *base, FILE *f,
- const char *prefix)
+static void fprintf_exec_filter(struct cgit_filter *base, FILE *f, const char *prefix)
{
struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base;
fprintf(f, "%sexec:%s\n", prefix, filter->cmd);
@@ -101,8 +94,7 @@ static struct cgit_filter *new_exec_filter(const char *cmd, int argument_count)
return &filter->base;
}
-void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd,
- char **argv)
+void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv)
{
memset(filter, 0, sizeof(*filter));
filter->base.open = open_exec_filter;
@@ -127,8 +119,7 @@ struct lua_filter {
lua_State *lua_state;
};
-typedef ssize_t (*filter_write_fn)(struct cgit_filter *base, const void *buf,
- size_t count);
+typedef ssize_t (*filter_write_fn)(struct cgit_filter *base, const void *buf, size_t count);
static ssize_t (*libc_write)(int fd, const void *buf, size_t count);
static filter_write_fn filter_write = NULL;
@@ -152,8 +143,7 @@ ssize_t write(int fd, const void *buf, size_t count)
return filter_write(current_write_filter, buf, count);
}
-static inline void hook_write(struct cgit_filter *filter,
- filter_write_fn write_fn)
+static inline void hook_write(struct cgit_filter *filter, filter_write_fn write_fn)
{
// Filters cannot nest, because there is one stdout and one hook, so a
// second one would strand the first.
@@ -178,12 +168,10 @@ static NORETURN void die_lua_error(struct lua_filter *filter)
// page would be fed back into the broken filter.
if (filter_write)
unhook_write();
- die("Lua error in %s: %s", filter->script_file,
- lua_tostring(filter->lua_state, -1));
+ die("Lua error in %s: %s", filter->script_file, lua_tostring(filter->lua_state, -1));
}
-static ssize_t write_lua_filter(struct cgit_filter *base, const void *buf,
- size_t count)
+static ssize_t write_lua_filter(struct cgit_filter *base, const void *buf, size_t count)
{
struct lua_filter *filter = (struct lua_filter *)base;
@@ -199,8 +187,7 @@ static ssize_t write_lua_filter(struct cgit_filter *base, const void *buf,
* so the hook comes off around the call. The zero returned is Lua's count
* of values pushed, not a success code.
*/
-static inline int emit_unfiltered(lua_State *lua_state,
- void (*emit)(const char *text))
+static inline int emit_unfiltered(lua_State *lua_state, void (*emit)(const char *text))
{
const char *text;
filter_write_fn saved_write;
@@ -330,8 +317,7 @@ static int close_lua_filter(struct cgit_filter *base)
return ret;
}
-static void fprintf_lua_filter(struct cgit_filter *base, FILE *f,
- const char *prefix)
+static void fprintf_lua_filter(struct cgit_filter *base, FILE *f, const char *prefix)
{
struct lua_filter *filter = (struct lua_filter *)base;
fprintf(f, "%slua:%s\n", prefix, filter->script_file);
@@ -391,8 +377,7 @@ int cgit_close_filter(struct cgit_filter *filter)
return filter->close(filter);
}
-void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f,
- const char *prefix)
+void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix)
{
filter->fprintfp(filter, f, prefix);
}
@@ -469,8 +454,7 @@ struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype)
return new_exec_filter(cmd, argument_count);
for (i = 0; i < ARRAY_SIZE(filter_specs); i++) {
- if (len == strlen(filter_specs[i].prefix) &&
- !strncmp(filter_specs[i].prefix, cmd, len))
+ if (len == strlen(filter_specs[i].prefix) && !strncmp(filter_specs[i].prefix, cmd, len))
return filter_specs[i].create(colon + 1, argument_count);
}
diff --git a/source/html.c b/source/html.c
index 2e3a3b7..b97fdbb 100644
--- a/source/html.c
+++ b/source/html.c
@@ -324,8 +324,7 @@ void html_hidden(const char *name, const char *value)
html("'>");
}
-void html_option(const char *value, const char *text,
- const char *selected_value)
+void html_option(const char *value, const char *text, const char *selected_value)
{
html("<option value='");
html_attr(value);
@@ -339,8 +338,7 @@ void html_option(const char *value, const char *text,
void html_intoption(int value, const char *text, int selected_value)
{
- htmlf("<option value='%d'%s>", value,
- value == selected_value ? " selected" : "");
+ htmlf("<option value='%d'%s>", value, value == selected_value ? " selected" : "");
html_txt(text);
html("</option>\n");
}
@@ -371,8 +369,7 @@ void html_link_close(void)
*/
void html_fileperm(unsigned short mode)
{
- htmlf("%c%c%c", (mode & 4 ? 'r' : '-'),
- (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-'));
+ htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-'));
}
int html_include(const char *filename)
@@ -382,8 +379,7 @@ int html_include(const char *filename)
size_t len;
if (!(f = fopen(filename, "r"))) {
- fprintf(stderr, "[cgit] Error including file %s: %s (%d)\n",
- filename, strerror(errno), errno);
+ fprintf(stderr, "[cgit] Error including file %s: %s (%d)\n", filename, strerror(errno), errno);
return -1;
}
while ((len = fread(buf, 1, sizeof(buf), f)) > 0)
@@ -392,8 +388,7 @@ int html_include(const char *filename)
return 0;
}
-void http_parse_querystring(const char *txt,
- void (*fn)(const char *name, const char *value))
+void http_parse_querystring(const char *txt, void (*fn)(const char *name, const char *value))
{
const char *p = txt;
diff --git a/source/html.h b/source/html.h
index 3bbb30e..410661b 100644
--- a/source/html.h
+++ b/source/html.h
@@ -67,17 +67,13 @@ extern char *cgit_fmt(const char *format, ...);
__attribute__((format (printf,1,2)))
extern char *cgit_fmtalloc(const char *format, ...);
-extern void html_option(const char *value, const char *text,
- const char *selected_value);
+extern void html_option(const char *value, const char *text, const char *selected_value);
extern void html_intoption(int value, const char *text, int selected_value);
-extern void html_link_open(const char *url, const char *title,
- const char *class);
+extern void html_link_open(const char *url, const char *title, const char *class);
extern void html_link_close(void);
extern void html_fileperm(unsigned short mode);
extern int html_include(const char *filename);
-extern void http_parse_querystring(const char *txt,
- void (*fn)(const char *name,
- const char *value));
+extern void http_parse_querystring(const char *txt, void (*fn)(const char *name, const char *value));
#endif // CGIT_HTML_H
diff --git a/source/parsing.c b/source/parsing.c
index 745bbba..c992538 100644
--- a/source/parsing.c
+++ b/source/parsing.c
@@ -29,8 +29,7 @@ static char *substr(const char *start, const char *end)
return buf;
}
-static void parse_user(const char *line, char **name, char **email,
- timestamp_t *date, int *tz)
+static void parse_user(const char *line, char **name, char **email, timestamp_t *date, int *tz)
{
struct ident_split ident;
struct strbuf address = STRBUF_INIT;
@@ -158,14 +157,12 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
p += the_hash_algo->hexsz + 1;
if (skip_prefix(p, "author ", &p)) {
- parse_user(p, &info->author, &info->author_email,
- &info->author_date, &info->author_tz);
+ parse_user(p, &info->author, &info->author_email, &info->author_date, &info->author_tz);
p = next_header_line(p);
}
if (p && skip_prefix(p, "committer ", &p)) {
- parse_user(p, &info->committer, &info->committer_email,
- &info->committer_date, &info->committer_tz);
+ parse_user(p, &info->committer, &info->committer_email, &info->committer_date, &info->committer_tz);
p = next_header_line(p);
}
@@ -218,8 +215,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)
const char *p;
struct taginfo *info = NULL;
- data = odb_read_object(the_repository->objects, &tag->object.oid,
- &type, &size);
+ data = odb_read_object(the_repository->objects, &tag->object.oid, &type, &size);
if (!data || type != OBJ_TAG)
goto cleanup;
@@ -227,8 +223,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)
for (p = data; !end_of_header(p); p = next_header_line(p)) {
if (skip_prefix(p, "tagger ", &p)) {
- parse_user(p, &info->tagger, &info->tagger_email,
- &info->tagger_date, &info->tagger_tz);
+ parse_user(p, &info->tagger, &info->tagger_email, &info->tagger_date, &info->tagger_tz);
}
}
diff --git a/source/scan-tree.c b/source/scan-tree.c
index f72a5be..c46b47d 100644
--- a/source/scan-tree.c
+++ b/source/scan-tree.c
@@ -16,8 +16,7 @@
// Git writes this line into the description file of every repository it
// creates, so a repository still carrying it gets cgit's own default instead.
static const char *default_git_desc =
- "Unnamed repository; edit this file 'description' to name the "
- "repository.";
+ "Unnamed repository; edit this file 'description' to name the repository.";
// The config callbacks are handed only a name and a value, so the repository
// being filled in waits here for the length of one add_repo call.
@@ -33,8 +32,7 @@ static int stat_entry(const char *dir, const char *name, struct stat *st)
// A missing entry is the ordinary answer for a directory that is not a
// repository, so only some other failure is worth reporting.
if (err && errno != ENOENT)
- fprintf(stderr, "[cgit] Error checking path %s: %s (%d)\n",
- dir, strerror(errno), errno);
+ fprintf(stderr, "[cgit] Error checking path %s: %s (%d)\n", dir, strerror(errno), errno);
strbuf_release(&path);
return err;
}
@@ -51,8 +49,7 @@ static int is_git_dir(const char *path)
}
static int apply_gitconfig(const char *key, const char *value,
- const __attribute__((unused)) struct config_context *cfg_ctx,
- void *cb)
+ const __attribute__((unused)) struct config_context *cfg_ctx, void *cb)
{
const char *name;
@@ -94,8 +91,7 @@ static char *section_slash(struct strbuf *relpath, int depth)
depth--;
} else {
slash = relpath->buf + relpath->len;
- while (slash && depth &&
- (slash = find_char_back(relpath->buf, slash - 1, '/')))
+ while (slash && depth && (slash = find_char_back(relpath->buf, slash - 1, '/')))
depth++;
}
return slash && !depth ? slash : NULL;
@@ -127,8 +123,7 @@ static void add_repo(const char *base, struct strbuf *path)
size_t desc_size;
if (stat(path->buf, &st)) {
- fprintf(stderr, "[cgit] Error accessing %s: %s (%d)\n",
- path->buf, strerror(errno), errno);
+ fprintf(stderr, "[cgit] Error accessing %s: %s (%d)\n", path->buf, strerror(errno), errno);
return;
}
@@ -184,18 +179,15 @@ static void add_repo(const char *base, struct strbuf *path)
if (pwd->pw_gecos)
if ((comma = strchr(pwd->pw_gecos, ',')))
*comma = '\0';
- current_repo->owner = cgit_strdup_first_line(
- pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
+ current_repo->owner = cgit_strdup_first_line(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name);
}
if (current_repo->desc == cgit_default_repo_desc || !current_repo->desc) {
strbuf_addstr(path, "description");
if (!stat(path->buf, &st))
- cgit_read_first_line(path->buf, &current_repo->desc,
- &desc_size);
+ cgit_read_first_line(path->buf, &current_repo->desc, &desc_size);
strbuf_setlen(path, pathlen);
- if (current_repo->desc &&
- !strcmp(current_repo->desc, default_git_desc)) {
+ if (current_repo->desc && !strcmp(current_repo->desc, default_git_desc)) {
free(current_repo->desc);
current_repo->desc = cgit_default_repo_desc;
}
@@ -231,8 +223,7 @@ static void scan_path(const char *base, const char *path)
struct stat st;
if (!dir) {
- fprintf(stderr, "[cgit] Error opening directory %s: %s (%d)\n",
- path, strerror(errno), errno);
+ fprintf(stderr, "[cgit] Error opening directory %s: %s (%d)\n", path, strerror(errno), errno);
return;
}
@@ -255,8 +246,7 @@ static void scan_path(const char *base, const char *path)
strbuf_setlen(&pathbuf, pathlen);
strbuf_addstr(&pathbuf, ent->d_name);
if (stat(pathbuf.buf, &st)) {
- fprintf(stderr, "[cgit] Error checking path %s: %s (%d)\n",
- pathbuf.buf, strerror(errno), errno);
+ fprintf(stderr, "[cgit] Error checking path %s: %s (%d)\n", pathbuf.buf, strerror(errno), errno);
continue;
}
if (S_ISDIR(st.st_mode))
diff --git a/source/shared.c b/source/shared.c
index fab5c13..beda48b 100644
--- a/source/shared.c
+++ b/source/shared.c
@@ -45,8 +45,7 @@ static void free_refinfo(struct refinfo *ref)
free(ref);
}
-static struct refinfo *make_refinfo(const char *refname,
- const struct object_id *oid)
+static struct refinfo *make_refinfo(const char *refname, const struct object_id *oid)
{
struct refinfo *ref;
@@ -81,8 +80,7 @@ static int load_mmfile(mmfile_t *file, const struct object_id *oid)
return 1;
}
- file->ptr = odb_read_object(the_repository->objects, oid, &type,
- (unsigned long *)&file->size);
+ file->ptr = odb_read_object(the_repository->objects, oid, &type, (unsigned long *)&file->size);
// odb_read_object leaves size untouched when it fails, so the caller
// has to be told rather than handed a buffer with an unset length.
return file->ptr != NULL;
@@ -194,9 +192,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
cgit_repolist.length = 8;
else
cgit_repolist.length *= 2;
- cgit_repolist.repos = xrealloc(cgit_repolist.repos,
- cgit_repolist.length *
- sizeof(struct cgit_repo));
+ cgit_repolist.repos = xrealloc(cgit_repolist.repos, cgit_repolist.length * sizeof(struct cgit_repo));
}
repo = &cgit_repolist.repos[cgit_repolist.count-1];
@@ -342,8 +338,7 @@ int cgit_refs_cb(const struct reference *ref, void *cb_data)
return 0;
}
-void cgit_diff_tree_cb(struct diff_queue_struct *q,
- struct diff_options *options, void *data)
+void cgit_diff_tree_cb(struct diff_queue_struct *q, struct diff_options *options, void *data)
{
filepair_fn fn = (filepair_fn)data;
int i;
@@ -356,10 +351,9 @@ void cgit_diff_tree_cb(struct diff_queue_struct *q,
}
}
-int cgit_diff_files(const struct object_id *old_oid,
- const struct object_id *new_oid, unsigned long *old_size,
- unsigned long *new_size, int *binary, int context,
- int ignorews, linediff_fn fn)
+int cgit_diff_files(const struct object_id *old_oid, const struct object_id *new_oid,
+ unsigned long *old_size, unsigned long *new_size, int *binary, int context, int ignorews,
+ linediff_fn fn)
{
mmfile_t old_file, new_file;
xpparam_t diff_params;
@@ -370,19 +364,17 @@ int cgit_diff_files(const struct object_id *old_oid,
// Read the object headers first so an oversized blob is never inflated
// into memory just to be diffed. Reporting it as binary suppresses
// inlining the same way max-blob-size does in the other views.
- if (!is_null_oid(old_oid) &&
- odb_read_object_info(the_repository->objects, old_oid, &old_bytes) < 0)
+ if (!is_null_oid(old_oid) && odb_read_object_info(the_repository->objects, old_oid, &old_bytes) < 0)
return 1;
- if (!is_null_oid(new_oid) &&
- odb_read_object_info(the_repository->objects, new_oid, &new_bytes) < 0)
+ if (!is_null_oid(new_oid) && odb_read_object_info(the_repository->objects, new_oid, &new_bytes) < 0)
return 1;
*old_size = old_bytes;
*new_size = new_bytes;
if (ctx.cfg.max_blob_size &&
- (old_bytes / 1024 > (unsigned long)ctx.cfg.max_blob_size ||
- new_bytes / 1024 > (unsigned long)ctx.cfg.max_blob_size)) {
+ (old_bytes / 1024 > (unsigned long)ctx.cfg.max_blob_size ||
+ new_bytes / 1024 > (unsigned long)ctx.cfg.max_blob_size)) {
*binary = 1;
return 0;
}
@@ -394,8 +386,7 @@ int cgit_diff_files(const struct object_id *old_oid,
return 1;
}
- if (buffer_is_binary(old_file.ptr, old_file.size) ||
- buffer_is_binary(new_file.ptr, new_file.size)) {
+ if (buffer_is_binary(old_file.ptr, old_file.size) || buffer_is_binary(new_file.ptr, new_file.size)) {
*binary = 1;
release_mmfile(&old_file, old_oid);
release_mmfile(&new_file, new_oid);
@@ -418,9 +409,8 @@ int cgit_diff_files(const struct object_id *old_oid,
return 0;
}
-void cgit_diff_tree(const struct object_id *old_oid,
- const struct object_id *new_oid,
- filepair_fn fn, const char *prefix, int ignorews)
+void cgit_diff_tree(const struct object_id *old_oid, const struct object_id *new_oid,
+ filepair_fn fn, const char *prefix, int ignorews)
{
struct diff_options opt;
struct pathspec_item *item;
@@ -457,8 +447,7 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)
if (commit->parents)
old_oid = &commit->parents->item->object.oid;
- cgit_diff_tree(old_oid, &commit->object.oid, fn, prefix,
- ctx.qry.ignorews);
+ cgit_diff_tree(old_oid, &commit->object.oid, fn, prefix, ctx.qry.ignorews);
}
/*
@@ -508,10 +497,8 @@ void cgit_prepare_repo_env(struct cgit_repo *repo)
for (i = 0; i < ARRAY_SIZE(vars); i++)
if (vars[i].value && setenv(vars[i].name, vars[i].value, 1))
- fprintf(stderr,
- "[cgit] Error setting env %s=%s: %s (%d)\n",
- vars[i].name, vars[i].value,
- strerror(errno), errno);
+ fprintf(stderr, "[cgit] Error setting env %s=%s: %s (%d)\n",
+ vars[i].name, vars[i].value, strerror(errno), errno);
}
int cgit_read_first_line(const char *path, char **buf, size_t *size)
diff --git a/source/shared.h b/source/shared.h
index 9f4cba3..b9f6ecf 100644
--- a/source/shared.h
+++ b/source/shared.h
@@ -44,8 +44,7 @@ extern int cgit_refs_cb(const struct reference *ref, void *cb_data);
extern void cgit_free_commitinfo(struct commitinfo *info);
extern void cgit_free_taginfo(struct taginfo *info);
-extern void cgit_diff_tree_cb(struct diff_queue_struct *q,
- struct diff_options *options, void *data);
+extern void cgit_diff_tree_cb(struct diff_queue_struct *q, struct diff_options *options, void *data);
/*
* Diff two blobs and hand fn one line at a time. Returns non-zero when either
@@ -53,17 +52,13 @@ extern void cgit_diff_tree_cb(struct diff_queue_struct *q,
* sets binary instead, and produces no lines, so the caller can offer a link
* in place of the content.
*/
-extern int cgit_diff_files(const struct object_id *old_oid,
- const struct object_id *new_oid,
- unsigned long *old_size, unsigned long *new_size,
- int *binary, int context, int ignorews,
- linediff_fn fn);
+extern int cgit_diff_files(const struct object_id *old_oid, const struct object_id *new_oid,
+ unsigned long *old_size, unsigned long *new_size, int *binary, int context, int ignorews,
+ linediff_fn fn);
-extern void cgit_diff_tree(const struct object_id *old_oid,
- const struct object_id *new_oid,
- filepair_fn fn, const char *prefix, int ignorews);
-extern void cgit_diff_commit(struct commit *commit, filepair_fn fn,
- const char *prefix);
+extern void cgit_diff_tree(const struct object_id *old_oid, const struct object_id *new_oid,
+ filepair_fn fn, const char *prefix, int ignorews);
+extern void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix);
// Accept only the date formats cgit documents, leaving mode unchanged for
// anything else.
diff --git a/source/ui-atom.c b/source/ui-atom.c
index 3eb4332..46039a0 100644
--- a/source/ui-atom.c
+++ b/source/ui-atom.c
@@ -87,8 +87,7 @@ static void xml_txt(const char *txt)
strbuf_addstr(&sb, XML_REPLACEMENT);
} else if ((seq = utf8_seq_len(p, left))) {
// U+FFFE and U+FFFF are valid UTF-8 but not XML.
- if (seq == 3 && p[0] == 0xef && p[1] == 0xbf &&
- p[2] >= 0xbe)
+ if (seq == 3 && p[0] == 0xef && p[1] == 0xbf && p[2] >= 0xbe)
strbuf_addstr(&sb, XML_REPLACEMENT);
else
strbuf_add(&sb, p, seq);
diff --git a/source/ui-blame.c b/source/ui-blame.c
index 8a7f8f0..7248120 100644
--- a/source/ui-blame.c
+++ b/source/ui-blame.c
@@ -52,7 +52,7 @@ static void free_suspect_details(void)
* keep them alive together.
*/
static void run_blame(struct blame_scoreboard *sb, struct rev_info *revs,
- const char *path, const char *rev)
+ const char *path, const char *rev)
{
struct strvec argv = STRVEC_INIT;
struct blame_origin *origin;
@@ -120,15 +120,13 @@ static char *suspect_detail(struct blame_origin *suspect)
if (ctx.cfg.enable_plain_email)
strbuf_addf(&detail, " %s", info->author_email);
strbuf_addf(&detail, " %s\n",
- show_date(info->author_date, info->author_tz,
- cgit_date_mode(DATE_ISO8601)));
+ show_date(info->author_date, info->author_tz, cgit_date_mode(DATE_ISO8601)));
strbuf_addf(&detail, "committer %s", info->committer);
if (ctx.cfg.enable_plain_email)
strbuf_addf(&detail, " %s", info->committer_email);
strbuf_addf(&detail, " %s\n\n",
- show_date(info->committer_date, info->committer_tz,
- cgit_date_mode(DATE_ISO8601)));
+ show_date(info->committer_date, info->committer_tz, cgit_date_mode(DATE_ISO8601)));
strbuf_addstr(&detail, info->subject);
@@ -145,20 +143,20 @@ static void emit_entry_hash(struct blame_entry *ent)
const char *detail = suspect_detail(suspect);
html("<span class='oid'>");
- cgit_commit_link(repo_find_unique_abbrev(the_repository, oid,
- DEFAULT_ABBREV),
- detail, NULL, ctx.qry.head, oid_to_hex(oid),
- suspect->path);
+ cgit_commit_link(
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
+ detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path
+ );
html("</span>");
- if (!repo_parse_commit(the_repository, suspect->commit) &&
- suspect->commit->parents) {
+ if (!repo_parse_commit(the_repository, suspect->commit) && suspect->commit->parents) {
struct commit *parent = suspect->commit->parents->item;
html(" ");
- cgit_blame_link("^", "Blame the previous revision", NULL,
- ctx.qry.head, oid_to_hex(&parent->object.oid),
- suspect->path);
+ cgit_blame_link(
+ "^", "Blame the previous revision", NULL, ctx.qry.head,
+ oid_to_hex(&parent->object.oid), suspect->path
+ );
}
// The stripes only line up across the columns if each column gives an
@@ -228,8 +226,7 @@ static size_t line_width(struct blame_scoreboard *sb, int line)
* these blocks, so each block has to be padded to the height and width of
* the lines it stands behind.
*/
-static void emit_entry_background(struct blame_scoreboard *sb,
- struct blame_entry *ent)
+static void emit_entry_background(struct blame_scoreboard *sb, struct blame_entry *ent)
{
size_t widest = 2;
int line;
@@ -267,7 +264,7 @@ static void emit_line_backgrounds(struct blame_scoreboard *sb)
}
static void print_blame_page(const struct object_id *oid, const char *path,
- const char *filename, const char *rev)
+ const char *filename, const char *rev)
{
enum object_type type;
char *buf;
@@ -277,21 +274,20 @@ static void print_blame_page(const struct object_id *oid, const char *path,
type = odb_read_object_info(the_repository->objects, oid, &size);
if (type == OBJ_BAD) {
- cgit_print_error_page(404, "Not Found", "Bad object name: %s",
- oid_to_hex(oid));
+ cgit_print_error_page(404, "Not Found", "Bad object name: %s", oid_to_hex(oid));
return;
}
if (ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size) {
- cgit_print_error_page(413, "Content Too Large",
- "blob size (%luKB) exceeds display size limit (%dKB)",
- size / 1024, ctx.cfg.max_blob_size);
+ cgit_print_error_page(
+ 413, "Content Too Large", "blob size (%luKB) exceeds display size limit (%dKB)",
+ size / 1024, ctx.cfg.max_blob_size
+ );
return;
}
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf) {
- cgit_print_error_page(500, "Internal Server Error",
- "Error reading object %s", oid_to_hex(oid));
+ cgit_print_error_page(500, "Internal Server Error", "Error reading object %s", oid_to_hex(oid));
return;
}
@@ -357,27 +353,24 @@ cleanup:
}
static int walk_tree(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *data)
+ const char *pathname, unsigned mode, void *data)
{
struct walk_tree_context *walk = data;
// match_baselen is -1 when no path was given, which no length equals.
- if (walk->match_baselen >= 0 &&
- base->len == (size_t)walk->match_baselen) {
+ if (walk->match_baselen >= 0 && base->len == (size_t)walk->match_baselen) {
if (S_ISREG(mode)) {
struct strbuf fullpath = STRBUF_INIT;
strbuf_addbuf(&fullpath, base);
strbuf_addstr(&fullpath, pathname);
- print_blame_page(oid, fullpath.buf, pathname,
- walk->rev);
+ print_blame_page(oid, fullpath.buf, pathname, walk->rev);
strbuf_release(&fullpath);
walk->found = TARGET_FILE;
} else if (S_ISDIR(mode)) {
walk->found = TARGET_FOLDER;
}
- } else if (base->len < INT_MAX
- && (int)base->len > walk->match_baselen) {
+ } else if (base->len < INT_MAX && (int)base->len > walk->match_baselen) {
walk->found = TARGET_FOLDER;
} else if (S_ISDIR(mode)) {
return READ_TREE_RECURSIVE;
@@ -419,28 +412,23 @@ void cgit_print_blame(void)
rev = ctx.qry.head;
if (repo_get_oid(the_repository, rev, &oid)) {
- cgit_print_error_page(404, "Not Found",
- "Invalid revision name: %s", rev);
+ cgit_print_error_page(404, "Not Found", "Invalid revision name: %s", rev);
return;
}
commit = lookup_commit_reference(the_repository, &oid);
if (!commit || repo_parse_commit(the_repository, commit)) {
- cgit_print_error_page(404, "Not Found",
- "Invalid commit reference: %s", rev);
+ cgit_print_error_page(404, "Not Found", "Invalid commit reference: %s", rev);
return;
}
walk.rev = xstrdup(rev);
- walk.match_baselen = path_items.match ?
- basedir_len(path_items.match) : -1;
+ walk.match_baselen = path_items.match ? basedir_len(path_items.match) : -1;
- read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
- &paths, walk_tree, &walk);
+ read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
if (walk.found == TARGET_MISSING)
cgit_print_error_page(404, "Not Found", "Not found");
else if (walk.found == TARGET_FOLDER)
- cgit_print_error_page(404, "Not Found",
- "Blame is not available for folders.");
+ cgit_print_error_page(404, "Not Found", "Blame is not available for folders.");
free(walk.rev);
}
diff --git a/source/ui-blob.c b/source/ui-blob.c
index 67af675..a298e54 100644
--- a/source/ui-blob.c
+++ b/source/ui-blob.c
@@ -26,14 +26,13 @@ struct walk_tree_context {
* READ_TREE_RECURSIVE means step into this entry and zero means step over it.
*/
static int walk_tree(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *context)
+ const char *pathname, unsigned mode, void *context)
{
struct walk_tree_context *walk = context;
if (walk->file_only && !S_ISREG(mode))
return READ_TREE_RECURSIVE;
- if (strncmp(base->buf, walk->match_path, base->len)
- || strcmp(walk->match_path + base->len, pathname))
+ if (strncmp(base->buf, walk->match_path, base->len) || strcmp(walk->match_path + base->len, pathname))
return READ_TREE_RECURSIVE;
oidcpy(walk->matched_oid, oid);
walk->found_path = 1;
@@ -66,8 +65,7 @@ static int find_path_oid(struct object_id *oid, char *path, int file_only)
.file_only = file_only
};
- read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
- &paths, walk_tree, &walk);
+ read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
return walk.found_path;
}
@@ -77,8 +75,7 @@ static int find_path_oid(struct object_id *oid, char *path, int file_only)
*/
static int over_size_limit(unsigned long size)
{
- return ctx.cfg.max_blob_size &&
- size / 1024 > (unsigned long)ctx.cfg.max_blob_size;
+ return ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size;
}
int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
@@ -155,14 +152,12 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
if (hex) {
if (get_oid_hex(hex, &oid)) {
- cgit_print_error_page(400, "Bad Request",
- "Bad hex value: %s", hex);
+ cgit_print_error_page(400, "Bad Request", "Bad hex value: %s", hex);
return;
}
} else {
if (repo_get_oid(the_repository, head, &oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad ref: %s", head);
+ cgit_print_error_page(404, "Not Found", "Bad ref: %s", head);
return;
}
}
@@ -171,30 +166,26 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
if (!hex && type == OBJ_COMMIT && path) {
if (!find_path_oid(&oid, path, file_only)) {
- cgit_print_error_page(404, "Not Found",
- "Path not found: %s", path);
+ cgit_print_error_page(404, "Not Found", "Path not found: %s", path);
return;
}
type = odb_read_object_info(the_repository->objects, &oid, &size);
}
if (type == OBJ_BAD) {
- cgit_print_error_page(404, "Not Found",
- "Bad object name: %s", hex ? hex : path);
+ cgit_print_error_page(404, "Not Found", "Bad object name: %s", hex ? hex : path);
return;
}
if (over_size_limit(size)) {
- cgit_print_error_page(413, "Content Too Large",
- "Object size (%luKB) exceeds limit (%dKB)",
- size / 1024, ctx.cfg.max_blob_size);
+ cgit_print_error_page(413, "Content Too Large", "Object size (%luKB) exceeds limit (%dKB)",
+ size / 1024, ctx.cfg.max_blob_size);
return;
}
buf = odb_read_object(the_repository->objects, &oid, &type, &size);
if (!buf) {
- cgit_print_error_page(500, "Internal Server Error",
- "Error reading object %s", hex ? hex : path);
+ cgit_print_error_page(500, "Internal Server Error", "Error reading object %s", hex ? hex : path);
return;
}
diff --git a/source/ui-blob.h b/source/ui-blob.h
index eb3dbd1..2eab0db 100644
--- a/source/ui-blob.h
+++ b/source/ui-blob.h
@@ -8,11 +8,8 @@
#ifndef CGIT_UI_BLOB_H
#define CGIT_UI_BLOB_H
-extern int cgit_ref_path_exists(const char *path, const char *ref,
- int file_only);
-extern int cgit_print_file(char *path, const char *head, int file_only,
- int html_escape);
-extern void cgit_print_blob(const char *hex, char *path, const char *head,
- int file_only);
+extern int cgit_ref_path_exists(const char *path, const char *ref, int file_only);
+extern int cgit_print_file(char *path, const char *head, int file_only, int html_escape);
+extern void cgit_print_blob(const char *hex, char *path, const char *head, int file_only);
#endif // CGIT_UI_BLOB_H
diff --git a/source/ui-clone.c b/source/ui-clone.c
index f5c4d59..4329e9d 100644
--- a/source/ui-clone.c
+++ b/source/ui-clone.c
@@ -70,12 +70,10 @@ static void print_pack_info(void)
// because a pack the multi-pack-index already covers joins that
// list only when the accessor loads it, and reading the field
// directly leaves those packs unfindable.
- for (entry = packfile_store_get_packs(files->packed); entry;
- entry = entry->next) {
+ for (entry = packfile_store_get_packs(files->packed); entry; entry = entry->next) {
struct packed_git *pack = entry->pack;
if (pack->pack_local)
- htmlf("P %s\n",
- last_path_component(pack->pack_name));
+ htmlf("P %s\n", last_path_component(pack->pack_name));
}
}
}
@@ -134,8 +132,7 @@ void cgit_clone_info(void)
ctx.page.mimetype = "text/plain";
ctx.page.filename = "info/refs";
cgit_print_http_headers();
- refs_for_each_ref(get_main_ref_store(the_repository),
- print_ref, NULL);
+ refs_for_each_ref(get_main_ref_store(the_repository), print_ref, NULL);
}
void cgit_clone_objects(void)
diff --git a/source/ui-commit.c b/source/ui-commit.c
index a35fcec..6055509 100644
--- a/source/ui-commit.c
+++ b/source/ui-commit.c
@@ -23,8 +23,8 @@
// many parents or more is shown without a diff at all.
#define OCTOPUS_PARENTS 3
-static void print_ident_row(const char *role, const char *name,
- const char *email, timestamp_t date, int tz)
+static void print_ident_row(const char *role, const char *name, const char *email,
+ timestamp_t date, int tz)
{
htmlf("<tr><th>%s</th><td>", role);
cgit_open_filter(ctx.repo->email_filter, email, "commit");
@@ -41,8 +41,7 @@ static void print_ident_row(const char *role, const char *name,
html("</time></td></tr>\n");
}
-static int print_parent_rows(struct commit *commit, const char *rev,
- const char *prefix)
+static int print_parent_rows(struct commit *commit, const char *rev, const char *prefix)
{
struct commit_list *p;
struct commit *parent;
@@ -50,24 +49,20 @@ static int print_parent_rows(struct commit *commit, const char *rev,
int parents = 0;
for (p = commit->parents; p; p = p->next) {
- parent = lookup_commit_reference(the_repository,
- &p->item->object.oid);
+ parent = lookup_commit_reference(the_repository, &p->item->object.oid);
if (!parent) {
html("<tr><td colspan='3'>");
cgit_print_error("Error reading parent commit");
html("</td></tr>\n");
continue;
}
- html("<tr><th>parent</th>"
- "<td colspan='2' class='oid'>");
+ html("<tr><th>parent</th><td colspan='2' class='oid'>");
parent_hex = label = oid_to_hex(&p->item->object.oid);
if (ctx.repo->enable_subject_links)
label = cgit_parse_commit(parent)->subject;
- cgit_commit_link(label, NULL, NULL, ctx.qry.head, parent_hex,
- prefix);
+ cgit_commit_link(label, NULL, NULL, ctx.qry.head, parent_hex, prefix);
html(" (");
- cgit_diff_link("diff", NULL, NULL, ctx.qry.head, rev,
- oid_to_hex(&p->item->object.oid), prefix);
+ cgit_diff_link("diff", NULL, NULL, ctx.qry.head, rev, oid_to_hex(&p->item->object.oid), prefix);
html(")</td></tr>\n");
parents++;
}
@@ -95,14 +90,12 @@ void cgit_print_commit(char *hex, const char *prefix)
hex = ctx.qry.head;
if (repo_get_oid(the_repository, hex, &oid)) {
- cgit_print_error_page(400, "Bad Request",
- "Bad object id: %s", hex);
+ cgit_print_error_page(400, "Bad Request", "Bad object id: %s", hex);
return;
}
commit = lookup_commit_reference(the_repository, &oid);
if (!commit) {
- cgit_print_error_page(404, "Not Found",
- "Bad commit reference: %s", hex);
+ cgit_print_error_page(404, "Not Found", "Bad commit reference: %s", hex);
return;
}
info = cgit_parse_commit(commit);
@@ -116,15 +109,13 @@ void cgit_print_commit(char *hex, const char *prefix)
cgit_print_diff_ctrls();
html("<table class='commit-info'>\n");
- print_ident_row("author", info->author, info->author_email,
- info->author_date, info->author_tz);
+ print_ident_row("author", info->author, info->author_email, info->author_date, info->author_tz);
print_ident_row("committer", info->committer, info->committer_email,
- info->committer_date, info->committer_tz);
+ info->committer_date, info->committer_tz);
html("<tr><th>commit</th><td colspan='2' class='oid'>");
commit_hex = oid_to_hex(&commit->object.oid);
- cgit_commit_link(commit_hex, NULL, NULL, ctx.qry.head, commit_hex,
- prefix);
+ cgit_commit_link(commit_hex, NULL, NULL, ctx.qry.head, commit_hex, prefix);
html(" (");
cgit_patch_link("patch", NULL, NULL, NULL, commit_hex, prefix);
html(")</td></tr>\n");
@@ -135,12 +126,10 @@ void cgit_print_commit(char *hex, const char *prefix)
html("<tr><th>tree</th><td colspan='2' class='oid'>");
tree_rev = xstrdup(hex);
- cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL,
- ctx.qry.head, tree_rev, NULL);
+ cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL, ctx.qry.head, tree_rev, NULL);
if (prefix) {
html(" /");
- cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tree_rev,
- prefix);
+ cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tree_rev, prefix);
}
free(tree_rev);
html("</td></tr>\n");
@@ -169,8 +158,7 @@ void cgit_print_commit(char *hex, const char *prefix)
if (parents < OCTOPUS_PARENTS) {
if (parents)
- first_parent =
- oid_to_hex(&commit->parents->item->object.oid);
+ first_parent = oid_to_hex(&commit->parents->item->object.oid);
else
first_parent = NULL;
cgit_print_diff(ctx.qry.oid, first_parent, prefix, 0, 0);
diff --git a/source/ui-diff.c b/source/ui-diff.c
index 3c7d8d2..fb86a96 100644
--- a/source/ui-diff.c
+++ b/source/ui-diff.c
@@ -131,26 +131,21 @@ static void print_fileinfo(struct fileinfo *info)
cgit_print_filemode(info->new_mode);
}
- if (info->old_mode != info->new_mode &&
- !is_null_oid(info->old_oid) &&
- !is_null_oid(info->new_oid)) {
+ if (info->old_mode != info->new_mode && !is_null_oid(info->old_oid) && !is_null_oid(info->new_oid)) {
html("<span class='modechange'>[");
cgit_print_filemode(info->old_mode);
html("]</span>");
}
htmlf("</td><td class='%s'>", class);
- cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.oid,
- ctx.qry.oid2, info->new_path);
+ cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, info->new_path);
if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) {
- htmlf(" (%s from ",
- info->status == DIFF_STATUS_COPIED ? "copied" : "renamed");
+ htmlf(" (%s from ", info->status == DIFF_STATUS_COPIED ? "copied" : "renamed");
html_txt(info->old_path);
html(")");
}
html("</td><td class='right'>");
if (info->binary) {
- htmlf("bin</td><td class='graph'>%lu -> %lu bytes</td></tr>\n",
- info->old_size, info->new_size);
+ htmlf("bin</td><td class='graph'>%lu -> %lu bytes</td></tr>\n", info->old_size, info->new_size);
return;
}
htmlf("%d", info->added + info->removed);
@@ -178,8 +173,7 @@ static void count_diff_lines(char *line, int len)
}
if (!render_line_fn || render_suppressed)
return;
- if (cap_diffs && ctx.cfg.max_diff_lines > 0 &&
- lines_added + lines_removed > ctx.cfg.max_diff_lines) {
+ if (cap_diffs && ctx.cfg.max_diff_lines > 0 && lines_added + lines_removed > ctx.cfg.max_diff_lines) {
render_suppressed = 1;
return;
}
@@ -190,8 +184,7 @@ static int show_filepair(struct diff_filepair *pair)
{
if (!current_prefix)
return 1;
- return starts_with(pair->one->path, current_prefix) ||
- starts_with(pair->two->path, current_prefix);
+ return starts_with(pair->one->path, current_prefix) || starts_with(pair->two->path, current_prefix);
}
/*
@@ -224,13 +217,11 @@ static void print_line(char *line, int len)
*/
static char *abbrev_oid(const struct object_id *oid)
{
- return xstrdup(repo_find_unique_abbrev(the_repository, oid,
- DEFAULT_ABBREV));
+ return xstrdup(repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
}
-static void print_file_header(const struct object_id *old_oid, char *old_path,
- int old_mode, const struct object_id *new_oid,
- char *new_path, int new_mode)
+static void print_file_header(const struct object_id *old_oid, char *old_path, int old_mode,
+ const struct object_id *new_oid, char *new_path, int new_mode)
{
char *old_abbrev, *new_abbrev;
int subproject;
@@ -265,8 +256,7 @@ static void print_file_header(const struct object_id *old_oid, char *old_path,
} else
html("<br>--- a/");
if (old_mode != 0)
- cgit_tree_link(old_path, NULL, NULL, ctx.qry.head,
- oid_to_hex(old_rev_oid), old_path);
+ cgit_tree_link(old_path, NULL, NULL, ctx.qry.head, oid_to_hex(old_rev_oid), old_path);
else
html_txt(old_path);
if (is_null_oid(new_oid)) {
@@ -275,8 +265,7 @@ static void print_file_header(const struct object_id *old_oid, char *old_path,
} else
html("<br>+++ b/");
if (new_mode != 0)
- cgit_tree_link(new_path, NULL, NULL, ctx.qry.head,
- oid_to_hex(new_rev_oid), new_path);
+ cgit_tree_link(new_path, NULL, NULL, ctx.qry.head, oid_to_hex(new_rev_oid), new_path);
else
html_txt(new_path);
}
@@ -287,17 +276,14 @@ static void print_file_header(const struct object_id *old_oid, char *old_path,
* The length passed counts the terminator, because a renderer strips the last
* byte of every line it is given.
*/
-static void print_subproject_lines(struct diff_filepair *pair,
- linediff_fn line_fn)
+static void print_subproject_lines(struct diff_filepair *pair, linediff_fn line_fn)
{
if (S_ISGITLINK(pair->one->mode)) {
- char *text = cgit_fmt("-Subproject %s",
- oid_to_hex(&pair->one->oid));
+ char *text = cgit_fmt("-Subproject %s", oid_to_hex(&pair->one->oid));
line_fn(text, strlen(text) + 1);
}
if (S_ISGITLINK(pair->two->mode)) {
- char *text = cgit_fmt("+Subproject %s",
- oid_to_hex(&pair->two->oid));
+ char *text = cgit_fmt("+Subproject %s", oid_to_hex(&pair->two->oid));
line_fn(text, strlen(text) + 1);
}
}
@@ -317,8 +303,7 @@ static void print_truncated(const char *path)
else
html("<div class='truncated'>");
html("This diff is too large to be rendered inline. ");
- cgit_diff_link("View it on its own page", NULL, NULL, ctx.qry.head,
- ctx.qry.oid, ctx.qry.oid2, path);
+ cgit_diff_link("View it on its own page", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, path);
html(".");
if (use_ssdiff) {
html("</td></tr>");
@@ -346,9 +331,8 @@ static struct fileinfo *reserve_item(void)
* Renders one file's body into its own buffer, the way filepair_cb would have
* written it straight out on a second walk.
*/
-static void collect_body(struct diff_filepair *pair, struct fileinfo *item,
- int *binary, unsigned long *old_size,
- unsigned long *new_size)
+static void collect_body(struct diff_filepair *pair, struct fileinfo *item, int *binary,
+ unsigned long *old_size, unsigned long *new_size)
{
struct strbuf *body = &item->body;
linediff_fn line_fn = use_ssdiff ? cgit_ssdiff_line_cb : print_line;
@@ -360,7 +344,7 @@ static void collect_body(struct diff_filepair *pair, struct fileinfo *item,
if (use_ssdiff)
cgit_ssdiff_header_begin();
print_file_header(&pair->one->oid, pair->one->path, pair->one->mode,
- &pair->two->oid, pair->two->path, pair->two->mode);
+ &pair->two->oid, pair->two->path, pair->two->mode);
if (use_ssdiff)
cgit_ssdiff_header_end();
header_len = body->len;
@@ -376,15 +360,13 @@ static void collect_body(struct diff_filepair *pair, struct fileinfo *item,
// than the two lines the body shows, so run that diff for
// the count alone.
render_line_fn = NULL;
- cgit_diff_files(&pair->one->oid, &pair->two->oid, old_size,
- new_size, binary, 0, ctx.qry.ignorews,
- count_diff_lines);
+ cgit_diff_files(&pair->one->oid, &pair->two->oid, old_size, new_size,
+ binary, 0, ctx.qry.ignorews, count_diff_lines);
print_subproject_lines(pair, line_fn);
} else {
render_line_fn = line_fn;
- if (cgit_diff_files(&pair->one->oid, &pair->two->oid, old_size,
- new_size, binary, ctx.qry.context,
- ctx.qry.ignorews, count_diff_lines))
+ if (cgit_diff_files(&pair->one->oid, &pair->two->oid, old_size, new_size,
+ binary, ctx.qry.context, ctx.qry.ignorews, count_diff_lines))
cgit_print_error("Error running diff");
render_line_fn = NULL;
if (*binary)
@@ -429,9 +411,8 @@ static void inspect_filepair(struct diff_filepair *pair)
if (bodies_usable)
collect_body(pair, item, &binary, &old_size, &new_size);
else
- cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size,
- &new_size, &binary, 0, ctx.qry.ignorews,
- count_diff_lines);
+ cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size, &new_size,
+ &binary, 0, ctx.qry.ignorews, count_diff_lines);
item->status = pair->status;
oidcpy(item->old_oid, &pair->one->oid);
@@ -451,14 +432,13 @@ static void inspect_filepair(struct diff_filepair *pair)
total_rems += lines_removed;
}
-static void print_diffstat(const struct object_id *old_oid,
- const struct object_id *new_oid, const char *prefix)
+static void print_diffstat(const struct object_id *old_oid, const struct object_id *new_oid,
+ const char *prefix)
{
int i;
html("<div class='diffstat-header'>");
- cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.oid,
- ctx.qry.oid2, NULL);
+ cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, NULL);
if (prefix) {
html(" (limited to '");
html_txt(prefix);
@@ -467,8 +447,7 @@ static void print_diffstat(const struct object_id *old_oid,
html("</div>\n");
html("<table class='diffstat'>\n");
max_changes = 0;
- cgit_diff_tree(old_oid, new_oid, inspect_filepair, prefix,
- ctx.qry.ignorews);
+ cgit_diff_tree(old_oid, new_oid, inspect_filepair, prefix, ctx.qry.ignorews);
for (i = 0; i < files; i++)
print_fileinfo(&items[i]);
html("</table>\n");
@@ -483,9 +462,8 @@ static void print_diffstat(const struct object_id *old_oid,
static int over_line_cap(int idx)
{
return cap_diffs && ctx.cfg.max_diff_lines > 0 &&
- idx < files && !items[idx].binary &&
- items[idx].added + items[idx].removed >
- (unsigned int)ctx.cfg.max_diff_lines;
+ idx < files && !items[idx].binary &&
+ items[idx].added + items[idx].removed > (unsigned int)ctx.cfg.max_diff_lines;
}
static void filepair_cb(struct diff_filepair *pair)
@@ -506,7 +484,7 @@ static void filepair_cb(struct diff_filepair *pair)
line_fn = cgit_ssdiff_line_cb;
}
print_file_header(&pair->one->oid, pair->one->path, pair->one->mode,
- &pair->two->oid, pair->two->path, pair->two->mode);
+ &pair->two->oid, pair->two->path, pair->two->mode);
if (use_ssdiff)
cgit_ssdiff_header_end();
@@ -520,9 +498,8 @@ static void filepair_cb(struct diff_filepair *pair)
cgit_ssdiff_footer();
return;
}
- if (cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size,
- &new_size, &binary, ctx.qry.context,
- ctx.qry.ignorews, line_fn))
+ if (cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size, &new_size,
+ &binary, ctx.qry.context, ctx.qry.ignorews, line_fn))
cgit_print_error("Error running diff");
if (binary)
print_binary_differs();
@@ -530,8 +507,7 @@ static void filepair_cb(struct diff_filepair *pair)
cgit_ssdiff_footer();
}
-static void print_raw_patch(const struct object_id *old_tree_oid,
- const struct object_id *new_tree_oid)
+static void print_raw_patch(const struct object_id *old_tree_oid, const struct object_id *new_tree_oid)
{
struct diff_options diffopt;
@@ -607,8 +583,8 @@ void cgit_print_diff_ctrls(void)
html("</div>\n");
}
-void cgit_print_diff(const char *new_rev, const char *old_rev,
- const char *prefix, int show_ctrls, int raw)
+void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix,
+ int show_ctrls, int raw)
{
struct commit *new_commit, *old_commit;
const struct object_id *old_tree_oid, *new_tree_oid;
@@ -631,22 +607,19 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
if (!new_rev)
new_rev = ctx.qry.head;
if (repo_get_oid(the_repository, new_rev, new_rev_oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad object name: %s", new_rev);
+ cgit_print_error_page(404, "Not Found", "Bad object name: %s", new_rev);
return;
}
new_commit = lookup_commit_reference(the_repository, new_rev_oid);
if (!new_commit || repo_parse_commit(the_repository, new_commit)) {
- cgit_print_error_page(404, "Not Found",
- "Bad commit: %s", oid_to_hex(new_rev_oid));
+ cgit_print_error_page(404, "Not Found", "Bad commit: %s", oid_to_hex(new_rev_oid));
return;
}
new_tree_oid = get_commit_tree_oid(new_commit);
if (old_rev) {
if (repo_get_oid(the_repository, old_rev, old_rev_oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad object name: %s", old_rev);
+ cgit_print_error_page(404, "Not Found", "Bad object name: %s", old_rev);
return;
}
} else if (new_commit->parents && new_commit->parents->item) {
@@ -656,12 +629,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
}
if (!is_null_oid(old_rev_oid)) {
- old_commit = lookup_commit_reference(the_repository,
- old_rev_oid);
- if (!old_commit ||
- repo_parse_commit(the_repository, old_commit)) {
- cgit_print_error_page(404, "Not Found",
- "Bad commit: %s", oid_to_hex(old_rev_oid));
+ old_commit = lookup_commit_reference(the_repository, old_rev_oid);
+ if (!old_commit || repo_parse_commit(the_repository, old_commit)) {
+ cgit_print_error_page(404, "Not Found", "Bad commit: %s", oid_to_hex(old_rev_oid));
return;
}
old_tree_oid = get_commit_tree_oid(old_commit);
@@ -680,8 +650,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
// it came from, which for a side by side diff is several times the blob
// itself, and the budget cannot help there because it is only reached
// once a body is complete.
- bodies_usable = difftype != DIFF_STATONLY && cap_diffs &&
- ctx.cfg.max_diff_lines > 0;
+ bodies_usable = difftype != DIFF_STATONLY && cap_diffs && ctx.cfg.max_diff_lines > 0;
if (show_ctrls) {
cgit_print_layout_start();
@@ -702,11 +671,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
return;
}
- if (cap_diffs && ctx.cfg.max_diff_files > 0 &&
- files > ctx.cfg.max_diff_files) {
+ if (cap_diffs && ctx.cfg.max_diff_files > 0 && files > ctx.cfg.max_diff_files) {
html("<div class='truncated'>");
- html("This diff is too large to be rendered inline. "
- "Follow a file above, or the ");
+ html("This diff is too large to be rendered inline. Follow a file above, or the ");
cgit_patch_link("patch", NULL, NULL, NULL, ctx.qry.oid, NULL);
html(" link for the whole commit.");
html("</div>");
@@ -730,8 +697,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
release_bodies();
} else {
item_idx = 0;
- cgit_diff_tree(old_rev_oid, new_rev_oid, filepair_cb, prefix,
- ctx.qry.ignorews);
+ cgit_diff_tree(old_rev_oid, new_rev_oid, filepair_cb, prefix, ctx.qry.ignorews);
}
if (!use_ssdiff)
html("</td></tr>\n");
diff --git a/source/ui-diff.h b/source/ui-diff.h
index 67d33ba..467c79f 100644
--- a/source/ui-diff.h
+++ b/source/ui-diff.h
@@ -17,8 +17,8 @@
extern void cgit_print_diff_ctrls(void);
-extern void cgit_print_diff(const char *new_hex, const char *old_hex,
- const char *prefix, int show_ctrls, int raw);
+extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix,
+ int show_ctrls, int raw);
extern struct diff_filespec *cgit_get_current_old_file(void);
extern struct diff_filespec *cgit_get_current_new_file(void);
diff --git a/source/ui-log.c b/source/ui-log.c
index 5b5dd32..8fe58f9 100644
--- a/source/ui-log.c
+++ b/source/ui-log.c
@@ -64,9 +64,8 @@ static void count_file(struct diff_filepair *pair)
file_count++;
if (ctx.repo->enable_log_linecount)
- cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size,
- &new_size, &binary, 0, ctx.qry.ignorews,
- count_line);
+ cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size, &new_size,
+ &binary, 0, ctx.qry.ignorews, count_line);
}
/*
@@ -122,9 +121,7 @@ static int should_show(struct commit *commit, struct rev_info *revs)
removed_lines = 0;
revs->diffopt.flags.recursive = 1;
- diff_tree_oid(get_commit_tree_oid(parent),
- get_commit_tree_oid(commit),
- "", &revs->diffopt);
+ diff_tree_oid(get_commit_tree_oid(parent), get_commit_tree_oid(commit), "", &revs->diffopt);
diffcore_std(&revs->diffopt);
found = !diff_queue_is_empty(&revs->diffopt);
@@ -146,8 +143,7 @@ static int should_show(struct commit *commit, struct rev_info *revs)
* commit itself stays in graph for the caller to place in the commit's own
* row.
*/
-static void print_graph_above(struct rev_info *revs, struct strbuf *graph,
- int columns)
+static void print_graph_above(struct rev_info *revs, struct strbuf *graph, int columns)
{
while (!graph_next_line(revs->graph, graph)) {
html("<tr class='nohover'><td class='commitgraph'>");
@@ -171,8 +167,7 @@ static void wrap_subject(struct commitinfo *info, struct strbuf *msg)
size_t subject_len = strlen(info->subject);
int cut;
- if (ctx.cfg.max_msg_len < MIN_WRAP_LEN ||
- subject_len <= (size_t)ctx.cfg.max_msg_len)
+ if (ctx.cfg.max_msg_len < MIN_WRAP_LEN || subject_len <= (size_t)ctx.cfg.max_msg_len)
return;
cut = ctx.cfg.max_msg_len - strlen(wrap_symbol);
@@ -199,8 +194,7 @@ static int line_count(const char *text)
return lines;
}
-static void print_graph_padding(struct rev_info *revs, struct strbuf *graph,
- int lines)
+static void print_graph_padding(struct rev_info *revs, struct strbuf *graph, int lines)
{
html("<td class='commitgraph'>");
while (lines > 0 || !graph_is_commit_finished(revs->graph)) {
@@ -237,11 +231,9 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
html(graphbuf.buf);
html("</td>");
strbuf_setlen(&graphbuf, 0);
- }
- else {
+ } else {
html("<td>");
- cgit_print_age(info->committer_date, info->committer_tz,
- MAX_RELATIVE_AGE);
+ cgit_print_age(info->committer_date, info->committer_tz, MAX_RELATIVE_AGE);
html("</td>");
}
@@ -249,7 +241,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
if (ctx.qry.showmsg)
wrap_subject(info, &msgbuf);
cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
- oid_to_hex(&commit->object.oid), ctx.qry.vpath);
+ oid_to_hex(&commit->object.oid), ctx.qry.vpath);
cgit_print_commit_decorations(commit);
html("</td><td class='col-author'>");
cgit_open_filter(ctx.repo->email_filter, info->author_email, "log");
@@ -258,12 +250,10 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
if (revs->graph) {
html("</td><td>");
- cgit_print_age(info->committer_date, info->committer_tz,
- MAX_RELATIVE_AGE);
+ cgit_print_age(info->committer_date, info->committer_tz, MAX_RELATIVE_AGE);
}
- if (!counts_ready && (ctx.repo->enable_log_filecount ||
- ctx.repo->enable_log_linecount)) {
+ if (!counts_ready && (ctx.repo->enable_log_filecount || ctx.repo->enable_log_linecount)) {
file_count = 0;
added_lines = 0;
removed_lines = 0;
@@ -274,13 +264,11 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
htmlf("</td><td class='col-count'>%d", file_count);
if (ctx.repo->enable_log_linecount)
htmlf("</td><td class='col-count'><span class='deletions'>-%d</span>/"
- "<span class='insertions'>+%d</span>",
- removed_lines, added_lines);
+ "<span class='insertions'>+%d</span>", removed_lines, added_lines);
html("</td></tr>\n");
- if ((revs->graph && !graph_is_commit_finished(revs->graph))
- || ctx.qry.showmsg) {
+ if ((revs->graph && !graph_is_commit_finished(revs->graph)) || ctx.qry.showmsg) {
html("<tr class='nohover-highlight'>");
if (ctx.qry.showmsg) {
@@ -288,26 +276,22 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
strbuf_addstr(&msgbuf, info->msg);
strbuf_addch(&msgbuf, '\n');
}
- format_display_notes(&commit->object.oid,
- &msgbuf, PAGE_ENCODING, 0);
+ format_display_notes(&commit->object.oid, &msgbuf, PAGE_ENCODING, 0);
strbuf_addch(&msgbuf, '\n');
strbuf_ltrim(&msgbuf);
}
// With no graph the empty cell stands in for the age column.
if (revs->graph) {
- int msg_lines = ctx.qry.showmsg ?
- line_count(msgbuf.buf) : 0;
+ int msg_lines = ctx.qry.showmsg ? line_count(msgbuf.buf) : 0;
print_graph_padding(revs, &graphbuf, msg_lines);
- }
- else
+ } else
html("<td></td>");
// Either way one cell is already on the row, so the message
// spans the remaining columns.
- htmlf("<td colspan='%d'%s>\n", columns - 1,
- ctx.qry.showmsg ? " class='logmsg'" : "");
+ htmlf("<td colspan='%d'%s>\n", columns - 1, ctx.qry.showmsg ? " class='logmsg'" : "");
html_txt(msgbuf.buf);
html("</td></tr>\n");
}
@@ -370,20 +354,18 @@ static void print_pager(struct rev_info *revs, int ofs, int cnt)
html("<ul class='pager'>");
if (ofs > 0) {
html("<li>");
- cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
- ctx.qry.oid, ctx.qry.vpath,
- ofs - cnt, ctx.qry.grep,
- ctx.qry.search, ctx.qry.showmsg,
- ctx.qry.follow);
+ cgit_log_link(
+ "[prev]", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.vpath,
+ ofs - cnt, ctx.qry.grep, ctx.qry.search, ctx.qry.showmsg, ctx.qry.follow
+ );
html("</li>");
}
if (more) {
html("<li>");
- cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
- ctx.qry.oid, ctx.qry.vpath,
- ofs + cnt, ctx.qry.grep,
- ctx.qry.search, ctx.qry.showmsg,
- ctx.qry.follow);
+ cgit_log_link(
+ "[next]", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.vpath,
+ ofs + cnt, ctx.qry.grep, ctx.qry.search, ctx.qry.showmsg, ctx.qry.follow
+ );
html("</li>");
}
html("</ul>");
@@ -411,31 +393,25 @@ void cgit_print_commit_decorations(struct commit *commit)
case DECORATION_NONE:
break;
case DECORATION_REF_LOCAL:
- cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
- ctx.qry.vpath, 0, NULL, NULL,
- ctx.qry.showmsg, 0);
+ cgit_log_link(buf, NULL, "branch-deco", buf, NULL, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, 0);
break;
case DECORATION_REF_TAG:
- if (!refs_read_ref(get_main_ref_store(the_repository),
- deco->name, &oid_tag) &&
- !peel_object(the_repository, &oid_tag, &peeled,
- PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE))
+ if (!refs_read_ref(get_main_ref_store(the_repository), deco->name, &oid_tag) &&
+ !peel_object(the_repository, &oid_tag, &peeled,
+ PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE))
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;
case DECORATION_REF_REMOTE:
if (!ctx.repo->enable_remote_branches)
break;
- cgit_log_link(buf, NULL, "remote-deco", NULL,
- oid_to_hex(&commit->object.oid),
- ctx.qry.vpath, 0, NULL, NULL,
- ctx.qry.showmsg, 0);
+ cgit_log_link(
+ buf, NULL, "remote-deco", NULL, oid_to_hex(&commit->object.oid),
+ ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, 0
+ );
break;
default:
- cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
- oid_to_hex(&commit->object.oid),
- ctx.qry.vpath);
+ cgit_commit_link(buf, NULL, "deco", ctx.qry.head, oid_to_hex(&commit->object.oid), ctx.qry.vpath);
break;
}
deco = deco->next;
@@ -443,9 +419,8 @@ void cgit_print_commit_decorations(struct commit *commit)
html("</span>");
}
-void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
- char *pattern, const char *path, int pager,
- int commit_graph, int commit_sort)
+void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
+ const char *path, int pager, int commit_graph, int commit_sort)
{
struct rev_info rev;
struct commit *commit;
@@ -475,8 +450,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
if (grep && pattern && *pattern) {
pattern = xstrdup(pattern);
- if (!strcmp(grep, "grep") || !strcmp(grep, "author") ||
- !strcmp(grep, "committer")) {
+ if (!strcmp(grep, "grep") || !strcmp(grep, "author") || !strcmp(grep, "committer")) {
strvec_pushf(&rev_argv, "--%s=%s", grep, pattern);
} else if (!strcmp(grep, "range")) {
char *arg;
@@ -489,8 +463,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
strvec_pop(&rev_argv);
while ((arg = next_token(&pattern))) {
if (*arg == '-') {
- fprintf(stderr, "[cgit] Bad range expression: %s\n",
- arg);
+ fprintf(stderr, "[cgit] Bad range expression: %s\n", arg);
break;
}
strvec_push(&rev_argv, arg);
@@ -504,8 +477,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
if (commit_graph && !ctx.qry.follow) {
strvec_push(&rev_argv, "--graph");
strvec_push(&rev_argv, "--color");
- graph_set_column_colors(column_colors_html,
- COLUMN_COLORS_HTML_MAX);
+ graph_set_column_colors(column_colors_html, COLUMN_COLORS_HTML_MAX);
}
if (commit_sort == 1)
@@ -552,11 +524,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
html("<th class='left'>Commit message");
if (pager) {
html(" (");
- cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,
- NULL, ctx.qry.head, ctx.qry.oid,
- ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep,
- ctx.qry.search, ctx.qry.showmsg ? 0 : 1,
- ctx.qry.follow);
+ cgit_log_link(
+ ctx.qry.showmsg ? "Collapse" : "Expand", NULL, NULL, ctx.qry.head,
+ ctx.qry.oid, ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, ctx.qry.search,
+ ctx.qry.showmsg ? 0 : 1, ctx.qry.follow
+ );
html(")");
}
html("</th><th class='left col-author'>Author</th>");
@@ -598,9 +570,10 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
cgit_print_layout_end();
} else if ((commit = get_revision(&rev)) != NULL) {
htmlf("<tr class='nohover'><td colspan='%d'>", columns);
- cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL,
- ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg,
- ctx.qry.follow);
+ cgit_log_link(
+ "[...]", NULL, NULL, ctx.qry.head, NULL, ctx.qry.vpath, 0,
+ NULL, NULL, ctx.qry.showmsg, ctx.qry.follow
+ );
html("</td></tr>\n");
}
diff --git a/source/ui-log.h b/source/ui-log.h
index ecfe85d..8e6e3db 100644
--- a/source/ui-log.h
+++ b/source/ui-log.h
@@ -8,9 +8,8 @@
#ifndef CGIT_UI_LOG_H
#define CGIT_UI_LOG_H
-extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
- char *pattern, const char *path, int pager,
- int commit_graph, int commit_sort);
+extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
+ const char *path, int pager, int commit_graph, int commit_sort);
extern void cgit_print_commit_decorations(struct commit *commit);
#endif // CGIT_UI_LOG_H
diff --git a/source/ui-patch.c b/source/ui-patch.c
index bc98f2e..baa87c9 100644
--- a/source/ui-patch.c
+++ b/source/ui-patch.c
@@ -25,31 +25,27 @@
* for that one commit instead.
*/
static int resolve_range(const char *new_rev, const char *old_rev,
- struct object_id *new_oid, struct object_id *old_oid)
+ struct object_id *new_oid, struct object_id *old_oid)
{
struct commit *commit;
if (repo_get_oid(the_repository, new_rev, new_oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad object id: %s", new_rev);
+ cgit_print_error_page(404, "Not Found", "Bad object id: %s", new_rev);
return -1;
}
commit = lookup_commit_reference(the_repository, new_oid);
if (!commit) {
- cgit_print_error_page(404, "Not Found",
- "Bad commit reference: %s", new_rev);
+ cgit_print_error_page(404, "Not Found", "Bad commit reference: %s", new_rev);
return -1;
}
if (old_rev) {
if (repo_get_oid(the_repository, old_rev, old_oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad object id: %s", old_rev);
+ cgit_print_error_page(404, "Not Found", "Bad object id: %s", old_rev);
return -1;
}
if (!lookup_commit_reference(the_repository, old_oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad commit reference: %s", old_rev);
+ cgit_print_error_page(404, "Not Found", "Bad commit reference: %s", old_rev);
return -1;
}
} else if (commit->parents && commit->parents->item) {
@@ -60,8 +56,7 @@ static int resolve_range(const char *new_rev, const char *old_rev,
return 0;
}
-void cgit_print_patch(const char *new_rev, const char *old_rev,
- const char *prefix)
+void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix)
{
struct rev_info rev;
struct commit *commit;
@@ -71,8 +66,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
// first entry stands in for the program name and is skipped, and the
// array has to stay null terminated because the path after the double
// dash is picked up past the count.
- const char *rev_argv[] = { NULL, "--reverse", "--format=email",
- rev_range, "--", prefix, NULL };
+ const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL };
int rev_argc = ARRAY_SIZE(rev_argv) - 1;
if (!prefix)
@@ -87,8 +81,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
if (is_null_oid(&old_oid)) {
memcpy(rev_range, oid_to_hex(&new_oid), the_hash_algo->hexsz + 1);
} else {
- xsnprintf(rev_range, REV_RANGE_LEN, "%s..%s",
- oid_to_hex(&old_oid), oid_to_hex(&new_oid));
+ xsnprintf(rev_range, REV_RANGE_LEN, "%s..%s", oid_to_hex(&old_oid), oid_to_hex(&new_oid));
}
ctx.page.mimetype = "text/plain";
@@ -97,9 +90,8 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
if (!ctx.cfg.enable_plain_email) {
rev_argv[FORMAT_ARG] =
- "--format=format:From %H Mon Sep 17 00:00:00 "
- "2001%nFrom: %an%nDate: %aD%n%w(78,0,1)Subject: "
- "%s%n%n%w(0)%b";
+ "--format=format:From %H Mon Sep 17 00:00:00 2001%n"
+ "From: %an%nDate: %aD%n%w(78,0,1)Subject: %s%n%n%w(0)%b";
}
repo_init_revisions(the_repository, &rev, NULL);
@@ -108,15 +100,13 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
rev.diff = 1;
rev.show_root_diff = 1;
rev.max_parents = 1;
- rev.diffopt.output_format |= DIFF_FORMAT_DIFFSTAT |
- DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY;
+ rev.diffopt.output_format |= DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY;
if (prefix)
// Allocated rather than formatted into cgit_fmt's fixed
// buffer, because the path comes from the request and a long
// one would abort the process here, with the headers for a
// successful response already on the wire.
- rev.diffopt.stat_sep = cgit_fmtalloc("(limited to '%s')\n\n",
- prefix);
+ rev.diffopt.stat_sep = cgit_fmtalloc("(limited to '%s')\n\n", prefix);
setup_revisions(rev_argc, rev_argv, &rev, NULL);
// A single commit resolves to a range starting at its parent, so this
// only ever cuts an explicit range short and keeps one request from
diff --git a/source/ui-patch.h b/source/ui-patch.h
index 4dfe8bc..4575d1b 100644
--- a/source/ui-patch.h
+++ b/source/ui-patch.h
@@ -8,7 +8,6 @@
#ifndef CGIT_UI_PATCH_H
#define CGIT_UI_PATCH_H
-extern void cgit_print_patch(const char *new_rev, const char *old_rev,
- const char *prefix);
+extern void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix);
#endif // CGIT_UI_PATCH_H
diff --git a/source/ui-plain.c b/source/ui-plain.c
index d3b4771..6b45637 100644
--- a/source/ui-plain.c
+++ b/source/ui-plain.c
@@ -62,10 +62,8 @@ static void print_object(const struct object_id *oid, const char *path)
// The limit counts kilobytes and is checked before the read, so a huge
// blob is kept out of memory rather than noticed once it is there.
- if (ctx.cfg.max_blob_size &&
- size / 1024 > (unsigned long)ctx.cfg.max_blob_size) {
- cgit_print_error_page(413, "Content Too Large",
- "Object size (%luKB) exceeds limit (%dKB)",
+ if (ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size) {
+ cgit_print_error_page(413, "Content Too Large", "Object size (%luKB) exceeds limit (%dKB)",
size / 1024, ctx.cfg.max_blob_size);
return;
}
@@ -142,15 +140,14 @@ static void print_dir(const char *base, int baselen, const char *path)
fullpath = NULL;
}
html("<li>");
- cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.oid,
- fullpath);
+ cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.oid, fullpath);
html("</li>\n");
}
free(fullpath);
}
static void print_dir_entry(const struct object_id *oid, const char *base,
- int baselen, const char *path, unsigned mode)
+ int baselen, const char *path, unsigned mode)
{
char *fullpath;
@@ -161,8 +158,7 @@ static void print_dir_entry(const struct object_id *oid, const char *base,
if (S_ISGITLINK(mode))
cgit_submodule_link(NULL, fullpath, oid_to_hex(oid));
else
- cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.oid,
- fullpath);
+ cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.oid, fullpath);
html("</li>\n");
free(fullpath);
}
@@ -177,7 +173,7 @@ static void print_dir_tail(void)
* READ_TREE_RECURSIVE means step into this entry and zero means step over it.
*/
static int walk_tree(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *context)
+ const char *pathname, unsigned mode, void *context)
{
struct walk_tree_context *walk = context;
@@ -252,8 +248,7 @@ void cgit_print_plain(void)
} else {
walk.dir_len = dir_prefix_len(path_items.match);
}
- read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
- &paths, walk_tree, &walk);
+ read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
if (walk.response == RESPONSE_NONE)
cgit_print_error_page(404, "Not Found", "Not found");
else if (walk.response == RESPONSE_LISTING)
diff --git a/source/ui-refs.c b/source/ui-refs.c
index 1b32088..42a3cfb 100644
--- a/source/ui-refs.c
+++ b/source/ui-refs.c
@@ -73,11 +73,9 @@ static void collect_branches(struct reflist *list)
{
list->refs = NULL;
list->alloc = list->count = 0;
- refs_for_each_branch_ref(get_main_ref_store(the_repository),
- cgit_refs_cb, list);
+ refs_for_each_branch_ref(get_main_ref_store(the_repository), cgit_refs_cb, list);
if (ctx.repo->enable_remote_branches)
- refs_for_each_remote_ref(get_main_ref_store(the_repository),
- cgit_refs_cb, list);
+ refs_for_each_remote_ref(get_main_ref_store(the_repository), cgit_refs_cb, list);
}
static void print_branch_header(void)
@@ -96,8 +94,7 @@ static int print_branch(struct refinfo *ref)
if (!info)
return 1;
html("<tr><td>");
- cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL,
- ctx.qry.showmsg, 0);
+ cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL, ctx.qry.showmsg, 0);
html("</td><td>");
if (ref->object->type == OBJ_COMMIT) {
@@ -122,8 +119,7 @@ static void collect_tags(struct reflist *list)
{
list->refs = NULL;
list->alloc = list->count = 0;
- refs_for_each_tag_ref(get_main_ref_store(the_repository),
- cgit_refs_cb, list);
+ refs_for_each_tag_ref(get_main_ref_store(the_repository), cgit_refs_cb, list);
}
static void print_tag_header(void)
@@ -197,18 +193,15 @@ static void print_ref_pager(int ofs, int pagesize, int count, const char *path)
if (ofs > 0) {
int prev_ofs = ofs > pagesize ? ofs - pagesize : 0;
- url = cgit_pageurl(ctx.qry.repo, cgit_fmt("refs/%s", path),
- cgit_fmt("ofs=%d", prev_ofs));
+ url = cgit_pageurl(ctx.qry.repo, cgit_fmt("refs/%s", path), cgit_fmt("ofs=%d", prev_ofs));
html("<a href='");
html_attr(url);
html("'>[prev]</a> ");
free(url);
}
- htmlf("%d - %d of %d", ofs + 1,
- ofs + pagesize < count ? ofs + pagesize : count, count);
+ htmlf("%d - %d of %d", ofs + 1, ofs + pagesize < count ? ofs + pagesize : count, count);
if (ofs + pagesize < count) {
- url = cgit_pageurl(ctx.qry.repo, cgit_fmt("refs/%s", path),
- cgit_fmt("ofs=%d", ofs + pagesize));
+ url = cgit_pageurl(ctx.qry.repo, cgit_fmt("refs/%s", path), cgit_fmt("ofs=%d", ofs + pagesize));
html(" <a href='");
html_attr(url);
html("'>[next]</a>");
@@ -225,8 +218,7 @@ static struct ref_page page_bounds(int pagesize, int count)
page.start = ctx.qry.ofs > 0 ? ctx.qry.ofs : 0;
if (page.start > count)
page.start = count;
- page.end = page.start + page.size < count ?
- page.start + page.size : count;
+ page.end = page.start + page.size < count ? page.start + page.size : count;
return page;
}
diff --git a/source/ui-repolist.c b/source/ui-repolist.c
index 9f60228..cd22afd 100644
--- a/source/ui-repolist.c
+++ b/source/ui-repolist.c
@@ -177,8 +177,7 @@ static int any_repos_visible(void)
// currenturl is passed in because it is the same for every heading and every
// row, and working it out here would mean an allocation and a free per cell.
-static void print_column_header(const char *title, const char *column,
- const char *currenturl)
+static void print_column_header(const char *title, const char *column, const char *currenturl)
{
htmlf("<th class='left col-%s'><a href='", column);
html_attr(currenturl);
@@ -214,8 +213,7 @@ static int section_changed(const char *section, const char *last)
static void print_section_row(const char *section, int columns)
{
- htmlf("<tr class='nohover-highlight'><td colspan='%d' class='reposection'>",
- columns);
+ htmlf("<tr class='nohover-highlight'><td colspan='%d' class='reposection'>", columns);
html_txt(section);
html("</td></tr>\n");
}
@@ -224,8 +222,7 @@ static void print_repo_row(const char *currenturl, int sublevel)
{
char *repourl;
- htmlf("<tr><td class='col-name %s'>",
- sublevel ? "sublevel-repo" : "toplevel-repo");
+ htmlf("<tr><td class='col-name %s'>", sublevel ? "sublevel-repo" : "toplevel-repo");
cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
html("</td><td class='col-desc'>");
repourl = cgit_repourl(ctx.repo->url);
@@ -256,8 +253,7 @@ static void print_repo_row(const char *currenturl, int sublevel)
if (ctx.cfg.enable_index_links) {
html("<td class='col-links'>");
cgit_summary_link("summary", NULL, "button", NULL);
- cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
- 0, NULL, NULL, ctx.qry.showmsg, 0);
+ cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 0, NULL, NULL, ctx.qry.showmsg, 0);
cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
html("</td>");
}
@@ -273,8 +269,7 @@ static void print_pager(int total, int pagelen, char *search, char *sort)
for (i = 0, ofs = 0; ofs < total; i++, ofs = i * pagelen) {
class = (ctx.qry.ofs == ofs) ? "current" : NULL;
html("<li>");
- cgit_index_link(cgit_fmt("[%d]", i + 1), cgit_fmt("Page %d", i + 1),
- class, search, sort, ofs, 0);
+ cgit_index_link(cgit_fmt("[%d]", i + 1), cgit_fmt("Page %d", i + 1), class, search, sort, ofs, 0);
html("</li>");
}
html("</ul>\n");
@@ -385,8 +380,7 @@ static int sort_repolist(char *field)
continue;
if (column->cmp == cmp_idle || column->cmp == cmp_section)
resolve_modtimes();
- qsort(cgit_repolist.repos, cgit_repolist.count,
- sizeof(struct cgit_repo), column->cmp);
+ qsort(cgit_repolist.repos, cgit_repolist.count, sizeof(struct cgit_repo), column->cmp);
return 1;
}
return 0;
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 2ec9d0e..58e7f03 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -73,8 +73,7 @@ static const char *root_url(void)
return ctx.cfg.script_name;
}
-static void site_url(const char *page, const char *search, const char *sort,
- int ofs, int always_root)
+static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)
{
const char *delim = "?";
@@ -109,8 +108,7 @@ static void site_url(const char *page, const char *search, const char *sort,
}
static void site_link(const char *page, const char *name, const char *title,
- const char *class, const char *search, const char *sort,
- int ofs, int always_root)
+ const char *class, const char *search, const char *sort, int ofs, int always_root)
{
html("<a");
if (title) {
@@ -136,9 +134,8 @@ static void site_link(const char *page, const char *name, const char *title,
* arguments and close. The return is the delimiter to put before the first of
* those, which is still a question mark unless a query string has been opened.
*/
-static const char *repolink(const char *title, const char *class,
- const char *page, const char *head,
- const char *path)
+static const char *repolink(const char *title, const char *class, const char *page,
+ const char *head, const char *path)
{
const char *delim = "?";
@@ -200,8 +197,7 @@ static const char *emit_rev_arg(const char *delim, const char *rev)
}
static void reporevlink(const char *page, const char *name, const char *title,
- const char *class, const char *head, const char *rev,
- const char *path)
+ const char *class, const char *head, const char *rev, const char *path)
{
const char *delim;
@@ -236,8 +232,7 @@ static void emit_diff_args(const char *delim)
}
}
-static struct string_list_item *lookup_path(struct string_list *list,
- const char *path)
+static struct string_list_item *lookup_path(struct string_list *list, const char *path)
{
struct string_list_item *item;
@@ -307,8 +302,7 @@ static void print_abs_date(time_t t, int tz)
html("</time>");
}
-static void print_rel_date(time_t t, int tz, double count, const char *class,
- const char *suffix)
+static void print_rel_date(time_t t, int tz, double count, const char *class, const char *suffix)
{
htmlf("<time class='%s' datetime='", class);
html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601_STRICT)));
@@ -407,7 +401,7 @@ static const struct object_id *pinned_oid(void)
if (!ctx.repo || !ctx.qry.has_oid || !ctx.qry.oid || !ctx.qry.head)
return NULL;
if (repo_get_oid(the_repository, ctx.qry.oid, &oid) ||
- repo_get_oid(the_repository, ctx.qry.head, &head_oid))
+ repo_get_oid(the_repository, ctx.qry.head, &head_oid))
return NULL;
// A full hex id resolves without being looked up, so only peeling to a
// commit proves the pin names history, and a tag pinned to the tip
@@ -533,16 +527,13 @@ static void print_header(void)
if (pinned) {
const char *hex = oid_to_hex(pinned);
- html_option(hex, cgit_fmt("%.*s (detached)",
- SHORT_HASH_LEN, hex), hex);
+ html_option(hex, cgit_fmt("%.*s (detached)", SHORT_HASH_LEN, hex), hex);
} else if (!head_is_listed_branch()) {
print_detached_head_option();
}
- refs_for_each_branch_ref(get_main_ref_store(the_repository),
- print_branch_option, &opt);
+ refs_for_each_branch_ref(get_main_ref_store(the_repository), print_branch_option, &opt);
if (ctx.repo->enable_remote_branches)
- refs_for_each_remote_ref(get_main_ref_store(the_repository),
- print_branch_option, &opt);
+ refs_for_each_remote_ref(get_main_ref_store(the_repository), print_branch_option, &opt);
html("</select> ");
html("<input type='submit' value='switch'>");
html("</form>\n");
@@ -572,8 +563,7 @@ static const char *tab_class(const char *page)
return strcmp(ctx.qry.page, page) ? NULL : "active";
}
-static const char *tab_title(const char *format, const char *fallback,
- const char *path)
+static const char *tab_title(const char *format, const char *fallback, const char *path)
{
if (!path || !*path || strlen(path) > MAX_TITLE_PATH_LEN)
return fallback;
@@ -587,47 +577,44 @@ static void print_repo_tabs(void)
html("<ul>\n");
if (ctx.repo->readme.nr) {
html("<li>");
- reporevlink("about", "about", "About this repository",
- tab_class("about"), ctx.qry.head, NULL, NULL);
+ reporevlink("about", "about", "About this repository", tab_class("about"), ctx.qry.head, NULL, NULL);
html("</li>\n");
}
html("<li>");
- cgit_summary_link("summary", "Repository summary", tab_class("summary"),
- ctx.qry.head);
+ cgit_summary_link("summary", "Repository summary", tab_class("summary"), ctx.qry.head);
html("</li>\n<li>");
- cgit_refs_link("refs", "Branches and tags", tab_class("refs"),
- ctx.qry.head, ctx.qry.oid, NULL);
+ cgit_refs_link("refs", "Branches and tags", tab_class("refs"), ctx.qry.head, ctx.qry.oid, NULL);
html("</li>\n<li>");
- cgit_log_link("log",
- tab_title("Commit history of %s", "Commit history", vpath),
- tab_class("log"), ctx.qry.head,
- NULL, ctx.qry.vpath, 0, NULL, NULL,
- ctx.qry.showmsg, ctx.qry.follow);
+ cgit_log_link(
+ "log", tab_title("Commit history of %s", "Commit history", vpath),
+ tab_class("log"), ctx.qry.head, NULL, ctx.qry.vpath, 0, NULL, NULL,
+ ctx.qry.showmsg, ctx.qry.follow
+ );
html("</li>\n<li>");
if (ctx.qry.page && !strcmp(ctx.qry.page, "blame"))
- cgit_blame_link("blame",
- tab_title("Line-by-line blame of %s", "Blame", vpath),
- tab_class("blame"), ctx.qry.head,
- ctx.qry.oid, ctx.qry.vpath);
+ cgit_blame_link(
+ "blame", tab_title("Line-by-line blame of %s", "Blame", vpath),
+ tab_class("blame"), ctx.qry.head, ctx.qry.oid, ctx.qry.vpath
+ );
else
- cgit_tree_link("tree",
- tab_title("Browse the tree at %s",
- "Browse the file tree", vpath),
- tab_class("tree"), ctx.qry.head,
- ctx.qry.oid, ctx.qry.vpath);
+ cgit_tree_link(
+ "tree", tab_title("Browse the tree at %s", "Browse the file tree", vpath),
+ tab_class("tree"), ctx.qry.head, ctx.qry.oid, ctx.qry.vpath
+ );
html("</li>\n<li>");
- cgit_commit_link("commit", "The current commit", tab_class("commit"),
- ctx.qry.head, ctx.qry.oid, ctx.qry.vpath);
+ cgit_commit_link(
+ "commit", "The current commit", tab_class("commit"),
+ ctx.qry.head, ctx.qry.oid, ctx.qry.vpath
+ );
html("</li>\n<li>");
- cgit_diff_link("diff",
- tab_title("Changes to %s", "Changes in the current commit", vpath),
- tab_class("diff"), ctx.qry.head,
- ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath);
+ cgit_diff_link(
+ "diff", tab_title("Changes to %s", "Changes in the current commit", vpath),
+ tab_class("diff"), ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath
+ );
html("</li>\n");
if (ctx.repo->max_stats) {
html("<li>");
- cgit_stats_link("stats", "Commit activity", tab_class("stats"),
- ctx.qry.head, ctx.qry.vpath);
+ cgit_stats_link("stats", "Commit activity", tab_class("stats"), ctx.qry.head, ctx.qry.vpath);
html("</li>\n");
}
html("</ul>\n");
@@ -637,8 +624,7 @@ static void print_repo_search(void)
{
html("<form class='search' method='get' action='");
if (ctx.cfg.virtual_root) {
- char *fileurl = cgit_fileurl(ctx.qry.repo, "log",
- ctx.qry.vpath, NULL);
+ char *fileurl = cgit_fileurl(ctx.qry.repo, "log", ctx.qry.vpath, NULL);
html_url_path(fileurl);
free(fileurl);
}
@@ -660,13 +646,11 @@ static void print_repo_search(void)
static void print_site_tabs(void)
{
html("<ul>\n<li>");
- site_link(NULL, "index", "Repository index", tab_class("repolist"),
- NULL, NULL, 0, 1);
+ site_link(NULL, "index", "Repository index", tab_class("repolist"), NULL, NULL, 0, 1);
html("</li>\n");
if (ctx.cfg.root_readme) {
html("<li>");
- site_link("about", "about", "About this site",
- tab_class("about"), NULL, NULL, 0, 1);
+ site_link("about", "about", "About this site", tab_class("about"), NULL, NULL, 0, 1);
html("</li>\n");
}
html("</ul>\n");
@@ -688,8 +672,7 @@ static void print_site_search(void)
}
static void snapshot_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev,
- const char *archivename)
+ const char *head, const char *rev, const char *archivename)
{
reporevlink("snapshot", name, title, class, head, rev, archivename);
}
@@ -699,54 +682,35 @@ static void snapshot_link(const char *name, const char *title, const char *class
static void self_link(const char *name, const char *title, const char *class)
{
if (!strcmp(ctx.qry.page, "repolist"))
- cgit_index_link(name, title, class, ctx.qry.search, ctx.qry.sort,
- ctx.qry.ofs, 1);
+ cgit_index_link(name, title, class, ctx.qry.search, ctx.qry.sort, ctx.qry.ofs, 1);
else if (!strcmp(ctx.qry.page, "summary"))
cgit_summary_link(name, title, class, ctx.qry.head);
else if (!strcmp(ctx.qry.page, "tag"))
- cgit_tag_link(name, title, class, ctx.qry.has_oid ?
- ctx.qry.oid : ctx.qry.head);
+ cgit_tag_link(name, title, class, ctx.qry.has_oid ? ctx.qry.oid : ctx.qry.head);
else if (!strcmp(ctx.qry.page, "tree"))
- cgit_tree_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ cgit_tree_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "plain"))
- cgit_plain_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ cgit_plain_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "blame"))
- cgit_blame_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ cgit_blame_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "log"))
- cgit_log_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path, ctx.qry.ofs,
- ctx.qry.grep, ctx.qry.search,
- ctx.qry.showmsg, ctx.qry.follow);
+ cgit_log_link(
+ name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL,
+ ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, ctx.qry.search,
+ ctx.qry.showmsg, ctx.qry.follow
+ );
else if (!strcmp(ctx.qry.page, "commit"))
- cgit_commit_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ cgit_commit_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "patch"))
- cgit_patch_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ cgit_patch_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "refs"))
- cgit_refs_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ cgit_refs_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "snapshot"))
- snapshot_link(name, title, class, ctx.qry.head,
- ctx.qry.has_oid ? ctx.qry.oid : NULL,
- ctx.qry.path);
+ snapshot_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "diff"))
- cgit_diff_link(name, title, class, ctx.qry.head,
- ctx.qry.oid, ctx.qry.oid2,
- ctx.qry.path);
+ cgit_diff_link(name, title, class, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, ctx.qry.path);
else if (!strcmp(ctx.qry.page, "stats"))
- cgit_stats_link(name, title, class, ctx.qry.head,
- ctx.qry.path);
+ cgit_stats_link(name, title, class, ctx.qry.head, ctx.qry.path);
else {
// A page name this switch does not know still gets a plain
// repolink, which covers any simple page added later.
@@ -824,8 +788,7 @@ char *cgit_hosturl(void)
return xstrdup(ctx.env.http_host);
if (!ctx.env.server_name)
return NULL;
- if (!ctx.env.server_port ||
- atoi(ctx.env.server_port) == DEFAULT_HTTP_PORT)
+ if (!ctx.env.server_port || atoi(ctx.env.server_port) == DEFAULT_HTTP_PORT)
return xstrdup(ctx.env.server_name);
return cgit_fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
}
@@ -895,8 +858,8 @@ char *cgit_repourl(const char *reponame)
return cgit_fmtalloc("?r=%s", reponame);
}
-char *cgit_fileurl(const char *reponame, const char *pagename,
- const char *filename, const char *query)
+char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename,
+ const char *query)
{
struct strbuf sb = STRBUF_INIT;
const char *delim;
@@ -904,12 +867,11 @@ char *cgit_fileurl(const char *reponame, const char *pagename,
// The result is a raw URL, so the query joiner is a bare ampersand
// and each sink escapes the whole string for wherever it lands.
if (ctx.cfg.virtual_root) {
- strbuf_addf(&sb, "%s%s/%s/%s", ctx.cfg.virtual_root, reponame,
- pagename, (filename ? filename:""));
+ strbuf_addf(&sb, "%s%s/%s/%s", ctx.cfg.virtual_root, reponame, pagename,
+ (filename ? filename:""));
delim = "?";
} else {
- strbuf_addf(&sb, "?url=%s/%s/%s", reponame, pagename,
- (filename ? filename : ""));
+ strbuf_addf(&sb, "?url=%s/%s/%s", reponame, pagename, (filename ? filename : ""));
delim = "&";
}
if (query)
@@ -917,8 +879,7 @@ char *cgit_fileurl(const char *reponame, const char *pagename,
return strbuf_detach(&sb, NULL);
}
-char *cgit_pageurl(const char *reponame, const char *pagename,
- const char *query)
+char *cgit_pageurl(const char *reponame, const char *pagename, const char *query)
{
return cgit_fileurl(reponame, pagename, NULL, query);
}
@@ -932,46 +893,42 @@ const char *cgit_snapshot_prefix(const struct cgit_repo *repo)
}
void cgit_index_link(const char *name, const char *title, const char *class,
- const char *pattern, const char *sort, int ofs,
- int always_root)
+ const char *pattern, const char *sort, int ofs, int always_root)
{
site_link(NULL, name, title, class, pattern, sort, ofs, always_root);
}
-void cgit_summary_link(const char *name, const char *title, const char *class,
- const char *head)
+void cgit_summary_link(const char *name, const char *title, const char *class, const char *head)
{
reporevlink(NULL, name, title, class, head, NULL, NULL);
}
-void cgit_tag_link(const char *name, const char *title, const char *class,
- const char *tag)
+void cgit_tag_link(const char *name, const char *title, const char *class, const char *tag)
{
reporevlink("tag", name, title, class, tag, NULL, NULL);
}
void cgit_tree_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path)
+ const char *head, const char *rev, const char *path)
{
reporevlink("tree", name, title, class, head, rev, path);
}
void cgit_plain_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path)
+ const char *head, const char *rev, const char *path)
{
reporevlink("plain", name, title, class, head, rev, path);
}
void cgit_blame_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path)
+ const char *head, const char *rev, const char *path)
{
reporevlink("blame", name, title, class, head, rev, path);
}
void cgit_log_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path,
- int ofs, const char *grep, const char *pattern, int showmsg,
- int follow)
+ const char *head, const char *rev, const char *path, int ofs, const char *grep,
+ const char *pattern, int showmsg, int follow)
{
const char *delim;
@@ -1007,7 +964,7 @@ void cgit_log_link(const char *name, const char *title, const char *class,
}
void cgit_commit_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path)
+ const char *head, const char *rev, const char *path)
{
const char *delim;
@@ -1016,8 +973,7 @@ void cgit_commit_link(const char *name, const char *title, const char *class,
emit_diff_args(delim);
html("'>");
if (name && name[0] != '\0') {
- if (ctx.cfg.max_msg_len >= MIN_TRUNCATE_LEN &&
- strlen(name) > (size_t)ctx.cfg.max_msg_len) {
+ if (ctx.cfg.max_msg_len >= MIN_TRUNCATE_LEN && strlen(name) > (size_t)ctx.cfg.max_msg_len) {
html_ntxt(name, ctx.cfg.max_msg_len - ELLIPSIS_LEN);
html("...");
} else
@@ -1028,14 +984,13 @@ void cgit_commit_link(const char *name, const char *title, const char *class,
}
void cgit_refs_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path)
+ const char *head, const char *rev, const char *path)
{
reporevlink("refs", name, title, class, head, rev, path);
}
void cgit_diff_link(const char *name, const char *title, const char *class,
- const char *head, const char *new_rev, const char *old_rev,
- const char *path)
+ const char *head, const char *new_rev, const char *old_rev, const char *path)
{
const char *delim;
@@ -1054,13 +1009,13 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
}
void cgit_patch_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev, const char *path)
+ const char *head, const char *rev, const char *path)
{
reporevlink("patch", name, title, class, head, rev, path);
}
void cgit_stats_link(const char *name, const char *title, const char *class,
- const char *head, const char *path)
+ const char *head, const char *path)
{
reporevlink("stats", name, title, class, head, NULL, path);
}
@@ -1074,8 +1029,7 @@ void cgit_object_link(struct object *obj)
shortrev = xstrdup(fullrev);
shortrev[SHORT_HASH_LEN] = '\0';
if (obj->type == OBJ_COMMIT) {
- cgit_commit_link(cgit_fmt("commit %s...", shortrev), NULL, NULL,
- ctx.qry.head, fullrev, NULL);
+ cgit_commit_link(cgit_fmt("commit %s...", shortrev), NULL, NULL, ctx.qry.head, fullrev, NULL);
return;
} else if (obj->type == OBJ_TREE)
page = "tree";
@@ -1128,18 +1082,19 @@ static char *submodule_url_path(const char *url)
strbuf_release(&sb);
return NULL;
}
- } else if (skip_prefix(url, "http://", &rest) ||
- skip_prefix(url, "https://", &rest) ||
- skip_prefix(url, "git://", &rest) ||
- skip_prefix(url, "ssh://", &rest)) {
+ } else if (
+ skip_prefix(url, "http://", &rest) ||
+ skip_prefix(url, "https://", &rest) ||
+ skip_prefix(url, "git://", &rest) ||
+ skip_prefix(url, "ssh://", &rest)
+ ) {
rest = strchr(rest, '/');
if (!rest)
return NULL;
strbuf_addstr(&sb, rest);
} else if (skip_prefix(url, "file://", &rest)) {
strbuf_addstr(&sb, rest);
- } else if ((colon = strchr(url, ':')) &&
- !memchr(url, '/', colon - url)) {
+ } else if ((colon = strchr(url, ':')) && !memchr(url, '/', colon - url)) {
// scp syntax, user@host:path
strbuf_addstr(&sb, colon + 1);
} else {
@@ -1216,8 +1171,7 @@ static const struct forge *forge_for_host(const char *host, size_t len)
size_t i;
for (i = 0; i < ARRAY_SIZE(forges); i++)
- if (strlen(forges[i].host) == len &&
- !strncasecmp(forges[i].host, host, len))
+ if (strlen(forges[i].host) == len && !strncasecmp(forges[i].host, host, len))
return &forges[i];
return NULL;
}
@@ -1228,9 +1182,8 @@ static const struct forge *forge_for_host(const char *host, size_t len)
* relative urls still land on an internal page when their target is served
* here, and a scheme cgit cannot vouch for is left unlinked as a tooltip.
*/
-static void gitmodules_link(const char *path, const char *rev,
- char **module, char **commit,
- const char **tooltip)
+static void gitmodules_link(const char *path, const char *rev, char **module,
+ char **commit, const char **tooltip)
{
const struct object_id *treeish = page_treeish();
const struct submodule *sub;
@@ -1256,8 +1209,7 @@ static void gitmodules_link(const char *path, const char *rev,
return;
}
- if (skip_prefix(url, "http://", &rest) ||
- skip_prefix(url, "https://", &rest)) {
+ if (skip_prefix(url, "http://", &rest) || skip_prefix(url, "https://", &rest)) {
*module = xstrdup(url);
forge = forge_for_host(rest, strcspn(rest, "/"));
if (forge) {
@@ -1284,8 +1236,7 @@ static void gitmodules_link(const char *path, const char *rev,
rest = colon + 1;
while (*rest == '/')
rest++;
- strbuf_addf(&sb, "https://%.*s/%s",
- (int)(colon - host), host, rest);
+ strbuf_addf(&sb, "https://%.*s/%s", (int)(colon - host), host, rest);
while (sb.len && sb.buf[sb.len - 1] == '/')
strbuf_setlen(&sb, sb.len - 1);
if (!forge->keep_dot_git)
@@ -1322,8 +1273,7 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
}
}
- if (!item && !ctx.repo->module_link &&
- ctx.repo->enable_gitmodules_links)
+ if (!item && !ctx.repo->module_link && ctx.repo->enable_gitmodules_links)
gitmodules_link(path, rev, &module, &commit, &tooltip);
// The row shows the entry's own name, like every other row, while
@@ -1398,39 +1348,32 @@ void cgit_print_age(time_t t, int tz, time_t max_relative)
if (secs < 0)
secs = 0;
- if (!ctx.cfg.enable_relative_dates ||
- (secs > max_relative && max_relative >= 0)) {
+ if (!ctx.cfg.enable_relative_dates || (secs > max_relative && max_relative >= 0)) {
print_abs_date(t, tz);
return;
}
if (secs < SECONDS_PER_HOUR * 2) {
- print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MINUTE,
- "age-mins", "min.");
+ print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MINUTE, "age-mins", "min.");
return;
}
if (secs < SECONDS_PER_DAY * 2) {
- print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_HOUR,
- "age-hours", "hours");
+ print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_HOUR, "age-hours", "hours");
return;
}
if (secs < SECONDS_PER_WEEK * 2) {
- print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_DAY,
- "age-days", "days");
+ print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_DAY, "age-days", "days");
return;
}
if (secs < SECONDS_PER_MONTH * 2) {
- print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_WEEK,
- "age-weeks", "weeks");
+ print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_WEEK, "age-weeks", "weeks");
return;
}
if (secs < SECONDS_PER_YEAR * 2) {
- print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MONTH,
- "age-months", "months");
+ print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MONTH, "age-months", "months");
return;
}
- print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_YEAR,
- "age-years", "years");
+ print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_YEAR, "age-years", "years");
}
void cgit_print_http_headers(void)
@@ -1445,8 +1388,7 @@ void cgit_print_http_headers(void)
else
html("Status: 200 OK\n");
if (ctx.page.mimetype && ctx.page.charset)
- htmlf("Content-Type: %s; charset=%s\n", ctx.page.mimetype,
- ctx.page.charset);
+ htmlf("Content-Type: %s; charset=%s\n", ctx.page.mimetype, ctx.page.charset);
else if (ctx.page.mimetype)
htmlf("Content-Type: %s\n", ctx.page.mimetype);
if (ctx.page.size)
@@ -1475,8 +1417,7 @@ void cgit_print_http_headers(void)
void cgit_redirect(const char *url, bool permanent)
{
- htmlf("Status: %d %s\n", permanent ? 301 : 302,
- permanent ? "Moved Permanently" : "Found");
+ htmlf("Status: %d %s\n", permanent ? 301 : 302, permanent ? "Moved Permanently" : "Found");
html("Location: ");
html_url_path(url);
html("\n\n");
@@ -1499,10 +1440,8 @@ void cgit_print_docstart(void)
html("<meta charset='UTF-8'>\n");
html("<meta name='viewport' content='width=device-width, initial-scale=1'>\n");
html("<meta name='color-scheme' content='light dark'>\n");
- html("<meta name='theme-color' media='(prefers-color-scheme: light)'"
- " content='#ffffff'>\n");
- html("<meta name='theme-color' media='(prefers-color-scheme: dark)'"
- " content='#1b1b1b'>\n");
+ html("<meta name='theme-color' media='(prefers-color-scheme: light)' content='#ffffff'>\n");
+ html("<meta name='theme-color' media='(prefers-color-scheme: dark)' content='#1b1b1b'>\n");
html("<title>");
// An error page reached before a title was chosen still has to name
// itself, since an empty title element is not valid.
@@ -1514,8 +1453,7 @@ void cgit_print_docstart(void)
html("</title>\n");
// The placeholder a scanned repository carries instead of a description
// is left out, since it describes nothing.
- if (ctx.repo && ctx.repo->desc && *ctx.repo->desc &&
- ctx.repo->desc != cgit_default_repo_desc) {
+ if (ctx.repo && ctx.repo->desc && *ctx.repo->desc && ctx.repo->desc != cgit_default_repo_desc) {
html("<meta name='description' content='");
html_attr(ctx.repo->desc);
html("'>\n");
@@ -1554,8 +1492,7 @@ void cgit_print_docstart(void)
html("<link rel='alternate' title='Atom feed' href='");
html(cgit_httpscheme());
html_attr(host);
- fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
- sb.buf);
+ fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath, sb.buf);
html_attr(fileurl);
html("' type='application/atom+xml'>\n");
strbuf_release(&sb);
@@ -1603,8 +1540,7 @@ void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)
va_end(ap);
}
-void cgit_vprint_error_page(int code, const char *msg, const char *fmt,
- va_list ap)
+void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ap)
{
// An error page describes a condition that may not outlast the slot
// holding it. A request naming a commit not yet pushed would cache its
@@ -1688,8 +1624,7 @@ void cgit_print_clone_row(const char *url, int colspan)
free(fallback);
}
-void cgit_add_hidden_formfields(int incl_head, int incl_search,
- const char *page)
+void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page)
{
if (!ctx.cfg.virtual_root) {
struct strbuf url = STRBUF_INIT;
@@ -1701,8 +1636,7 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search,
strbuf_release(&url);
}
- if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
- strcmp(ctx.qry.head, ctx.repo->defbranch))
+ if (incl_head && ctx.qry.head && ctx.repo->defbranch && strcmp(ctx.qry.head, ctx.repo->defbranch))
html_hidden("h", ctx.qry.head);
if (ctx.qry.oid)
@@ -1734,8 +1668,7 @@ void cgit_print_pageheader(void)
// Every other tab needs a commit to render and the search form
// has nothing to search, so an empty repo gets summary alone.
html("<ul>\n<li>");
- cgit_summary_link("summary", "Repository summary",
- tab_class("summary"), ctx.qry.head);
+ cgit_summary_link("summary", "Repository summary", tab_class("summary"), ctx.qry.head);
html("</li>\n</ul>\n");
} else if (ctx.env.authenticated && ctx.repo) {
print_repo_tabs();
@@ -1749,8 +1682,7 @@ void cgit_print_pageheader(void)
pinned = ctx.env.authenticated && ctx.repo ? pinned_oid() : NULL;
// The commit and diff pages name the commit they show as their own
// content, so the rev crumb would only repeat them.
- if (pinned && ctx.qry.page && (!strcmp(ctx.qry.page, "commit") ||
- !strcmp(ctx.qry.page, "diff")))
+ if (pinned && ctx.qry.page && (!strcmp(ctx.qry.page, "commit") || !strcmp(ctx.qry.page, "diff")))
pinned = NULL;
if ((ctx.env.authenticated && ctx.repo && ctx.qry.vpath) || pinned) {
html("<nav class='path' aria-label='");
@@ -1762,12 +1694,10 @@ void cgit_print_pageheader(void)
// between them, so the run stays inline in a span.
html("<span>path: ");
print_path_crumbs(ctx.qry.vpath);
- if (ctx.repo->enable_follow_links &&
- !strcmp(ctx.qry.page, "log")) {
+ if (ctx.repo->enable_follow_links && !strcmp(ctx.qry.page, "log")) {
html(" (");
ctx.qry.follow = !ctx.qry.follow;
- self_link(ctx.qry.follow ? "follow" : "unfollow",
- NULL, NULL);
+ self_link(ctx.qry.follow ? "follow" : "unfollow", NULL, NULL);
ctx.qry.follow = !ctx.qry.follow;
html(")");
}
@@ -1779,8 +1709,7 @@ void cgit_print_pageheader(void)
html("<span class='rev'>rev: ");
cgit_commit_link(cgit_fmt("%.*s", SHORT_HASH_LEN, hex),
- NULL, NULL, ctx.qry.head, hex,
- ctx.qry.vpath);
+ NULL, NULL, ctx.qry.head, hex, ctx.qry.vpath);
html(" (");
// self_link reads the pin out of ctx.qry, so lifting
// it is what makes the link land back on the tip of
@@ -1812,8 +1741,7 @@ void cgit_print_filemode(unsigned short mode)
html_fileperm(mode);
}
-static void compose_snapshot_prefix(struct strbuf *filename, const char *base,
- const char *ref)
+static void compose_snapshot_prefix(struct strbuf *filename, const char *base, const char *ref)
{
struct object_id oid;
@@ -1831,8 +1759,7 @@ static void compose_snapshot_prefix(struct strbuf *filename, const char *base,
strbuf_addf(filename, "%s-%s", base, ref);
}
-void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
- const char *separator)
+void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, const char *separator)
{
const struct cgit_snapshot_format *f;
struct strbuf filename = STRBUF_INIT;
@@ -1851,25 +1778,20 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
continue;
strbuf_setlen(&filename, prefixlen);
strbuf_addstr(&filename, f->suffix);
- snapshot_link(filename.buf, NULL, NULL, NULL, NULL,
- filename.buf);
+ snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf);
if (cgit_snapshot_get_sig(ref, f)) {
strbuf_addstr(&filename, ".asc");
html(" (");
- snapshot_link("sig", NULL, NULL, NULL, NULL,
- filename.buf);
+ snapshot_link("sig", NULL, NULL, NULL, NULL, filename.buf);
html(")");
- } else if (starts_with(f->suffix, ".tar") &&
- cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) {
+ } else if (starts_with(f->suffix, ".tar") && cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) {
// A compressed tarball offers the signature made for
// the plain tar it expands to, which is the first
// format in the table.
- strbuf_setlen(&filename,
- filename.len - strlen(f->suffix));
+ strbuf_setlen(&filename, filename.len - strlen(f->suffix));
strbuf_addstr(&filename, ".tar.asc");
html(" (");
- snapshot_link("sig", NULL, NULL, NULL, NULL,
- filename.buf);
+ snapshot_link("sig", NULL, NULL, NULL, NULL, filename.buf);
html(")");
}
html(separator);
diff --git a/source/ui-shared.h b/source/ui-shared.h
index c421178..8a1a2b8 100644
--- a/source/ui-shared.h
+++ b/source/ui-shared.h
@@ -25,10 +25,9 @@ extern char *cgit_currentfullurl(void);
extern const char *cgit_loginurl(void);
extern char *cgit_repourl(const char *reponame);
extern void cgit_print_clone_row(const char *url, int colspan);
-extern char *cgit_fileurl(const char *reponame, const char *pagename,
- const char *filename, const char *query);
-extern char *cgit_pageurl(const char *reponame, const char *pagename,
- const char *query);
+extern char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename,
+ const char *query);
+extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query);
// Call fn once for every URL this repository can be cloned from.
extern void cgit_add_clone_urls(void (*fn)(const char *));
@@ -38,46 +37,32 @@ extern void cgit_add_clone_urls(void (*fn)(const char *));
* as the text a reader sees. A NULL title or class leaves that attribute out,
* and what follows them is the state the target page should open in.
*/
-extern void cgit_index_link(const char *name, const char *title,
- const char *class, const char *pattern,
- const char *sort, int ofs, int always_root);
-extern void cgit_summary_link(const char *name, const char *title,
- const char *class, const char *head);
-extern void cgit_tag_link(const char *name, const char *title,
- const char *class, const char *tag);
-extern void cgit_tree_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *rev, const char *path);
-extern void cgit_plain_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *rev, const char *path);
-extern void cgit_blame_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *rev, const char *path);
-extern void cgit_log_link(const char *name, const char *title,
- const char *class, const char *head, const char *rev,
- const char *path, int ofs, const char *grep,
- const char *pattern, int showmsg, int follow);
-extern void cgit_commit_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *rev, const char *path);
-extern void cgit_patch_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *rev, const char *path);
-extern void cgit_refs_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *rev, const char *path);
-extern void cgit_diff_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *new_rev, const char *old_rev,
- const char *path);
-extern void cgit_stats_link(const char *name, const char *title,
- const char *class, const char *head,
- const char *path);
+extern void cgit_index_link(const char *name, const char *title, const char *class,
+ const char *pattern, const char *sort, int ofs, int always_root);
+extern void cgit_summary_link(const char *name, const char *title, const char *class, const char *head);
+extern void cgit_tag_link(const char *name, const char *title, const char *class, const char *tag);
+extern void cgit_tree_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path);
+extern void cgit_plain_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path);
+extern void cgit_blame_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path);
+extern void cgit_log_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path, int ofs, const char *grep,
+ const char *pattern, int showmsg, int follow);
+extern void cgit_commit_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path);
+extern void cgit_patch_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path);
+extern void cgit_refs_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path);
+extern void cgit_diff_link(const char *name, const char *title, const char *class,
+ const char *head, const char *new_rev, const char *old_rev, const char *path);
+extern void cgit_stats_link(const char *name, const char *title, const char *class,
+ const char *head, const char *path);
extern void cgit_object_link(struct object *obj);
-extern void cgit_submodule_link(const char *class, char *path,
- const char *rev);
+extern void cgit_submodule_link(const char *class, char *path, const char *rev);
extern void cgit_print_layout_start(void);
extern void cgit_print_layout_end(void);
@@ -98,14 +83,11 @@ extern void cgit_redirect(const char *url, bool permanent);
extern void cgit_print_docstart(void);
extern void cgit_print_docend(void);
__attribute__((format (printf,3,4)))
-extern void cgit_print_error_page(int code, const char *msg, const char *fmt,
- ...);
-extern void cgit_vprint_error_page(int code, const char *msg, const char *fmt,
- va_list ap);
+extern void cgit_print_error_page(int code, const char *msg, const char *fmt, ...);
+extern void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ap);
extern void cgit_print_pageheader(void);
extern void cgit_print_filemode(unsigned short mode);
-extern void cgit_print_snapshot_links(const struct cgit_repo *repo,
- const char *ref, const char *separator);
+extern void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, const char *separator);
// The name a snapshot of this repository is downloaded under, which is the
// configured prefix or the last component of the repository URL.
@@ -117,8 +99,7 @@ extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo);
* terms are carried only when the caller asks for them, since a form with a
* field of its own for either would otherwise submit that name twice.
*/
-extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
- const char *page);
+extern void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page);
// Put path in front of the page title, its last component first.
extern void cgit_set_title_from_path(const char *path);
diff --git a/source/ui-snapshot.c b/source/ui-snapshot.c
index af985f4..a9bf858 100644
--- a/source/ui-snapshot.c
+++ b/source/ui-snapshot.c
@@ -20,8 +20,7 @@
#define SIG_SUFFIX ".asc"
-static int write_archive_format(const char *format_arg, const char *hex,
- const char *prefix)
+static int write_archive_format(const char *format_arg, const char *hex, const char *prefix)
{
struct strvec argv = STRVEC_INIT;
const char **args;
@@ -62,8 +61,7 @@ static int write_zip_archive(const char *hex, const char *prefix)
return write_archive_format("--format=zip", hex, prefix);
}
-static int write_compressed_tar_archive(const char *hex, const char *prefix,
- char *argv[])
+static int write_compressed_tar_archive(const char *hex, const char *prefix, char *argv[])
{
struct cgit_exec_filter filter;
int result;
@@ -147,9 +145,8 @@ static int resolves(const char *rev)
return repo_get_oid(the_repository, rev, &oid) == 0;
}
-static const char *ref_from_filename(const struct cgit_repo *repo,
- const char *filename,
- const struct cgit_snapshot_format *format)
+static const char *ref_from_filename(const struct cgit_repo *repo, const char *filename,
+ const struct cgit_snapshot_format *format)
{
struct strbuf rev = STRBUF_INIT;
const char *repo_prefix;
@@ -190,20 +187,17 @@ out:
return found ? strbuf_detach(&rev, NULL) : NULL;
}
-static int send_snapshot(const struct cgit_snapshot_format *format,
- const char *hex, const char *prefix,
- const char *filename)
+static int send_snapshot(const struct cgit_snapshot_format *format, const char *hex,
+ const char *prefix, const char *filename)
{
struct object_id oid;
if (repo_get_oid(the_repository, hex, &oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad object id: %s", hex);
+ cgit_print_error_page(404, "Not Found", "Bad object id: %s", hex);
return 1;
}
if (!lookup_commit_reference(the_repository, &oid)) {
- cgit_print_error_page(400, "Bad Request",
- "Not a commit reference: %s", hex);
+ cgit_print_error_page(400, "Bad Request", "Not a commit reference: %s", hex);
return 1;
}
ctx.page.mimetype = xstrdup(format->mimetype);
@@ -214,9 +208,8 @@ static int send_snapshot(const struct cgit_snapshot_format *format,
return 0;
}
-static int send_sig(const struct cgit_snapshot_format *format,
- const char *hex, const char *archive_name,
- const char *sig_filename)
+static int send_sig(const struct cgit_snapshot_format *format, const char *hex,
+ const char *archive_name, const char *sig_filename)
{
const struct object_id *note = cgit_snapshot_get_sig(hex, format);
enum object_type type;
@@ -224,8 +217,7 @@ static int send_sig(const struct cgit_snapshot_format *format,
char *buf;
if (!note) {
- cgit_print_error_page(404, "Not Found",
- "No signature for %s", archive_name);
+ cgit_print_error_page(404, "Not Found", "No signature for %s", archive_name);
return 0;
}
@@ -245,8 +237,7 @@ static int send_sig(const struct cgit_snapshot_format *format,
return 0;
}
-const struct object_id *cgit_snapshot_get_sig(const char *ref,
- const struct cgit_snapshot_format *f)
+const struct object_id *cgit_snapshot_get_sig(const char *ref, const struct cgit_snapshot_format *f)
{
struct notes_tree *tree;
struct object_id oid;
@@ -260,8 +251,7 @@ const struct object_id *cgit_snapshot_get_sig(const char *ref,
// Signatures live under the format suffix with the leading dot
// dropped, so plain tar is refs/notes/signatures/tar.
- strbuf_addf(&notes_ref, "refs/notes/signatures/%s",
- f->suffix + 1);
+ strbuf_addf(&notes_ref, "refs/notes/signatures/%s", f->suffix + 1);
init_notes(tree, notes_ref.buf, combine_notes_ignore, 0);
strbuf_release(&notes_ref);
@@ -295,8 +285,7 @@ int cgit_parse_snapshots_mask(const char *str)
for_each_string_list_item(item, &tokens) {
for (f = cgit_snapshot_formats; f->suffix; f++) {
- if (!strcmp(item->string, f->suffix) ||
- !strcmp(item->string, f->suffix + 1)) {
+ if (!strcmp(item->string, f->suffix) || !strcmp(item->string, f->suffix + 1)) {
mask |= cgit_snapshot_format_bit(f);
break;
}
@@ -307,8 +296,7 @@ int cgit_parse_snapshots_mask(const char *str)
return mask;
}
-void cgit_print_snapshot(const char *head, const char *hex,
- const char *filename, int dwim)
+void cgit_print_snapshot(const char *head, const char *hex, const char *filename, int dwim)
{
const struct cgit_snapshot_format *f;
const char *sig_filename = NULL;
@@ -316,8 +304,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
char *prefix = NULL;
if (!filename) {
- cgit_print_error_page(400, "Bad Request",
- "No snapshot name specified");
+ cgit_print_error_page(400, "Bad Request", "No snapshot name specified");
return;
}
@@ -329,10 +316,8 @@ void cgit_print_snapshot(const char *head, const char *hex,
}
f = find_format(filename);
- if (!f || (!sig_filename &&
- !(ctx.repo->snapshots & cgit_snapshot_format_bit(f)))) {
- cgit_print_error_page(400, "Bad Request",
- "Unsupported snapshot format: %s", filename);
+ if (!f || (!sig_filename && !(ctx.repo->snapshots & cgit_snapshot_format_bit(f)))) {
+ cgit_print_error_page(400, "Bad Request", "Unsupported snapshot format: %s", filename);
return;
}
diff --git a/source/ui-snapshot.h b/source/ui-snapshot.h
index 9d2910f..c594168 100644
--- a/source/ui-snapshot.h
+++ b/source/ui-snapshot.h
@@ -36,7 +36,6 @@ extern int cgit_parse_snapshots_mask(const char *str);
extern const struct object_id *cgit_snapshot_get_sig(
const char *ref, const struct cgit_snapshot_format *f);
-extern void cgit_print_snapshot(const char *head, const char *hex,
- const char *filename, int dwim);
+extern void cgit_print_snapshot(const char *head, const char *hex, const char *filename, int dwim);
#endif // CGIT_UI_SNAPSHOT_H
diff --git a/source/ui-ssdiff.c b/source/ui-ssdiff.c
index 759a77b..2ea4751 100644
--- a/source/ui-ssdiff.c
+++ b/source/ui-ssdiff.c
@@ -53,8 +53,7 @@ static void create_lcs_table(void)
* owns. A line too long for the table gets NULL back and is shown whole
* instead.
*/
-static char *longest_common_subsequence(const char *old_line,
- const char *new_line)
+static char *longest_common_subsequence(const char *old_line, const char *new_line)
{
int old_len = strlen(old_line);
int new_len = strlen(new_line);
@@ -76,8 +75,7 @@ static char *longest_common_subsequence(const char *old_line,
int drop_old = lcs_table[i + 1][j];
int drop_new = lcs_table[i][j + 1];
- lcs_table[i][j] = (drop_old > drop_new ?
- drop_old : drop_new);
+ lcs_table[i][j] = (drop_old > drop_new ? drop_old : drop_new);
}
}
}
@@ -116,8 +114,7 @@ static char *expand_tabs(const char *line)
for (p = line; *p; p++) {
if (*p == '\t')
- strbuf_addchars(&out, ' ',
- TAB_WIDTH - (out.len % TAB_WIDTH));
+ strbuf_addchars(&out, ' ', TAB_WIDTH - (out.len % TAB_WIDTH));
else
strbuf_addch(&out, *p);
}
@@ -136,8 +133,7 @@ static void flush_run(struct strbuf *run)
* A stretch the other side does not share is escaped in one call, so a
* changed line does not go through the output path a byte at a time.
*/
-static void print_line_with_lcs(const char *class, const char *line,
- const char *lcs)
+static void print_line_with_lcs(const char *class, const char *line, const char *lcs)
{
int len = strlen(line);
int in_common = 1;
@@ -168,8 +164,7 @@ static void print_line_with_lcs(const char *class, const char *line,
strbuf_release(&run);
}
-static void print_lineno_cell(struct diff_filespec *file,
- const struct object_id *rev, int line_no)
+static void print_lineno_cell(struct diff_filespec *file, const struct object_id *rev, int line_no)
{
struct strbuf path = STRBUF_INIT;
char *anchor, *query, *fileurl;
@@ -191,10 +186,8 @@ static void print_lineno_cell(struct diff_filespec *file,
strbuf_release(&path);
}
-static void print_row(const char *class,
- int old_line_no, char *old_line,
- int new_line_no, char *new_line,
- int highlight_chars)
+static void print_row(const char *class, int old_line_no, char *old_line,
+ int new_line_no, char *new_line, int highlight_chars)
{
char *lcs = NULL;
@@ -207,8 +200,7 @@ static void print_row(const char *class,
lcs = longest_common_subsequence(old_line, new_line);
html("<tr>\n");
if (old_line_no > 0) {
- print_lineno_cell(cgit_get_current_old_file(), old_rev_oid,
- old_line_no);
+ print_lineno_cell(cgit_get_current_old_file(), old_rev_oid, old_line_no);
htmlf("<td class='%s'>", class);
} else if (old_line)
htmlf("<td class='lineno'></td><td class='%s'>", class);
@@ -223,8 +215,7 @@ static void print_row(const char *class,
html("</td>\n");
if (new_line_no > 0) {
- print_lineno_cell(cgit_get_current_new_file(), new_rev_oid,
- new_line_no);
+ print_lineno_cell(cgit_get_current_new_file(), new_rev_oid, new_line_no);
htmlf("<td class='%s'>", class);
} else if (new_line)
htmlf("<td class='lineno'></td><td class='%s'>", class);
@@ -243,9 +234,8 @@ static void print_row(const char *class,
free(old_line);
}
-static void defer_line(struct deferred_line **head,
- struct deferred_line **last,
- const char *line, int line_no)
+static void defer_line(struct deferred_line **head, struct deferred_line **last,
+ const char *line, int line_no)
{
struct deferred_line *item = xmalloc(sizeof(*item));
@@ -321,15 +311,12 @@ static void print_deferred_changed_lines(void)
highlight_chars = count_deferred(old_item) == count_deferred(new_item);
while (old_item || new_item) {
if (old_item && new_item)
- print_row("changed", old_item->line_no,
- old_item->line, new_item->line_no,
- new_item->line, highlight_chars);
+ print_row("changed", old_item->line_no, old_item->line,
+ new_item->line_no, new_item->line, highlight_chars);
else if (old_item)
- print_row("changed", old_item->line_no,
- old_item->line, -1, NULL, 0);
+ print_row("changed", old_item->line_no, old_item->line, -1, NULL, 0);
else if (new_item)
- print_row("changed", -1, NULL,
- new_item->line_no, new_item->line, 0);
+ print_row("changed", -1, NULL, new_item->line_no, new_item->line, 0);
if (old_item) {
next = old_item->next;
free_deferred(old_item);
@@ -395,17 +382,14 @@ void cgit_ssdiff_line_cb(char *line, int len)
if (line[0] == ' ') {
print_deferred_lines();
- print_row("ctx", current_old_line, line,
- current_new_line, line, 0);
+ print_row("ctx", current_old_line, line, current_new_line, line, 0);
current_old_line += 1;
current_new_line += 1;
} else if (line[0] == '+') {
- defer_line(&deferred_new, &deferred_new_last, line,
- current_new_line);
+ defer_line(&deferred_new, &deferred_new_last, line, current_new_line);
current_new_line += 1;
} else if (line[0] == '-') {
- defer_line(&deferred_old, &deferred_old_last, line,
- current_old_line);
+ defer_line(&deferred_old, &deferred_old_last, line, current_old_line);
current_old_line += 1;
} else if (line[0] == '@') {
html("<tr><td colspan='4' class='hunk'>");
diff --git a/source/ui-stats.c b/source/ui-stats.c
index 62aac56..a04b189 100644
--- a/source/ui-stats.c
+++ b/source/ui-stats.c
@@ -168,7 +168,7 @@ static void window_start(const struct cgit_period *period, struct tm *tm)
}
static void add_commit(struct string_list *authors, struct commitinfo *info,
- const struct cgit_period *period)
+ const struct cgit_period *period)
{
struct string_list_item *author, *bucket;
struct authorstat *stats;
@@ -296,11 +296,9 @@ static struct string_list build_period_labels(const struct cgit_period *period)
* The run of authors to sum is given as a start and a count rather than as
* two indices, so that an empty author list cannot describe a run that wraps.
*/
-static void print_summary_row(struct string_list *authors, size_t from,
- size_t count, const char *label_format,
- const char *leftclass, const char *centerclass,
- const char *rightclass,
- const struct string_list *labels)
+static void print_summary_row(struct string_list *authors, size_t from, size_t count,
+ const char *label_format, const char *leftclass, const char *centerclass,
+ const char *rightclass, const struct string_list *labels)
{
struct authorstat *stats;
struct string_list_item *bucket;
@@ -308,8 +306,7 @@ static void print_summary_row(struct string_list *authors, size_t from,
long total, subtotal;
total = 0;
- htmlf("<tr><td class='%s'>%s</td>", leftclass,
- cgit_fmt(label_format, (long)count));
+ htmlf("<tr><td class='%s'>%s</td>", leftclass, cgit_fmt(label_format, (long)count));
for (column = 0; column < labels->nr; column++) {
const char *label = labels->items[column].string;
@@ -326,8 +323,7 @@ static void print_summary_row(struct string_list *authors, size_t from,
htmlf("<td class='%s'>%ld</td></tr>\n", rightclass, total);
}
-static void print_authors(struct string_list *authors, int max_rows,
- const struct string_list *labels)
+static void print_authors(struct string_list *authors, int max_rows, const struct string_list *labels)
{
struct string_list_item *author, *bucket;
struct authorstat *stats;
@@ -340,8 +336,7 @@ static void print_authors(struct string_list *authors, int max_rows,
html("<th>Total</th></tr>\n");
// The row count arrives through ofs, which carries -1 for "all".
- rows = (max_rows <= 0 || (size_t)max_rows > authors->nr)
- ? authors->nr : (size_t)max_rows;
+ rows = (max_rows <= 0 || (size_t)max_rows > authors->nr) ? authors->nr : (size_t)max_rows;
for (i = 0; i < rows; i++) {
author = &authors->items[i];
@@ -365,11 +360,9 @@ static void print_authors(struct string_list *authors, int max_rows,
}
if (rows < authors->nr)
- print_summary_row(authors, rows, authors->nr - rows,
- "Others (%ld)", "left", "", "sum", labels);
+ print_summary_row(authors, rows, authors->nr - rows, "Others (%ld)", "left", "", "sum", labels);
- print_summary_row(authors, 0, authors->nr, "Total",
- "total", "sum", "sum", labels);
+ print_summary_row(authors, 0, authors->nr, "Total", "total", "sum", "sum", labels);
html("</table>\n");
}
@@ -387,9 +380,7 @@ static void print_options_form(const struct cgit_period *period, int top)
html("<tr><td class='label'>Period:</td>");
html("<td class='ctrl'><select name='period'>");
for (i = 0; i < choices; i++)
- html_option(cgit_fmt("%c", periods[i].code),
- periods[i].name,
- cgit_fmt("%c", period->code));
+ html_option(cgit_fmt("%c", periods[i].code), periods[i].name, cgit_fmt("%c", period->code));
html("</select></td></tr>\n");
}
html("<tr><td class='label'>Authors:</td>");
@@ -447,18 +438,15 @@ void cgit_show_stats(void)
period_index = cgit_find_stats_period(code, &period);
if (!period_index) {
- cgit_print_error_page(404, "Not Found",
- "Unknown statistics type: %c", code[0]);
+ cgit_print_error_page(404, "Not Found", "Unknown statistics type: %c", code[0]);
return;
}
if (period_index > ctx.repo->max_stats) {
- cgit_print_error_page(400, "Bad Request",
- "Statistics type disabled: %s", period->name);
+ cgit_print_error_page(400, "Bad Request", "Statistics type disabled: %s", period->name);
return;
}
authors = collect_stats(period);
- qsort(authors.items, authors.nr, sizeof(struct string_list_item),
- cmp_total_commits);
+ qsort(authors.items, authors.nr, sizeof(struct string_list_item), cmp_total_commits);
top = ctx.qry.ofs;
if (!top)
diff --git a/source/ui-stats.h b/source/ui-stats.h
index 1b20e6c..feee741 100644
--- a/source/ui-stats.h
+++ b/source/ui-stats.h
@@ -36,8 +36,7 @@ struct cgit_period {
* table runs from the finest window to the coarsest, the index is what
* max-stats is compared against.
*/
-extern int cgit_find_stats_period(const char *expr,
- const struct cgit_period **period);
+extern int cgit_find_stats_period(const char *expr, const struct cgit_period **period);
// The name of the period at a one based index, or an empty string when the
// index names no period.
diff --git a/source/ui-summary.c b/source/ui-summary.c
index 197cd07..ea8f783 100644
--- a/source/ui-summary.c
+++ b/source/ui-summary.c
@@ -59,8 +59,7 @@ static int path_within(const char *base, const char *path)
{
size_t len = strlen(base);
- return starts_with(path, base) &&
- (path[len] == '\0' || path[len] == '/');
+ return starts_with(path, base) && (path[len] == '\0' || path[len] == '/');
}
/*
@@ -69,8 +68,7 @@ static int path_within(const char *base, const char *path)
* such a readme is confined to its own directory, so one named without a
* directory is refused.
*/
-static char *resolve_about_path(const char *filename, const char *ref,
- const char *path)
+static char *resolve_about_path(const char *filename, const char *ref, const char *path)
{
char *copy, *base_dir, *full_path;
char *resolved_base = NULL, *resolved_full = NULL;
@@ -91,8 +89,7 @@ static char *resolve_about_path(const char *filename, const char *ref,
if (!ref) {
resolved_base = realpath(base_dir, NULL);
resolved_full = realpath(full_path, NULL);
- if (!resolved_base || !resolved_full ||
- !path_within(resolved_base, resolved_full)) {
+ if (!resolved_base || !resolved_full || !path_within(resolved_base, resolved_full)) {
free(full_path);
full_path = NULL;
}
@@ -116,8 +113,7 @@ void cgit_print_summary(void)
cgit_print_tags(ctx.cfg.summary_tags);
if (ctx.cfg.summary_log > 0) {
htmlf("<tr class='nohover'><td colspan='%d'></td></tr>\n", columns);
- cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
- NULL, NULL, 0, 0, 0);
+ cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, NULL, NULL, 0, 0, 0);
}
clone_urls_printed = 0;
cgit_add_clone_urls(print_clone_url);
@@ -131,8 +127,7 @@ void cgit_print_repo_readme(const char *path)
int free_filename = 0;
mimetype = cgit_get_mimetype_for_filename(path);
- if (mimetype && (starts_with(mimetype, "image/") ||
- starts_with(mimetype, "video/"))) {
+ if (mimetype && (starts_with(mimetype, "image/") || starts_with(mimetype, "video/"))) {
ctx.page.mimetype = mimetype;
ctx.page.charset = NULL;
cgit_print_plain();
diff --git a/source/ui-tag.c b/source/ui-tag.c
index 469f209..ec8cd54 100644
--- a/source/ui-tag.c
+++ b/source/ui-tag.c
@@ -55,17 +55,14 @@ static void print_message(char *msg)
}
}
-static void print_annotated_tag(const char *revname,
- const struct object_id *oid)
+static void print_annotated_tag(const char *revname, const struct object_id *oid)
{
struct tag *tag;
struct taginfo *info;
tag = lookup_tag(the_repository, oid);
- if (!tag || parse_tag(the_repository, tag) ||
- !(info = cgit_parse_tag(tag))) {
- cgit_print_error_page(500, "Internal Server Error",
- "Bad tag object: %s", revname);
+ if (!tag || parse_tag(the_repository, tag) || !(info = cgit_parse_tag(tag))) {
+ cgit_print_error_page(500, "Internal Server Error", "Bad tag object: %s", revname);
return;
}
@@ -76,20 +73,16 @@ static void print_annotated_tag(const char *revname,
htmlf(" (<span class='oid'>%s</span>)</td></tr>\n", oid_to_hex(oid));
if (info->tagger_date > 0) {
html("<tr><th>tag date</th><td><time datetime='");
- html_attr(show_date(info->tagger_date, info->tagger_tz,
- cgit_date_mode(DATE_ISO8601_STRICT)));
+ html_attr(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601_STRICT)));
html("'>");
- html_txt(show_date(info->tagger_date, info->tagger_tz,
- cgit_date_mode(DATE_ISO8601)));
+ html_txt(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601)));
html("</time></td></tr>\n");
}
if (info->tagger) {
html("<tr><th>tagged by</th><td>");
// A tag can carry a tagger with no address, and a filter must
// not be handed a NULL argument.
- cgit_open_filter(ctx.repo->email_filter,
- info->tagger_email ? info->tagger_email : "",
- "tag");
+ cgit_open_filter(ctx.repo->email_filter, info->tagger_email ? info->tagger_email : "", "tag");
html_txt(info->tagger);
if (info->tagger_email && ctx.cfg.enable_plain_email) {
html(" ");
@@ -132,14 +125,12 @@ void cgit_print_tag(char *revname)
strbuf_addf(&fullref, "refs/tags/%s", revname);
if (repo_get_oid(the_repository, fullref.buf, &oid)) {
- cgit_print_error_page(404, "Not Found",
- "Bad tag reference: %s", revname);
+ cgit_print_error_page(404, "Not Found", "Bad tag reference: %s", revname);
goto cleanup;
}
obj = parse_object(the_repository, &oid);
if (!obj) {
- cgit_print_error_page(500, "Internal Server Error",
- "Bad object id: %s", oid_to_hex(&oid));
+ cgit_print_error_page(500, "Internal Server Error", "Bad object id: %s", oid_to_hex(&oid));
goto cleanup;
}
if (obj->type == OBJ_TAG)
diff --git a/source/ui-tree.c b/source/ui-tree.c
index 26a3fd1..aab448e 100644
--- a/source/ui-tree.c
+++ b/source/ui-tree.c
@@ -82,8 +82,7 @@ static void print_linenumbers(const char *buf, unsigned long size)
strbuf_release(&numbers);
}
-static void print_text_buffer(const char *filename, char *buf,
- unsigned long size)
+static void print_text_buffer(const char *filename, char *buf, unsigned long size)
{
html("<table class='blob'>\n");
@@ -131,8 +130,7 @@ static void print_binary_buffer(char *buf, unsigned long size)
html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>\n");
// A row goes out in one write rather than a write per byte.
- for (offset = 0; offset < size;
- offset += HEXDUMP_ROW_BYTES, buf += HEXDUMP_ROW_BYTES) {
+ for (offset = 0; offset < size; offset += HEXDUMP_ROW_BYTES, buf += HEXDUMP_ROW_BYTES) {
strbuf_reset(&row);
strbuf_addf(&row, "<tr><td class='right'>%04lx</td><td class='hex'>", offset);
for (idx = 0; idx < HEXDUMP_ROW_BYTES && offset + idx < size; idx++) {
@@ -159,7 +157,7 @@ static void print_binary_buffer(char *buf, unsigned long size)
* may be added to it.
*/
static bool print_object(const struct object_id *oid, const char *path,
- const char *filename, const char *rev)
+ const char *filename, const char *rev)
{
enum object_type type;
char *buf;
@@ -168,22 +166,21 @@ static bool print_object(const struct object_id *oid, const char *path,
type = odb_read_object_info(the_repository->objects, oid, &size);
if (type == OBJ_BAD) {
- cgit_print_error_page(404, "Not Found",
- "Bad object name: %s", oid_to_hex(oid));
+ cgit_print_error_page(404, "Not Found", "Bad object name: %s", oid_to_hex(oid));
return false;
}
if (ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size) {
- cgit_print_error_page(413, "Content Too Large",
- "blob size (%luKB) exceeds display size limit (%dKB)",
- size / 1024, ctx.cfg.max_blob_size);
+ cgit_print_error_page(
+ 413, "Content Too Large", "blob size (%luKB) exceeds display size limit (%dKB)",
+ size / 1024, ctx.cfg.max_blob_size
+ );
return false;
}
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf) {
- cgit_print_error_page(500, "Internal Server Error",
- "Error reading object %s", oid_to_hex(oid));
+ cgit_print_error_page(500, "Internal Server Error", "Error reading object %s", oid_to_hex(oid));
return false;
}
// buffer_is_binary only sniffs the front of the blob, and a NUL past
@@ -195,12 +192,10 @@ static bool print_object(const struct object_id *oid, const char *path,
cgit_print_layout_start();
htmlf("blob: %s (", oid_to_hex(oid));
- cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
- rev, path);
+ cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path);
if (ctx.repo->enable_blame && !is_binary) {
html(") (");
- cgit_blame_link("blame", NULL, NULL, ctx.qry.head,
- rev, path);
+ cgit_blame_link("blame", NULL, NULL, ctx.qry.head, rev, path);
}
html(")\n");
@@ -214,7 +209,7 @@ static bool print_object(const struct object_id *oid, const char *path,
}
static int only_child_cb(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *data)
+ const char *pathname, unsigned mode, void *data)
{
struct only_child *child = data;
@@ -232,8 +227,8 @@ static int only_child_cb(const struct object_id *oid, struct strbuf *base,
return 0;
}
-static void print_dir_chain(const struct object_id *oid, char *name,
- char *rev, struct strbuf *fullpath)
+static void print_dir_chain(const struct object_id *oid, char *name, char *rev,
+ struct strbuf *fullpath)
{
size_t initial_length = fullpath->len;
struct tree *tree;
@@ -248,8 +243,7 @@ static void print_dir_chain(const struct object_id *oid, char *name,
oidcpy(&child.oid, oid);
while (child.count == 1) {
- cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev,
- fullpath->buf);
+ cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, fullpath->buf);
tree = lookup_tree(the_repository, &child.oid);
if (!tree)
@@ -272,7 +266,7 @@ static void print_dir_chain(const struct object_id *oid, char *name,
}
static void print_ls_row(const struct object_id *oid, const char *pathname,
- unsigned mode, struct walk_tree_context *walk)
+ unsigned mode, struct walk_tree_context *walk)
{
char *name;
struct strbuf fullpath = STRBUF_INIT;
@@ -283,8 +277,7 @@ static void print_ls_row(const struct object_id *oid, const char *pathname,
char *buf;
name = xstrdup(pathname);
- strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "",
- ctx.qry.path ? "/" : "", name);
+ strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "", ctx.qry.path ? "/" : "", name);
if (!S_ISGITLINK(mode)) {
type = odb_read_object_info(the_repository->objects, oid, &size);
@@ -310,8 +303,7 @@ static void print_ls_row(const struct object_id *oid, const char *pathname,
strbuf_addstr(&class, "ls-blob");
if (ext)
strbuf_addf(&class, " %s", ext + 1);
- cgit_tree_link(name, NULL, class.buf, ctx.qry.head,
- walk->rev, fullpath.buf);
+ cgit_tree_link(name, NULL, class.buf, ctx.qry.head, walk->rev, fullpath.buf);
}
if (S_ISLNK(mode)) {
html(" -> ");
@@ -323,8 +315,7 @@ static void print_ls_row(const struct object_id *oid, const char *pathname,
strbuf_addbuf(&linkpath, &fullpath);
strbuf_addf(&linkpath, "/../%s", buf);
strbuf_normalize_path(&linkpath);
- cgit_tree_link(buf, NULL, class.buf, ctx.qry.head,
- walk->rev, linkpath.buf);
+ cgit_tree_link(buf, NULL, class.buf, ctx.qry.head, walk->rev, linkpath.buf);
free(buf);
strbuf_release(&linkpath);
}
@@ -334,18 +325,14 @@ static void print_ls_row(const struct object_id *oid, const char *pathname,
htmlf("</td><td class='ls-size'>%lu</td>", size);
html("<td class='ls-links'>");
- cgit_log_link("log", NULL, "button", ctx.qry.head,
- walk->rev, fullpath.buf, 0, NULL, NULL,
- ctx.qry.showmsg, 0);
+ cgit_log_link("log", NULL, "button", ctx.qry.head, walk->rev, fullpath.buf,
+ 0, NULL, NULL, ctx.qry.showmsg, 0);
if (ctx.repo->max_stats)
- cgit_stats_link("stats", NULL, "button", ctx.qry.head,
- fullpath.buf);
+ cgit_stats_link("stats", NULL, "button", ctx.qry.head, fullpath.buf);
if (!S_ISGITLINK(mode))
- cgit_plain_link("plain", NULL, "button", ctx.qry.head,
- walk->rev, fullpath.buf);
+ cgit_plain_link("plain", NULL, "button", ctx.qry.head, walk->rev, fullpath.buf);
if (!S_ISDIR(mode) && !S_ISGITLINK(mode) && ctx.repo->enable_blame)
- cgit_blame_link("blame", NULL, "button", ctx.qry.head,
- walk->rev, fullpath.buf);
+ cgit_blame_link("blame", NULL, "button", ctx.qry.head, walk->rev, fullpath.buf);
html("</td></tr>\n");
cleanup:
@@ -355,7 +342,7 @@ cleanup:
}
static int ls_item(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *data)
+ const char *pathname, unsigned mode, void *data)
{
struct walk_tree_context *walk = data;
@@ -364,8 +351,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
if (ctx.cfg.enable_tree_group_dirs) {
struct ls_entry *entry;
- ALLOC_GROW(walk->entries, walk->entries_nr + 1,
- walk->entries_alloc);
+ ALLOC_GROW(walk->entries, walk->entries_nr + 1, walk->entries_alloc);
entry = &walk->entries[walk->entries_nr++];
oidcpy(&entry->oid, oid);
entry->name = xstrdup(pathname);
@@ -419,8 +405,7 @@ static void ls_tail(void)
cgit_print_layout_end();
}
-static void ls_tree(const struct object_id *oid,
- struct walk_tree_context *walk)
+static void ls_tree(const struct object_id *oid, struct walk_tree_context *walk)
{
struct tree *tree;
struct pathspec paths = {
@@ -429,8 +414,7 @@ static void ls_tree(const struct object_id *oid,
tree = parse_tree_indirect(oid);
if (!tree) {
- cgit_print_error_page(404, "Not Found",
- "Not a tree object: %s", oid_to_hex(oid));
+ cgit_print_error_page(404, "Not Found", "Not a tree object: %s", oid_to_hex(oid));
return;
}
@@ -441,7 +425,7 @@ static void ls_tree(const struct object_id *oid,
}
static int walk_tree(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *data)
+ const char *pathname, unsigned mode, void *data)
{
struct walk_tree_context *walk = data;
@@ -460,8 +444,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base,
ls_head();
return READ_TREE_RECURSIVE;
} else {
- bool shown = print_object(oid, fullpath.buf,
- pathname, walk->rev);
+ bool shown = print_object(oid, fullpath.buf, pathname, walk->rev);
walk->state = shown ? WALK_BLOB_SHOWN : WALK_ERROR_SHOWN;
strbuf_release(&fullpath);
@@ -499,14 +482,12 @@ void cgit_print_tree(const char *rev, char *path)
rev = ctx.qry.head;
if (repo_get_oid(the_repository, rev, &oid)) {
- cgit_print_error_page(404, "Not Found",
- "Invalid revision name: %s", rev);
+ cgit_print_error_page(404, "Not Found", "Invalid revision name: %s", rev);
return;
}
commit = lookup_commit_reference(the_repository, &oid);
if (!commit || repo_parse_commit(the_repository, commit)) {
- cgit_print_error_page(404, "Not Found",
- "Invalid commit reference: %s", rev);
+ cgit_print_error_page(404, "Not Found", "Invalid commit reference: %s", rev);
return;
}
@@ -517,8 +498,7 @@ void cgit_print_tree(const char *rev, char *path)
goto cleanup;
}
- read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
- &paths, walk_tree, &walk);
+ read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
if (walk.state == WALK_LISTING) {
ls_flush(&walk);
ls_tail();