diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Clean up the whole tree
Diffstat (limited to 'source/shared.c')
| -rw-r--r-- | source/shared.c | 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 17 insertions, 30 deletions
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) |
