gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

commit a91b9003c3250f5a929b11e5b8716e226887b7d1
parent e4115c025e0f46eaf3caa78e75b9a85a65c795d2
Author: Chris Bracken <chris@bracken.jp>
Date:   Sat, 26 Jul 2025 07:34:46 -0700

Rename from gitout to gout

There are too many git-related tools named gitout. As far as I can tell,
there are no git-related tools named gout, probably for obvious reasons.

Diffstat:
MBUILD.gn | 54+++++++++++++++++++++++++++---------------------------
MMakefile | 6+++---
MREADME.md | 22+++++++++++-----------
Mformat.h | 6+++---
Mformat_tests.c | 8++++----
Mgit/BUILD.gn | 4++--
Mgit/commit.h | 6+++---
Mgit/delta.h | 6+++---
Mgit/file.h | 6+++---
Mgit/git.c | 4++--
Mgit/git.h | 10+++++-----
Mgit/internal.h | 6+++---
Mgit/reference.h | 6+++---
Mgit/repo.c | 14+++++---------
Mgit/repo.h | 6+++---
Dgitout.c | 166-------------------------------------------------------------------------------
Dgitout.h | 12------------
Dgitout_index.c | 93-------------------------------------------------------------------------------
Dgitout_index.h | 12------------
Dgitout_index_main.c | 21---------------------
Dgitout_main.c | 23-----------------------
Dgitout_tests.c | 17-----------------
Agout.c | 166+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agout.h | 12++++++++++++
Agout_index.c | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agout_index.h | 12++++++++++++
Agout_index_main.c | 21+++++++++++++++++++++
Agout_main.c | 23+++++++++++++++++++++++
Agout_tests.c | 17+++++++++++++++++
Rgitout_tests_main.c -> gout_tests_main.c | 0
Msecurity.c | 6+++---
Msecurity.h | 12++++++------
Mutils.h | 6+++---
Mwriter/BUILD.gn | 4++--
Mwriter/atom/BUILD.gn | 2+-
Mwriter/atom/atom.h | 6+++---
Mwriter/cache/BUILD.gn | 2+-
Mwriter/cache/cache.h | 6+++---
Mwriter/gopher/BUILD.gn | 4++--
Mwriter/gopher/commit.h | 6+++---
Mwriter/gopher/fileblob.h | 6+++---
Mwriter/gopher/files.h | 6+++---
Mwriter/gopher/index_writer.h | 6+++---
Mwriter/gopher/log.h | 6+++---
Mwriter/gopher/page.h | 6+++---
Mwriter/gopher/refs.h | 6+++---
Mwriter/gopher/repo_index.h | 6+++---
Mwriter/gopher/repo_writer.h | 6+++---
Mwriter/html/BUILD.gn | 4++--
Mwriter/html/commit.h | 6+++---
Mwriter/html/fileblob.h | 6+++---
Mwriter/html/files.h | 6+++---
Mwriter/html/index_writer.h | 6+++---
Mwriter/html/log.h | 6+++---
Mwriter/html/page.h | 6+++---
Mwriter/html/refs.h | 6+++---
Mwriter/html/repo_index.h | 6+++---
Mwriter/html/repo_writer.h | 6+++---
Mwriter/index_writer.h | 6+++---
Mwriter/repo_writer.h | 6+++---
60 files changed, 510 insertions(+), 514 deletions(-)

