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 'source/ui-snapshot.c')
-rw-r--r--source/ui-snapshot.c51
1 file changed, 18 insertions, 33 deletions
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;
}