Diff options
Diffstat (limited to '')
| -rw-r--r-- | source/shared.h | 71 |
1 file changed, 15 insertions, 56 deletions
diff --git a/source/shared.h b/source/shared.h index 2bf305d..302b752 100644 --- a/source/shared.h +++ b/source/shared.h @@ -1,9 +1,8 @@ /* - * The helpers that belong to no single page. Repository registration, the - * lifetimes of the reference and commit records the renderers build, thin - * wrappers over git's diff machinery, and a handful of string, date and - * mimetype utilities all live here because several renderers need them. The - * two process-wide globals, ctx and cgit_repolist, are defined here as well. + * The helpers that more than one file needs. Repository registration and thin + * wrappers over git's diff machinery make up most of it, beside a few string + * and request checks. The two process-wide globals, ctx and cgit_repolist, + * are defined here as well. */ #ifndef CGIT_SHARED_H @@ -17,14 +16,6 @@ typedef void (*filepair_fn)(struct diff_filepair *pair); typedef void (*linediff_fn)(char *line, int len); /* - * Each of these returns its argument untouched when the syscall it wraps - * succeeded, and dies with the message and errno otherwise. - */ -extern int cgit_die_unless_zero(int result, const char *msg); -extern int cgit_die_unless_positive(int result, const char *msg); -extern int cgit_die_unless_non_negative(int result, const char *msg); - -/* * Append a repository to cgit_repolist and return it, seeded from the current * global configuration. The returned pointer is invalidated by the next call, * because the list grows by reallocation. @@ -33,22 +24,6 @@ extern struct cgit_repo *cgit_add_repo(const char *url); extern struct cgit_repo *cgit_get_repoinfo(const char *url); /* - * Export the CGIT_REPO_* variables that filters and hooks read. - */ -extern void cgit_prepare_repo_env(struct cgit_repo *repo); - -extern void cgit_free_reflist_inner(struct reflist *list); - -/* - * Matches git's reference iteration callback, and appends each ref it is given - * to the struct reflist passed as cb_data. - */ -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); - -/* * A diff format callback that hands each filepair to the filepair_fn data * points at. ISO C has no conversion between a function pointer and void *, * so the function travels by address. @@ -66,13 +41,6 @@ extern int cgit_diff_files(const struct object_id *old_oid, const struct object_ linediff_fn fn); /* - * Whether a blob of size bytes is past max-blob-size. Callers ask before - * reading the object, so a huge blob stays out of memory rather than being - * noticed once it is already there. - */ -extern int cgit_blob_too_large(size_t size); - -/* * Limit a diff to the paths below prefix, which is taken literally. */ extern void cgit_diff_limit_path(struct diff_options *opt, const char *prefix); @@ -82,23 +50,28 @@ extern void cgit_diff_tree(const struct object_id *old_oid, const struct object_ 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. + * Whether a blob of size bytes is past max-blob-size. Callers ask before + * reading the object, so a huge blob stays out of memory rather than being + * noticed once it is already there. + */ +extern int cgit_blob_too_large(size_t size); + +/* + * Point ps at item alone, set to match path literally rather than as a glob, + * or at no item when path is NULL, which leaves every path matching. */ -extern void cgit_parse_date_format(const char *format, struct date_mode *mode); +extern void cgit_literal_pathspec(struct pathspec *ps, struct pathspec_item *item, const char *path); /* * Copy str without its trailing runs of c, returning NULL if nothing is left. */ extern char *cgit_trim_end(const char *str, char c); -extern char *cgit_ensure_end(const char *str, char c); -extern void strbuf_ensure_end(struct strbuf *sb, char c); /* * Read the first line of a file into a newly allocated, zero terminated * buffer. Returns 0 on success and an errno value otherwise. */ -extern int cgit_read_first_line(const char *path, char **buf, size_t *size); +extern int cgit_read_first_line(const char *path, char **buf); extern char *cgit_strdup_first_line(const char *text); /* @@ -119,8 +92,6 @@ extern void cgit_utf8_sanitize(char *text); */ extern char *cgit_expand_macros(const char *text); -extern char *cgit_get_mimetype_for_filename(const char *filename); - /* * Whether a readme setting names a file tracked in the repository, written * as ref:path or :path, rather than a file on the server's disk. @@ -140,16 +111,4 @@ extern int cgit_valid_rev(const char *rev); */ extern int cgit_notes_ref_usable(const char *notes_ref); -/* - * qsort for a list that may be empty. C leaves a null base undefined even - * with nothing to sort, and glibc declares it nonnull, while the lists here - * stay null until their first entry. - */ -static inline void cgit_qsort(void *base, size_t n, size_t size, - int (*cmp)(const void *, const void *)) -{ - if (n) - qsort(base, n, size, cmp); -} - #endif // CGIT_SHARED_H |
