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-blob.c')
-rw-r--r--source/ui-blob.c31
1 file changed, 11 insertions, 20 deletions
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;
}