diff --git a/BUILD.gn b/BUILD.gn @@ -1,5 +1,5 @@ # TODO(cbracken): remove personal include, lib dirs. -config("gitout_config") { +config("gout_config") { include_dirs = [ "//" ] + system_include_dirs lib_dirs = [] + system_lib_dirs defines = [ @@ -31,38 +31,38 @@ config("gitout_config") { group("default") { testonly = true deps = [ - ":gitout", - ":gitout_index", - ":gitout_tests", + ":gout", + ":gout_index", + ":gout_tests", ] } -executable("gitout") { - sources = [ "gitout_main.c" ] - configs += [ ":gitout_config" ] +executable("gout") { + sources = [ "gout_main.c" ] + configs += [ ":gout_config" ] deps = [ ":format", - ":gitout_srcs", + ":gout_srcs", ":utils", ] } -executable("gitout_index") { - sources = [ "gitout_index_main.c" ] - configs += [ ":gitout_config" ] - deps = [ ":gitout_index_srcs" ] +executable("gout_index") { + sources = [ "gout_index_main.c" ] + configs += [ ":gout_config" ] + deps = [ ":gout_index_srcs" ] } -executable("gitout_tests") { +executable("gout_tests") { testonly = true sources = [ "format_tests.c", - "gitout_tests.c", - "gitout_tests_main.c", + "gout_tests.c", + "gout_tests_main.c", "utils_tests.c", ] deps = [ - ":gitout_srcs", + ":gout_srcs", "//third_party/utest:utest_headers", ] } @@ -72,15 +72,15 @@ source_set("format") { "format.c", "format.h", ] - configs += [ ":gitout_config" ] + configs += [ ":gout_config" ] } -source_set("gitout_index_srcs") { +source_set("gout_index_srcs") { sources = [ - "gitout_index.c", - "gitout_index.h", + "gout_index.c", + "gout_index.h", ] - configs += [ ":gitout_config" ] + configs += [ ":gout_config" ] deps = [ ":security", "//git", @@ -88,12 +88,12 @@ source_set("gitout_index_srcs") { ] } -source_set("gitout_srcs") { +source_set("gout_srcs") { sources = [ - "gitout.c", - "gitout.h", + "gout.c", + "gout.h", ] - configs += [ ":gitout_config" ] + configs += [ ":gout_config" ] deps = [ ":security", "//git", @@ -106,7 +106,7 @@ source_set("security") { "security.c", "security.h", ] - configs += [ ":gitout_config" ] + configs += [ ":gout_config" ] } source_set("utils") { @@ -114,6 +114,6 @@ source_set("utils") { "utils.c", "utils.h", ] - configs += [ ":gitout_config" ] + configs += [ ":gout_config" ] deps = [ "//third_party/openbsd" ] } diff --git a/Makefile b/Makefile @@ -1,6 +1,6 @@ .POSIX: -NAME = gitout +NAME = gout VERSION = 0.1 all: debug release @@ -15,8 +15,8 @@ release: test: gn gen --args="is_debug=true" out/debug - ninja -C out/debug ":gitout_tests" - out/debug/gitout_tests + ninja -C out/debug ":gout_tests" + out/debug/gout_tests clean: rm -rf out diff --git a/README.md b/README.md @@ -1,7 +1,7 @@ -gitout -====== +gout +==== -Gitout is a static git repository builder designed to be output-compatible with +`gout` is a static git repository builder designed to be output-compatible with the excellent `stagit` tool, but adds support for multiple output formats in the same binary: html (-H) and gopher (-G). @@ -36,8 +36,8 @@ Next, generate the ninja build files under the `out` directory: To build and run the unit tests, run: gn gen --args=is_debug=true out/debug - ninja -C out/debug :gitout_tests - ./out/debug/gitout_tests + ninja -C out/debug :gout_tests + ./out/debug/gout_tests or @@ -49,21 +49,21 @@ or To build and run the binary: gn gen --args=is_debug=false out/release - ninja -C out/release :gitout :gitout_index - ./out/release/gitout - ./out/release/gitout_index + ninja -C out/release :gout :gout_index + ./out/release/gout + ./out/release/gout_index or make release - ./out/release/gitout - ./out/release/gitout_index + ./out/release/gout + ./out/release/gout_index Background ---------- -Gitout started as a set of small refactorings of stagit written primarily to +`gout` started as a set of small refactorings of `stagit` written primarily to separate git logic from formatting logic in order to experiment with merging gopher support into the same tool, and eventually add gemini support. Things got a bit out of hand and I'm embarrassed to say the code now reads a bit more like diff --git a/format.h b/format.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_FORMAT_H_ -#define GITOUT_FORMAT_H_ +#ifndef GOUT_FORMAT_H_ +#define GOUT_FORMAT_H_ #include <stdbool.h> #include <stdio.h> @@ -44,4 +44,4 @@ void print_gopher_link_padded(FILE* out, size_t width, char pad_char); -#endif // GITOUT_FORMAT_H_ +#endif // GOUT_FORMAT_H_ diff --git a/format_tests.c b/format_tests.c @@ -1,7 +1,7 @@ #include "format.h" -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> #include <time.h> #include "utest.h" @@ -14,7 +14,7 @@ UTEST(print_time, PositiveOffset) { /* Test time: 2023-12-08 10:30:00 UTC */ time_t test_time = 1702031400; - int timezone_offset = 540; /* +09:00 */ + int timezone_offset = 540; /* +09:00 */ print_time(out, test_time, timezone_offset); fclose(out); @@ -32,7 +32,7 @@ UTEST(print_time, NegativeOffset) { /* Test time: 2023-12-08 10:30:00 UTC */ time_t test_time = 1702031400; - int timezone_offset = -300; /* -05:00 */ + int timezone_offset = -300; /* -05:00 */ print_time(out, test_time, timezone_offset); fclose(out); @@ -50,7 +50,7 @@ UTEST(print_time, ZeroOffset) { /* Test time: 2023-12-08 10:30:00 UTC */ time_t test_time = 1702031400; - int timezone_offset = 0; /* UTC */ + int timezone_offset = 0; /* UTC */ print_time(out, test_time, timezone_offset); fclose(out); diff --git a/git/BUILD.gn b/git/BUILD.gn @@ -1,7 +1,7 @@ source_set("internal") { visibility = [ ":*" ] sources = [ "internal.h" ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] include_dirs = [ "//git" ] } @@ -20,7 +20,7 @@ source_set("git") { "repo.c", "repo.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ ":internal", "//:utils", diff --git a/git/commit.h b/git/commit.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_GIT_COMMIT_H_ -#define GITOUT_GIT_COMMIT_H_ +#ifndef GOUT_GIT_COMMIT_H_ +#define GOUT_GIT_COMMIT_H_ #include <time.h> @@ -55,4 +55,4 @@ size_t gitcommit_delcount(const GitCommit* commit); /* Returns the sum of files modified across all deltas in this commit. */ size_t gitcommit_filecount(const GitCommit* commit); -#endif // GITOUT_GIT_COMMIT_H_ +#endif // GOUT_GIT_COMMIT_H_ diff --git a/git/delta.h b/git/delta.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_GIT_DELTA_H_ -#define GITOUT_GIT_DELTA_H_ +#ifndef GOUT_GIT_DELTA_H_ +#define GOUT_GIT_DELTA_H_ #include <stdbool.h> #include <stddef.h> @@ -33,4 +33,4 @@ size_t gitdelta_hunk_count(const GitDelta* delta); char* gitdelta_added_graph(const GitDelta* delta, size_t max_width); char* gitdelta_deleted_graph(const GitDelta* delta, size_t max_width); -#endif // GITOUT_GIT_DELTA_H_ +#endif // GOUT_GIT_DELTA_H_ diff --git a/git/file.h b/git/file.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_GIT_FILE_H_ -#define GITOUT_GIT_FILE_H_ +#ifndef GOUT_GIT_FILE_H_ +#define GOUT_GIT_FILE_H_ #include <sys/types.h> @@ -22,4 +22,4 @@ ssize_t gitfile_size_bytes(const GitFile* file); ssize_t gitfile_size_lines(const GitFile* file); const char* gitfile_content(const GitFile* file); -#endif // GITOUT_GIT_FILE_H_ +#endif // GOUT_GIT_FILE_H_ diff --git a/git/git.c b/git/git.c @@ -8,7 +8,7 @@ /* Global const data. */ const size_t kOidLen = GIT_OID_SHA1_HEXSIZE + 1; -void gitout_git_initialize(void) { +void gout_git_initialize(void) { /* do not search outside the git repository: GIT_CONFIG_LEVEL_APP is the highest level currently */ git_libgit2_init(); @@ -19,6 +19,6 @@ void gitout_git_initialize(void) { git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 0); } -void gitout_git_shutdown(void) { +void gout_git_shutdown(void) { git_libgit2_shutdown(); } diff --git a/git/git.h b/git/git.h @@ -1,11 +1,11 @@ -#ifndef GITOUT_GIT_GIT_H_ -#define GITOUT_GIT_GIT_H_ +#ifndef GOUT_GIT_GIT_H_ +#define GOUT_GIT_GIT_H_ #include <stddef.h> extern const size_t kOidLen; -void gitout_git_initialize(void); -void gitout_git_shutdown(void); +void gout_git_initialize(void); +void gout_git_shutdown(void); -#endif // GITOUT_GIT_GIT_H_ +#endif // GOUT_GIT_GIT_H_ diff --git a/git/internal.h b/git/internal.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_GIT_INTERNAL_H_ -#define GITOUT_GIT_INTERNAL_H_ +#ifndef GOUT_GIT_INTERNAL_H_ +#define GOUT_GIT_INTERNAL_H_ #include <git2.h> @@ -28,4 +28,4 @@ GitReference* gitreference_create(git_repository* repo, git_reference* ref); void gitreference_free(GitReference* ref); int gitreference_compare(const void* r1, const void* r2); -#endif // GITOUT_GIT_INTERNAL_H_ +#endif // GOUT_GIT_INTERNAL_H_ diff --git a/git/reference.h b/git/reference.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_GIT_REFERENCE_H_ -#define GITOUT_GIT_REFERENCE_H_ +#ifndef GOUT_GIT_REFERENCE_H_ +#define GOUT_GIT_REFERENCE_H_ #include "git/commit.h" @@ -15,4 +15,4 @@ RefType gitreference_type(const GitReference* ref); const char* gitreference_shorthand(const GitReference* ref); GitCommit* gitreference_commit(const GitReference* ref); -#endif // GITOUT_GIT_REFERENCE_H_ +#endif // GOUT_GIT_REFERENCE_H_ diff --git a/git/repo.c b/git/repo.c @@ -259,11 +259,9 @@ GitRepo* gitrepo_create(const char* path) { repo->owner = first_line_of_file(owner_path); repo->description = first_line_of_file(desc_path); repo->clone_url = first_line_of_file(url_path); - repo->submodules = gitrepo_has_blob(repo->repo, "HEAD:.gitmodules") - ? ".gitmodules" - : ""; - repo->readme = - gitrepo_first_matching_file(repo->repo, kReadmes, kReadmesLen); + repo->submodules = + gitrepo_has_blob(repo->repo, "HEAD:.gitmodules") ? ".gitmodules" : ""; + repo->readme = gitrepo_first_matching_file(repo->repo, kReadmes, kReadmesLen); repo->license = gitrepo_first_matching_file(repo->repo, kLicenses, kLicensesLen); return repo; @@ -458,7 +456,7 @@ bool gitrepo_walk_tree_files(git_repository* repo, const char* content = ""; if (size_bytes > kMaxFileSizeBytes) { - size_lines = -2; /* oversized file */ + size_lines = -2; /* oversized file */ } else if (!git_blob_is_binary(blob)) { content = (const char*)git_blob_rawcontent(blob); size_lines = string_count_lines(content, size_bytes); @@ -477,9 +475,7 @@ bool gitrepo_walk_tree_files(git_repository* repo, return true; } -void gitrepo_for_each_file(GitRepo* repo, - FileCallback cb, - void* user_data) { +void gitrepo_for_each_file(GitRepo* repo, FileCallback cb, void* user_data) { git_commit* commit = NULL; const git_oid* id = oid_for_spec(repo->repo, "HEAD"); if (git_commit_lookup(&commit, repo->repo, id) != 0) { diff --git a/git/repo.h b/git/repo.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_GIT_REPO_H_ -#define GITOUT_GIT_REPO_H_ +#ifndef GOUT_GIT_REPO_H_ +#define GOUT_GIT_REPO_H_ #include "git/commit.h" #include "git/file.h" @@ -35,4 +35,4 @@ void gitrepo_for_each_reference(GitRepo* repo, typedef void (*FileCallback)(const GitFile* file, void* user_data); void gitrepo_for_each_file(GitRepo* repo, FileCallback cb, void* user_data); -#endif // GITOUT_GIT_REPO_H_ +#endif // GOUT_GIT_REPO_H_ diff --git a/gitout.c b/gitout.c @@ -1,166 +0,0 @@ -#include "gitout.h" - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> - -#include "git/commit.h" -#include "git/file.h" -#include "git/git.h" -#include "git/reference.h" -#include "git/repo.h" -#include "security.h" -#include "utils.h" -#include "writer/repo_writer.h" - -struct GitoutOptions { - const char* repodir; - long long log_commit_limit; /* -1 indicates not used */ - const char* cachefile_path; - const char* baseurl; /* base URL to make absolute RSS/Atom URI */ - RepoWriterType writer_type; -}; - -static void commit_callback(const GitCommit* commit, void* user_data); -static void reference_callback(const GitReference* ref, void* user_data); -static void file_callback(const GitFile* file, void* user_data); - -GitoutOptions* gitout_options_create(int argc, const char* argv[]) { - GitoutOptions options = { - .repodir = NULL, - .log_commit_limit = -1, - .cachefile_path = NULL, - .baseurl = "", - .writer_type = kRepoWriterTypeHtml, - }; - for (int i = 1; i < argc; i++) { - if (argv[i][0] != '-') { - // Cannot specify more than one repo directory. - if (options.repodir) { - return NULL; - } - options.repodir = argv[i]; - } else if (argv[i][1] == 'c') { - // Cache the entries of the log page up to the point of the last commit. - // The cachefile will store the last commit id and the entries in the - // HTML table. It is up to the user to make sure the state of the - // cachefile is in sync with the history of the repository. - - // Mutually exclusive with -l. - if (options.log_commit_limit > 0) { - return NULL; - } - // Requires cachefile path argument. - if (i + 1 >= argc) { - return NULL; - } - options.cachefile_path = argv[++i]; - } else if (argv[i][1] == 'l') { - // Write a maximum number of commits to the log.html file only. However - // the commit files are written as usual. - - // Mutually exclusive with -c option. - if (options.cachefile_path) { - return NULL; - } - // Requires log commits argument. - if (i + 1 >= argc) { - return NULL; - } - errno = 0; - char* p; - options.log_commit_limit = strtoll(argv[++i], &p, 10); - if (!argv[i][0] || *p || options.log_commit_limit <= 0 || errno) { - return NULL; - } - } else if (argv[i][1] == 'u') { - // Requires log commits argument. - if (i + 1 >= argc) { - return NULL; - } - options.baseurl = argv[++i]; - } else if (argv[i][1] == 'H') { - options.writer_type = kRepoWriterTypeHtml; - } else if (argv[i][1] == 'G') { - options.writer_type = kRepoWriterTypeGopher; - } - } - // Must specify at least one repo directory. - if (!options.repodir) { - return NULL; - } - GitoutOptions* options_out = ecalloc(1, sizeof(GitoutOptions)); - *options_out = options; - return options_out; -} - -void gitout_options_free(GitoutOptions* options) { - if (!options) { - return; - } - options->repodir = NULL; - options->log_commit_limit = -1; - options->cachefile_path = NULL; - options->baseurl = NULL; - free(options); -} - -void gitout_init(const GitoutOptions* options) { - // Restrict our permissions to the minimum necessary. - const char* readonly_paths[] = {options->repodir}; - size_t readonly_paths_count = 1; - const char* readwrite_paths[2] = {".", NULL}; - size_t readwrite_paths_count = 1; - if (options->cachefile_path) { - readwrite_paths[1] = options->cachefile_path; - readwrite_paths_count = 2; - } - restrict_filesystem_access(readonly_paths, readonly_paths_count, - readwrite_paths, readwrite_paths_count); - restrict_system_operations( - options->cachefile_path != NULL ? kGitoutWithCachefile : kGitout); - - gitout_git_initialize(); -} - -void gitout_run(const GitoutOptions* options) { - GitRepo* repo = gitrepo_create(options->repodir); - RepoWriter* writer = repowriter_create(options->writer_type, repo); - if (options->log_commit_limit >= 0) { - repowriter_set_log_commit_limit(writer, options->log_commit_limit); - } - if (options->cachefile_path) { - repowriter_set_log_cachefile(writer, options->cachefile_path); - } - if (options->baseurl) { - repowriter_set_baseurl(writer, options->baseurl); - } - - repowriter_begin(writer); - gitrepo_for_each_commit(repo, commit_callback, writer); - gitrepo_for_each_reference(repo, reference_callback, writer); - gitrepo_for_each_file(repo, file_callback, writer); - repowriter_end(writer); - - repowriter_free(writer); - gitrepo_free(repo); -} - -void gitout_shutdown(void) { - gitout_git_shutdown(); -} - -void commit_callback(const GitCommit* ci, void* user_data) { - RepoWriter* writer = (RepoWriter*)user_data; - repowriter_add_commit(writer, ci); -} - -void reference_callback(const GitReference* ref, void* user_data) { - RepoWriter* writer = (RepoWriter*)user_data; - repowriter_add_reference(writer, ref); -} - -void file_callback(const GitFile* file, void* user_data) { - RepoWriter* writer = (RepoWriter*)user_data; - repowriter_add_file(writer, file); -} diff --git a/gitout.h b/gitout.h @@ -1,12 +0,0 @@ -#ifndef GITOUT_GITOUT_H_ -#define GITOUT_GITOUT_H_ - -typedef struct GitoutOptions GitoutOptions; -GitoutOptions* gitout_options_create(int argc, const char* argv[]); -void gitout_options_free(GitoutOptions* options); - -void gitout_init(const GitoutOptions* options); -void gitout_run(const GitoutOptions* options); -void gitout_shutdown(void); - -#endif // GITOUT_GITOUT_H_ diff --git a/gitout_index.c b/gitout_index.c @@ -1,93 +0,0 @@ -#include "gitout_index.h" - -#include <err.h> -#include <stddef.h> -#include <stdlib.h> - -#include "git/git.h" -#include "git/repo.h" -#include "security.h" -#include "third_party/openbsd/reallocarray.h" -#include "utils.h" -#include "writer/index_writer.h" - -struct GitoutIndexOptions { - const char** repo_dirs; - size_t repo_dir_count; - const char* me_url; - IndexWriterType writer_type; -}; - -GitoutIndexOptions* gitout_index_options_create(int argc, const char* argv[]) { - GitoutIndexOptions options = { - .repo_dirs = NULL, - .repo_dir_count = 0, - .me_url = NULL, - .writer_type = kIndexWriterTypeHtml, - }; - for (int i = 1; i < argc; i++) { - if (argv[i][0] != '-') { - options.repo_dirs = reallocarray( - options.repo_dirs, options.repo_dir_count + 1, sizeof(char*)); - if (!options.repo_dirs) { - err(1, "reallocarray"); - } - options.repo_dirs[options.repo_dir_count++] = argv[i]; - } else if (argv[i][1] == 'm') { - // Requires 'me' URL argument. - if (i + 1 >= argc) { - return NULL; - } - options.me_url = argv[++i]; - } else if (argv[i][1] == 'H') { - options.writer_type = kIndexWriterTypeHtml; - } else if (argv[i][1] == 'G') { - options.writer_type = kIndexWriterTypeGopher; - } - } - GitoutIndexOptions* options_out = ecalloc(1, sizeof(GitoutIndexOptions)); - *options_out = options; - return options_out; -} - -void gitout_index_options_free(GitoutIndexOptions* options) { - if (!options) { - return; - } - if (options->repo_dirs) { - free(options->repo_dirs); - options->repo_dirs = NULL; - } - free(options); -} - -void gitout_index_init(const GitoutIndexOptions* options) { - const char** readonly_paths = options->repo_dirs; - size_t readonly_paths_count = options->repo_dir_count; - const char* readwrite_paths[2] = {".", NULL}; - size_t readwrite_paths_count = 1; - restrict_filesystem_access(readonly_paths, readonly_paths_count, - readwrite_paths, readwrite_paths_count); - restrict_system_operations(kGitoutIndex); - - gitout_git_initialize(); -} - -void gitout_index_run(const GitoutIndexOptions* options) { - IndexWriter* writer = indexwriter_create(options->writer_type); - if (options->me_url) { - indexwriter_set_me_url(writer, options->me_url); - } - indexwriter_begin(writer); - for (size_t i = 0; i < options->repo_dir_count; i++) { - GitRepo* repo = gitrepo_create(options->repo_dirs[i]); - indexwriter_add_repo(writer, repo); - gitrepo_free(repo); - } - indexwriter_end(writer); - indexwriter_free(writer); -} - -void gitout_index_shutdown(void) { - gitout_git_shutdown(); -} diff --git a/gitout_index.h b/gitout_index.h @@ -1,12 +0,0 @@ -#ifndef GITOUT_GITOUT_INDEX_H_ -#define GITOUT_GITOUT_INDEX_H_ - -typedef struct GitoutIndexOptions GitoutIndexOptions; -GitoutIndexOptions* gitout_index_options_create(int argc, const char* argv[]); -void gitout_index_options_free(GitoutIndexOptions* options); - -void gitout_index_init(const GitoutIndexOptions* options); -void gitout_index_run(const GitoutIndexOptions* options); -void gitout_index_shutdown(void); - -#endif // GITOUT_GITOUT_INDEX_H_ diff --git a/gitout_index_main.c b/gitout_index_main.c @@ -1,21 +0,0 @@ -#include "gitout_index.h" - -#include <stdio.h> -#include <stdlib.h> - -static void gitout_index_usage(const char* program_name) { - fprintf(stderr, "usage: %s [repodir...]\n", program_name); -} - -int main(int argc, const char* argv[]) { - GitoutIndexOptions* options = gitout_index_options_create(argc, argv); - if (options == NULL) { - gitout_index_usage(argv[0]); - exit(1); - } - gitout_index_init(options); - gitout_index_run(options); - gitout_index_shutdown(); - gitout_index_options_free(options); - return 0; -} diff --git a/gitout_main.c b/gitout_main.c @@ -1,23 +0,0 @@ -#include "gitout.h" - -#include <stdio.h> -#include <stdlib.h> - -static void gitout_usage(const char* program_name) { - fprintf(stderr, - "usage: %s [-c cachefile | -l commits] [-u baseurl] repodir\n", - program_name); -} - -int main(int argc, const char* argv[]) { - GitoutOptions* options = gitout_options_create(argc, argv); - if (options == NULL) { - gitout_usage(argv[0]); - exit(1); - } - gitout_init(options); - gitout_run(options); - gitout_shutdown(); - gitout_options_free(options); - return 0; -} diff --git a/gitout_tests.c b/gitout_tests.c @@ -1,17 +0,0 @@ -#include "gitout.h" - -#include "utest.h" - -UTEST(gitout_options_create, ReturnsNullIfNoRepoSpecified) { - int argc = 1; - const char* argv[1] = { "path/to/gitout" }; - GitoutOptions* options = gitout_options_create(argc, argv); - EXPECT_EQ(NULL, options); -} - -UTEST(gitout_options_create, ReturnsInitializedOptions) { - int argc = 2; - const char* argv[2] = { "path/to/gitout", "some/path/myrepo" }; - GitoutOptions* options = gitout_options_create(argc, argv); - ASSERT_NE(NULL, options); -} diff --git a/gout.c b/gout.c @@ -0,0 +1,166 @@ +#include "gout.h" + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + +#include "git/commit.h" +#include "git/file.h" +#include "git/git.h" +#include "git/reference.h" +#include "git/repo.h" +#include "security.h" +#include "utils.h" +#include "writer/repo_writer.h" + +struct GoutOptions { + const char* repodir; + long long log_commit_limit; /* -1 indicates not used */ + const char* cachefile_path; + const char* baseurl; /* base URL to make absolute RSS/Atom URI */ + RepoWriterType writer_type; +}; + +static void commit_callback(const GitCommit* commit, void* user_data); +static void reference_callback(const GitReference* ref, void* user_data); +static void file_callback(const GitFile* file, void* user_data); + +GoutOptions* gout_options_create(int argc, const char* argv[]) { + GoutOptions options = { + .repodir = NULL, + .log_commit_limit = -1, + .cachefile_path = NULL, + .baseurl = "", + .writer_type = kRepoWriterTypeHtml, + }; + for (int i = 1; i < argc; i++) { + if (argv[i][0] != '-') { + // Cannot specify more than one repo directory. + if (options.repodir) { + return NULL; + } + options.repodir = argv[i]; + } else if (argv[i][1] == 'c') { + // Cache the entries of the log page up to the point of the last commit. + // The cachefile will store the last commit id and the entries in the + // HTML table. It is up to the user to make sure the state of the + // cachefile is in sync with the history of the repository. + + // Mutually exclusive with -l. + if (options.log_commit_limit > 0) { + return NULL; + } + // Requires cachefile path argument. + if (i + 1 >= argc) { + return NULL; + } + options.cachefile_path = argv[++i]; + } else if (argv[i][1] == 'l') { + // Write a maximum number of commits to the log.html file only. However + // the commit files are written as usual. + + // Mutually exclusive with -c option. + if (options.cachefile_path) { + return NULL; + } + // Requires log commits argument. + if (i + 1 >= argc) { + return NULL; + } + errno = 0; + char* p; + options.log_commit_limit = strtoll(argv[++i], &p, 10); + if (!argv[i][0] || *p || options.log_commit_limit <= 0 || errno) { + return NULL; + } + } else if (argv[i][1] == 'u') { + // Requires log commits argument. + if (i + 1 >= argc) { + return NULL; + } + options.baseurl = argv[++i]; + } else if (argv[i][1] == 'H') { + options.writer_type = kRepoWriterTypeHtml; + } else if (argv[i][1] == 'G') { + options.writer_type = kRepoWriterTypeGopher; + } + } + // Must specify at least one repo directory. + if (!options.repodir) { + return NULL; + } + GoutOptions* options_out = ecalloc(1, sizeof(GoutOptions)); + *options_out = options; + return options_out; +} + +void gout_options_free(GoutOptions* options) { + if (!options) { + return; + } + options->repodir = NULL; + options->log_commit_limit = -1; + options->cachefile_path = NULL; + options->baseurl = NULL; + free(options); +} + +void gout_init(const GoutOptions* options) { + // Restrict our permissions to the minimum necessary. + const char* readonly_paths[] = {options->repodir}; + size_t readonly_paths_count = 1; + const char* readwrite_paths[2] = {".", NULL}; + size_t readwrite_paths_count = 1; + if (options->cachefile_path) { + readwrite_paths[1] = options->cachefile_path; + readwrite_paths_count = 2; + } + restrict_filesystem_access(readonly_paths, readonly_paths_count, + readwrite_paths, readwrite_paths_count); + restrict_system_operations( + options->cachefile_path != NULL ? kGoutWithCachefile : kGout); + + gout_git_initialize(); +} + +void gout_run(const GoutOptions* options) { + GitRepo* repo = gitrepo_create(options->repodir); + RepoWriter* writer = repowriter_create(options->writer_type, repo); + if (options->log_commit_limit >= 0) { + repowriter_set_log_commit_limit(writer, options->log_commit_limit); + } + if (options->cachefile_path) { + repowriter_set_log_cachefile(writer, options->cachefile_path); + } + if (options->baseurl) { + repowriter_set_baseurl(writer, options->baseurl); + } + + repowriter_begin(writer); + gitrepo_for_each_commit(repo, commit_callback, writer); + gitrepo_for_each_reference(repo, reference_callback, writer); + gitrepo_for_each_file(repo, file_callback, writer); + repowriter_end(writer); + + repowriter_free(writer); + gitrepo_free(repo); +} + +void gout_shutdown(void) { + gout_git_shutdown(); +} + +void commit_callback(const GitCommit* ci, void* user_data) { + RepoWriter* writer = (RepoWriter*)user_data; + repowriter_add_commit(writer, ci); +} + +void reference_callback(const GitReference* ref, void* user_data) { + RepoWriter* writer = (RepoWriter*)user_data; + repowriter_add_reference(writer, ref); +} + +void file_callback(const GitFile* file, void* user_data) { + RepoWriter* writer = (RepoWriter*)user_data; + repowriter_add_file(writer, file); +} diff --git a/gout.h b/gout.h @@ -0,0 +1,12 @@ +#ifndef GOUT_GOUT_H_ +#define GOUT_GOUT_H_ + +typedef struct GoutOptions GoutOptions; +GoutOptions* gout_options_create(int argc, const char* argv[]); +void gout_options_free(GoutOptions* options); + +void gout_init(const GoutOptions* options); +void gout_run(const GoutOptions* options); +void gout_shutdown(void); + +#endif // GOUT_GOUT_H_ diff --git a/gout_index.c b/gout_index.c @@ -0,0 +1,93 @@ +#include "gout_index.h" + +#include <err.h> +#include <stddef.h> +#include <stdlib.h> + +#include "git/git.h" +#include "git/repo.h" +#include "security.h" +#include "third_party/openbsd/reallocarray.h" +#include "utils.h" +#include "writer/index_writer.h" + +struct GoutIndexOptions { + const char** repo_dirs; + size_t repo_dir_count; + const char* me_url; + IndexWriterType writer_type; +}; + +GoutIndexOptions* gout_index_options_create(int argc, const char* argv[]) { + GoutIndexOptions options = { + .repo_dirs = NULL, + .repo_dir_count = 0, + .me_url = NULL, + .writer_type = kIndexWriterTypeHtml, + }; + for (int i = 1; i < argc; i++) { + if (argv[i][0] != '-') { + options.repo_dirs = reallocarray( + options.repo_dirs, options.repo_dir_count + 1, sizeof(char*)); + if (!options.repo_dirs) { + err(1, "reallocarray"); + } + options.repo_dirs[options.repo_dir_count++] = argv[i]; + } else if (argv[i][1] == 'm') { + // Requires 'me' URL argument. + if (i + 1 >= argc) { + return NULL; + } + options.me_url = argv[++i]; + } else if (argv[i][1] == 'H') { + options.writer_type = kIndexWriterTypeHtml; + } else if (argv[i][1] == 'G') { + options.writer_type = kIndexWriterTypeGopher; + } + } + GoutIndexOptions* options_out = ecalloc(1, sizeof(GoutIndexOptions)); + *options_out = options; + return options_out; +} + +void gout_index_options_free(GoutIndexOptions* options) { + if (!options) { + return; + } + if (options->repo_dirs) { + free(options->repo_dirs); + options->repo_dirs = NULL; + } + free(options); +} + +void gout_index_init(const GoutIndexOptions* options) { + const char** readonly_paths = options->repo_dirs; + size_t readonly_paths_count = options->repo_dir_count; + const char* readwrite_paths[2] = {".", NULL}; + size_t readwrite_paths_count = 1; + restrict_filesystem_access(readonly_paths, readonly_paths_count, + readwrite_paths, readwrite_paths_count); + restrict_system_operations(kGoutIndex); + + gout_git_initialize(); +} + +void gout_index_run(const GoutIndexOptions* options) { + IndexWriter* writer = indexwriter_create(options->writer_type); + if (options->me_url) { + indexwriter_set_me_url(writer, options->me_url); + } + indexwriter_begin(writer); + for (size_t i = 0; i < options->repo_dir_count; i++) { + GitRepo* repo = gitrepo_create(options->repo_dirs[i]); + indexwriter_add_repo(writer, repo); + gitrepo_free(repo); + } + indexwriter_end(writer); + indexwriter_free(writer); +} + +void gout_index_shutdown(void) { + gout_git_shutdown(); +} diff --git a/gout_index.h b/gout_index.h @@ -0,0 +1,12 @@ +#ifndef GOUT_GOUT_INDEX_H_ +#define GOUT_GOUT_INDEX_H_ + +typedef struct GoutIndexOptions GoutIndexOptions; +GoutIndexOptions* gout_index_options_create(int argc, const char* argv[]); +void gout_index_options_free(GoutIndexOptions* options); + +void gout_index_init(const GoutIndexOptions* options); +void gout_index_run(const GoutIndexOptions* options); +void gout_index_shutdown(void); + +#endif // GOUT_GOUT_INDEX_H_ diff --git a/gout_index_main.c b/gout_index_main.c @@ -0,0 +1,21 @@ +#include "gout_index.h" + +#include <stdio.h> +#include <stdlib.h> + +static void gout_index_usage(const char* program_name) { + fprintf(stderr, "usage: %s [repodir...]\n", program_name); +} + +int main(int argc, const char* argv[]) { + GoutIndexOptions* options = gout_index_options_create(argc, argv); + if (options == NULL) { + gout_index_usage(argv[0]); + exit(1); + } + gout_index_init(options); + gout_index_run(options); + gout_index_shutdown(); + gout_index_options_free(options); + return 0; +} diff --git a/gout_main.c b/gout_main.c @@ -0,0 +1,23 @@ +#include "gout.h" + +#include <stdio.h> +#include <stdlib.h> + +static void gout_usage(const char* program_name) { + fprintf(stderr, + "usage: %s [-c cachefile | -l commits] [-u baseurl] repodir\n", + program_name); +} + +int main(int argc, const char* argv[]) { + GoutOptions* options = gout_options_create(argc, argv); + if (options == NULL) { + gout_usage(argv[0]); + exit(1); + } + gout_init(options); + gout_run(options); + gout_shutdown(); + gout_options_free(options); + return 0; +} diff --git a/gout_tests.c b/gout_tests.c @@ -0,0 +1,17 @@ +#include "gout.h" + +#include "utest.h" + +UTEST(gout_options_create, ReturnsNullIfNoRepoSpecified) { + int argc = 1; + const char* argv[1] = {"path/to/gout"}; + GoutOptions* options = gout_options_create(argc, argv); + EXPECT_EQ(NULL, options); +} + +UTEST(gout_options_create, ReturnsInitializedOptions) { + int argc = 2; + const char* argv[2] = {"path/to/gout", "some/path/myrepo"}; + GoutOptions* options = gout_options_create(argc, argv); + ASSERT_NE(NULL, options); +} diff --git a/gitout_tests_main.c b/gout_tests_main.c diff --git a/security.c b/security.c @@ -34,13 +34,13 @@ void restrict_filesystem_access(const char* readonly_paths[], void restrict_system_operations(RestrictionType type) { const char* promises = NULL; switch (type) { - case kGitout: + case kGout: promises = "stdio rpath wpath cpath"; break; - case kGitoutWithCachefile: + case kGoutWithCachefile: promises = "stdio rpath wpath cpath fattr"; break; - case kGitoutIndex: + case kGoutIndex: promises = "stdio rpath"; break; default: diff --git a/security.h b/security.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_SECURITY_H_ -#define GITOUT_SECURITY_H_ +#ifndef GOUT_SECURITY_H_ +#define GOUT_SECURITY_H_ #include <stdlib.h> @@ -12,9 +12,9 @@ void restrict_filesystem_access(const char* readonly_paths[], size_t readwrite_paths_count); typedef enum { - kGitout, - kGitoutWithCachefile, - kGitoutIndex, + kGout, + kGoutWithCachefile, + kGoutIndex, } RestrictionType; // Limits system operations to the minimum required. @@ -22,4 +22,4 @@ typedef enum { // No effect on OSes other than OpenBSD. void restrict_system_operations(RestrictionType type); -#endif // GITOUT_SECURITY_H_ +#endif // GOUT_SECURITY_H_ diff --git a/utils.h b/utils.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_UTILS_H_ -#define GITOUT_UTILS_H_ +#ifndef GOUT_UTILS_H_ +#define GOUT_UTILS_H_ #include <stdbool.h> #include <stdio.h> @@ -37,4 +37,4 @@ bool is_safe_url(const char* url); /* Returns true if the email address is safe to use in a mailto: link. */ bool is_safe_mailto(const char* email); -#endif // GITOUT_UTILS_H_ +#endif // GOUT_UTILS_H_ diff --git a/writer/BUILD.gn b/writer/BUILD.gn @@ -3,7 +3,7 @@ source_set("index_writer") { "index_writer.c", "index_writer.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//writer/gopher:index_writer", "//writer/html:index_writer", @@ -16,7 +16,7 @@ source_set("repo_writer") { "repo_writer.c", "repo_writer.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//writer/gopher:repo_writer", "//writer/html:repo_writer", diff --git a/writer/atom/BUILD.gn b/writer/atom/BUILD.gn @@ -3,7 +3,7 @@ source_set("atom") { "atom.c", "atom.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//:format", "//:utils", diff --git a/writer/atom/atom.h b/writer/atom/atom.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_ATOM_ATOM_H_ -#define GITOUT_WRITER_ATOM_ATOM_H_ +#ifndef GOUT_WRITER_ATOM_ATOM_H_ +#define GOUT_WRITER_ATOM_ATOM_H_ #include "git/commit.h" #include "git/repo.h" @@ -37,4 +37,4 @@ void atom_add_commit(Atom* atom, /* Closes out the Atom <feed>. */ void atom_end(Atom* atom); -#endif // GITOUT_WRITER_ATOM_ATOM_H_ +#endif // GOUT_WRITER_ATOM_ATOM_H_ diff --git a/writer/cache/BUILD.gn b/writer/cache/BUILD.gn @@ -3,7 +3,7 @@ source_set("cache") { "cache.c", "cache.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//:utils" ] public_deps = [ "//git" ] } diff --git a/writer/cache/cache.h b/writer/cache/cache.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_CACHE_CACHE_H_ -#define GITOUT_WRITER_CACHE_CACHE_H_ +#ifndef GOUT_WRITER_CACHE_CACHE_H_ +#define GOUT_WRITER_CACHE_CACHE_H_ #include <stdbool.h> #include <stdio.h> @@ -76,4 +76,4 @@ void cache_write(Cache* cache); /* Copies the contents of the cache to the specified output stream. */ void cache_copy_log(Cache* cache, FILE* out); -#endif // GITOUT_WRITER_CACHE_CACHE_H_ +#endif // GOUT_WRITER_CACHE_CACHE_H_ diff --git a/writer/gopher/BUILD.gn b/writer/gopher/BUILD.gn @@ -5,7 +5,7 @@ source_set("index_writer") { "repo_index.c", "repo_index.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//:format", "//:utils", @@ -30,7 +30,7 @@ source_set("repo_writer") { "repo_writer.c", "repo_writer.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//:format", "//:utils", diff --git a/writer/gopher/commit.h b/writer/gopher/commit.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_COMMIT_H_ -#define GITOUT_WRITER_GOPHER_COMMIT_H_ +#ifndef GOUT_WRITER_GOPHER_COMMIT_H_ +#define GOUT_WRITER_GOPHER_COMMIT_H_ #include "git/commit.h" #include "git/repo.h" @@ -15,4 +15,4 @@ void gopher_commit_add_commit(GopherCommit* commit, const GitCommit* git_commit); void gopher_commit_end(GopherCommit* commit); -#endif // GITOUT_WRITER_GOPHER_COMMIT_H_ +#endif // GOUT_WRITER_GOPHER_COMMIT_H_ diff --git a/writer/gopher/fileblob.h b/writer/gopher/fileblob.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_FILEBLOB_H_ -#define GITOUT_WRITER_GOPHER_FILEBLOB_H_ +#ifndef GOUT_WRITER_GOPHER_FILEBLOB_H_ +#define GOUT_WRITER_GOPHER_FILEBLOB_H_ #include "git/file.h" #include "git/repo.h" @@ -12,4 +12,4 @@ void gopher_fileblob_begin(GopherFileBlob* blob); void gopher_fileblob_add_file(GopherFileBlob* blob, const GitFile* file); void gopher_fileblob_end(GopherFileBlob* blob); -#endif // GITOUT_WRITER_GOPHER_FILEBLOB_H_ +#endif // GOUT_WRITER_GOPHER_FILEBLOB_H_ diff --git a/writer/gopher/files.h b/writer/gopher/files.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_FILES_H_ -#define GITOUT_WRITER_GOPHER_FILES_H_ +#ifndef GOUT_WRITER_GOPHER_FILES_H_ +#define GOUT_WRITER_GOPHER_FILES_H_ #include "git/file.h" #include "git/repo.h" @@ -12,4 +12,4 @@ void gopher_files_begin(GopherFiles* files); void gopher_files_add_file(GopherFiles* files, const GitFile* file); void gopher_files_end(GopherFiles* files); -#endif // GITOUT_WRITER_GOPHER_FILES_H_ +#endif // GOUT_WRITER_GOPHER_FILES_H_ diff --git a/writer/gopher/index_writer.h b/writer/gopher/index_writer.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_INDEX_WRITER_H_ -#define GITOUT_WRITER_GOPHER_INDEX_WRITER_H_ +#ifndef GOUT_WRITER_GOPHER_INDEX_WRITER_H_ +#define GOUT_WRITER_GOPHER_INDEX_WRITER_H_ #include "git/repo.h" @@ -11,4 +11,4 @@ void gopher_indexwriter_begin(void* writer); void gopher_indexwriter_add_repo(void* writer, GitRepo* repo); void gopher_indexwriter_end(void* writer); -#endif // GITOUT_WRITER_GOPHER_INDEX_WRITER_H_ +#endif // GOUT_WRITER_GOPHER_INDEX_WRITER_H_ diff --git a/writer/gopher/log.h b/writer/gopher/log.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_LOG_H_ -#define GITOUT_WRITER_GOPHER_LOG_H_ +#ifndef GOUT_WRITER_GOPHER_LOG_H_ +#define GOUT_WRITER_GOPHER_LOG_H_ #include <stdbool.h> #include <stdio.h> @@ -18,4 +18,4 @@ void gopher_log_begin(GopherLog* log); void gopher_log_add_commit(GopherLog* log, const GitCommit* commit); void gopher_log_end(GopherLog* log); -#endif // GITOUT_WRITER_GOPHER_LOG_H_ +#endif // GOUT_WRITER_GOPHER_LOG_H_ diff --git a/writer/gopher/page.h b/writer/gopher/page.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_PAGE_H_ -#define GITOUT_WRITER_GOPHER_PAGE_H_ +#ifndef GOUT_WRITER_GOPHER_PAGE_H_ +#define GOUT_WRITER_GOPHER_PAGE_H_ #include <stdio.h> @@ -15,4 +15,4 @@ void gopher_page_free(GopherPage* page); void gopher_page_begin(GopherPage* page); void gopher_page_end(GopherPage* page); -#endif // GITOUT_WRITER_GOPHER_PAGE_H_ +#endif // GOUT_WRITER_GOPHER_PAGE_H_ diff --git a/writer/gopher/refs.h b/writer/gopher/refs.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_REFS_H_ -#define GITOUT_WRITER_GOPHER_REFS_H_ +#ifndef GOUT_WRITER_GOPHER_REFS_H_ +#define GOUT_WRITER_GOPHER_REFS_H_ #include "git/reference.h" #include "git/repo.h" @@ -12,4 +12,4 @@ void gopher_refs_begin(GopherRefs* refs); void gopher_refs_add_ref(GopherRefs* refs, const GitReference* ref); void gopher_refs_end(GopherRefs* refs); -#endif // GITOUT_WRITER_GOPHER_REFS_H_ +#endif // GOUT_WRITER_GOPHER_REFS_H_ diff --git a/writer/gopher/repo_index.h b/writer/gopher/repo_index.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_REPOINDEX_H_ -#define GITOUT_WRITER_GOPHER_REPOINDEX_H_ +#ifndef GOUT_WRITER_GOPHER_REPOINDEX_H_ +#define GOUT_WRITER_GOPHER_REPOINDEX_H_ #include "git/repo.h" @@ -13,4 +13,4 @@ void gopher_repoindex_begin(GopherRepoIndex* index); void gopher_repoindex_add_repo(GopherRepoIndex* index, GitRepo* repo); void gopher_repoindex_end(GopherRepoIndex* index); -#endif // GITOUT_WRITER_GOPHER_REPOINDEX_H_ +#endif // GOUT_WRITER_GOPHER_REPOINDEX_H_ diff --git a/writer/gopher/repo_writer.h b/writer/gopher/repo_writer.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_GOPHER_REPO_WRITER_H_ -#define GITOUT_WRITER_GOPHER_REPO_WRITER_H_ +#ifndef GOUT_WRITER_GOPHER_REPO_WRITER_H_ +#define GOUT_WRITER_GOPHER_REPO_WRITER_H_ #include <stddef.h> @@ -21,4 +21,4 @@ void gopher_repowriter_add_reference(void* writer, const GitReference* ref); void gopher_repowriter_add_file(void* writer, const GitFile* file); void gopher_repowriter_end(void* writer); -#endif // GITOUT_WRITER_GOPHER_REPO_WRITER_H_ +#endif // GOUT_WRITER_GOPHER_REPO_WRITER_H_ diff --git a/writer/html/BUILD.gn b/writer/html/BUILD.gn @@ -5,7 +5,7 @@ source_set("index_writer") { "repo_index.c", "repo_index.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//:format", "//:utils", @@ -30,7 +30,7 @@ source_set("repo_writer") { "repo_writer.c", "repo_writer.h", ] - configs += [ "//:gitout_config" ] + configs += [ "//:gout_config" ] deps = [ "//:format", "//:utils", diff --git a/writer/html/commit.h b/writer/html/commit.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_COMMIT_H_ -#define GITOUT_WRITER_HTML_COMMIT_H_ +#ifndef GOUT_WRITER_HTML_COMMIT_H_ +#define GOUT_WRITER_HTML_COMMIT_H_ #include "git/commit.h" #include "git/repo.h" @@ -14,4 +14,4 @@ void html_commit_begin(HtmlCommit* commit); void html_commit_add_commit(HtmlCommit* commit, const GitCommit* git_commit); void html_commit_end(HtmlCommit* commit); -#endif // GITOUT_WRITER_HTML_COMMIT_H_ +#endif // GOUT_WRITER_HTML_COMMIT_H_ diff --git a/writer/html/fileblob.h b/writer/html/fileblob.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_FILEBLOB_H_ -#define GITOUT_WRITER_HTML_FILEBLOB_H_ +#ifndef GOUT_WRITER_HTML_FILEBLOB_H_ +#define GOUT_WRITER_HTML_FILEBLOB_H_ #include "git/file.h" #include "git/repo.h" @@ -12,4 +12,4 @@ void html_fileblob_begin(HtmlFileBlob* blob); void html_fileblob_add_file(HtmlFileBlob* blob, const GitFile* file); void html_fileblob_end(HtmlFileBlob* blob); -#endif // GITOUT_WRITER_HTML_FILEBLOB_H_ +#endif // GOUT_WRITER_HTML_FILEBLOB_H_ diff --git a/writer/html/files.h b/writer/html/files.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_FILES_H_ -#define GITOUT_WRITER_HTML_FILES_H_ +#ifndef GOUT_WRITER_HTML_FILES_H_ +#define GOUT_WRITER_HTML_FILES_H_ #include "git/file.h" #include "git/repo.h" @@ -12,4 +12,4 @@ void html_files_begin(HtmlFiles* files); void html_files_add_file(HtmlFiles* files, const GitFile* file); void html_files_end(HtmlFiles* files); -#endif // GITOUT_WRITER_HTML_FILES_H_ +#endif // GOUT_WRITER_HTML_FILES_H_ diff --git a/writer/html/index_writer.h b/writer/html/index_writer.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_INDEX_WRITER_H_ -#define GITOUT_WRITER_HTML_INDEX_WRITER_H_ +#ifndef GOUT_WRITER_HTML_INDEX_WRITER_H_ +#define GOUT_WRITER_HTML_INDEX_WRITER_H_ #include "git/repo.h" @@ -12,4 +12,4 @@ void html_indexwriter_begin(void* writer); void html_indexwriter_add_repo(void* writer, GitRepo* repo); void html_indexwriter_end(void* writer); -#endif // GITOUT_WRITER_HTML_INDEX_WRITER_H_ +#endif // GOUT_WRITER_HTML_INDEX_WRITER_H_ diff --git a/writer/html/log.h b/writer/html/log.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_LOG_H_ -#define GITOUT_WRITER_HTML_LOG_H_ +#ifndef GOUT_WRITER_HTML_LOG_H_ +#define GOUT_WRITER_HTML_LOG_H_ #include <stdbool.h> #include <stdio.h> @@ -18,4 +18,4 @@ void html_log_begin(HtmlLog* log); void html_log_add_commit(HtmlLog* log, const GitCommit* commit); void html_log_end(HtmlLog* log); -#endif // GITOUT_WRITER_HTML_LOG_H_ +#endif // GOUT_WRITER_HTML_LOG_H_ diff --git a/writer/html/page.h b/writer/html/page.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_PAGE_H_ -#define GITOUT_WRITER_HTML_PAGE_H_ +#ifndef GOUT_WRITER_HTML_PAGE_H_ +#define GOUT_WRITER_HTML_PAGE_H_ #include <stdio.h> @@ -15,4 +15,4 @@ void html_page_free(HtmlPage* page); void html_page_begin(HtmlPage* page); void html_page_end(HtmlPage* page); -#endif // GITOUT_WRITER_HTML_PAGE_H_ +#endif // GOUT_WRITER_HTML_PAGE_H_ diff --git a/writer/html/refs.h b/writer/html/refs.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_REFS_H_ -#define GITOUT_WRITER_HTML_REFS_H_ +#ifndef GOUT_WRITER_HTML_REFS_H_ +#define GOUT_WRITER_HTML_REFS_H_ #include "git/reference.h" #include "git/repo.h" @@ -12,4 +12,4 @@ void html_refs_begin(HtmlRefs* refs); void html_refs_add_ref(HtmlRefs* refs, const GitReference* ref); void html_refs_end(HtmlRefs* refs); -#endif // GITOUT_WRITER_HTML_REFS_H_ +#endif // GOUT_WRITER_HTML_REFS_H_ diff --git a/writer/html/repo_index.h b/writer/html/repo_index.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_REPOINDEX_H_ -#define GITOUT_WRITER_HTML_REPOINDEX_H_ +#ifndef GOUT_WRITER_HTML_REPOINDEX_H_ +#define GOUT_WRITER_HTML_REPOINDEX_H_ #include "git/repo.h" @@ -14,4 +14,4 @@ void html_repoindex_begin(HtmlRepoIndex* index); void html_repoindex_add_repo(HtmlRepoIndex* index, GitRepo* repo); void html_repoindex_end(HtmlRepoIndex* index); -#endif // GITOUT_WRITER_HTML_REPOINDEX_H_ +#endif // GOUT_WRITER_HTML_REPOINDEX_H_ diff --git a/writer/html/repo_writer.h b/writer/html/repo_writer.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_HTML_REPO_WRITER_H_ -#define GITOUT_WRITER_HTML_REPO_WRITER_H_ +#ifndef GOUT_WRITER_HTML_REPO_WRITER_H_ +#define GOUT_WRITER_HTML_REPO_WRITER_H_ #include <stddef.h> @@ -21,4 +21,4 @@ void html_repowriter_add_reference(void* writer, const GitReference* ref); void html_repowriter_add_file(void* writer, const GitFile* file); void html_repowriter_end(void* writer); -#endif // GITOUT_WRITER_HTML_REPO_WRITER_H_ +#endif // GOUT_WRITER_HTML_REPO_WRITER_H_ diff --git a/writer/index_writer.h b/writer/index_writer.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_INDEX_WRITER_H_ -#define GITOUT_WRITER_INDEX_WRITER_H_ +#ifndef GOUT_WRITER_INDEX_WRITER_H_ +#define GOUT_WRITER_INDEX_WRITER_H_ #include "git/repo.h" @@ -17,4 +17,4 @@ void indexwriter_begin(IndexWriter* writer); void indexwriter_add_repo(IndexWriter* writer, GitRepo* repo); void indexwriter_end(IndexWriter* writer); -#endif // GITOUT_WRITER_INDEX_WRITER_H_ +#endif // GOUT_WRITER_INDEX_WRITER_H_ diff --git a/writer/repo_writer.h b/writer/repo_writer.h @@ -1,5 +1,5 @@ -#ifndef GITOUT_WRITER_REPO_WRITER_H_ -#define GITOUT_WRITER_REPO_WRITER_H_ +#ifndef GOUT_WRITER_REPO_WRITER_H_ +#define GOUT_WRITER_REPO_WRITER_H_ #include <stddef.h> @@ -28,4 +28,4 @@ void repowriter_add_reference(RepoWriter* writer, const GitReference* ref); void repowriter_add_file(RepoWriter* writer, const GitFile* file); void repowriter_end(RepoWriter* writer); -#endif // GITOUT_WRITER_REPO_WRITER_H_ +#endif // GOUT_WRITER_REPO_WRITER_H_