From 002e415c207e0cafb6aa98bc85a8d41eb411ec89 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Tue, 22 Sep 2026 07:04:21 -1000 Subject: Align with spaces instead of tabs --- .gitattributes | 1 - source/cache.c | 14 +++++++------- source/cgit.c | 25 ++++++++++++------------- source/scan-tree.c | 14 +++++++------- source/ui-diff.c | 8 ++++---- source/ui-shared.c | 6 +++--- source/ui-snapshot.c | 14 +++++++------- source/ui-summary.c | 4 ++-- tests/extensions/lib.sh | 12 ++++++------ tests/t0001-git-version.sh | 8 ++++---- tools/release-build.sh | 14 ++++++++++---- 11 files changed, 62 insertions(+), 58 deletions(-) diff --git a/.gitattributes b/.gitattributes index 319f6e1..d4a15ff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,5 @@ * text=auto - *.c text eol=lf *.h text eol=lf diff --git a/source/cache.c b/source/cache.c index 0c86210..091c078 100644 --- a/source/cache.c +++ b/source/cache.c @@ -90,8 +90,8 @@ static int open_slot(struct cache_slot *slot) if (slot->key) slot->key_matches = - keylen >= 0 && - (size_t)keylen == slot->keylen && + keylen >= 0 && + (size_t)keylen == slot->keylen && !memcmp(slot->key, slot->buf, keylen + 1); return 0; @@ -193,8 +193,8 @@ static int is_modified(struct cache_slot *slot) if (stat(slot->path, ¤t)) return 1; return ( - current.st_ino != slot->st.st_ino || - current.st_mtime != slot->st.st_mtime || + current.st_ino != slot->st.st_ino || + current.st_mtime != slot->st.st_mtime || current.st_size != slot->st.st_size ); } @@ -242,9 +242,9 @@ static int lock_slot(struct cache_slot *slot) // slot, and once the path is confirmed to still name this file that // rename can no longer happen, because it takes the lock held here. if ( - fstat(slot->lock_fd, &held) || - stat(slot->lock_path, &named) || - held.st_ino != named.st_ino || + fstat(slot->lock_fd, &held) || + stat(slot->lock_path, &named) || + held.st_ino != named.st_ino || held.st_dev != named.st_dev ) { close(slot->lock_fd); diff --git a/source/cgit.c b/source/cgit.c index 00ce97f..8601dd0 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -384,9 +384,9 @@ static int generate_cached_repolist(const char *path, const char *cached_rc) // list, and once the path is confirmed to still name this file that // rename can no longer happen, because it takes the lock held here. if ( - fstat(fd, &held) || - stat(locked_rc.buf, &named) || - held.st_ino != named.st_ino || + fstat(fd, &held) || + stat(locked_rc.buf, &named) || + held.st_ino != named.st_ino || held.st_dev != named.st_dev ) { err = EAGAIN; @@ -844,10 +844,10 @@ static void authenticate_cookie(void) } if ( - ctx.env.request_method && - ctx.qry.page && - !ctx.repo && - !strcmp(ctx.env.request_method, "POST") && + ctx.env.request_method && + ctx.qry.page && + !ctx.repo && + !strcmp(ctx.env.request_method, "POST") && !strcmp(ctx.qry.page, "login") ) { authenticate_post(); @@ -921,9 +921,9 @@ static int calc_ttl(void) // object id can never come out differently and is the most expensive // page to rebuild. if ( - ctx.qry.has_oid && - page_is_static() && - (!ctx.qry.oid || is_full_oid(ctx.qry.oid)) && + ctx.qry.has_oid && + page_is_static() && + (!ctx.qry.oid || is_full_oid(ctx.qry.oid)) && (!ctx.qry.oid2 || is_full_oid(ctx.qry.oid2)) ) return ctx.cfg.cache_static_ttl; @@ -1157,7 +1157,7 @@ static int prepare_repo_cmd(int nongit, int err, int clone) return 1; } if ( - (ctx.qry.oid && !cgit_valid_rev(ctx.qry.oid)) || + (ctx.qry.oid && !cgit_valid_rev(ctx.qry.oid)) || (ctx.qry.oid2 && !cgit_valid_rev(ctx.qry.oid2)) ) { cgit_print_error_page(400, "Bad Request", "Invalid revision"); @@ -1354,8 +1354,7 @@ int cmd_main(int argc, const char **argv) ttl = calc_ttl(); // An unauthenticated request gets a body meant for one visitor, and a // HEAD request stops after the headers. - if (!ctx.env.authenticated || - (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD"))) + if (!ctx.env.authenticated || (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD"))) ctx.cfg.cache_size = 0; build_cache_key(&cache_key); diff --git a/source/scan-tree.c b/source/scan-tree.c index 4110511..97a58e6 100644 --- a/source/scan-tree.c +++ b/source/scan-tree.c @@ -61,13 +61,13 @@ static int trusted_key(const char *name, const char *value) if (ctx.cfg.trust_scan_config) return 1; untrusted = - ends_with(name, "-filter") || - !strcmp(name, "head-content") || - !strcmp(name, "module-link") || - starts_with(name, "module-link.") || - !strcmp(name, "logo") || - !strcmp(name, "logo-link") || - !strcmp(name, "clone-url") || + ends_with(name, "-filter") || + !strcmp(name, "head-content") || + !strcmp(name, "module-link") || + starts_with(name, "module-link.") || + !strcmp(name, "logo") || + !strcmp(name, "logo-link") || + !strcmp(name, "clone-url") || (!strcmp(name, "readme") && !strchr(value, ':')); if (!untrusted) return 1; diff --git a/source/ui-diff.c b/source/ui-diff.c index ee8dc76..f258e9f 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -128,8 +128,8 @@ static void print_fileinfo(struct fileinfo *info) } if ( - info->old_mode != info->new_mode && - !is_null_oid(info->old_oid) && + info->old_mode != info->new_mode && + !is_null_oid(info->old_oid) && !is_null_oid(info->new_oid) ) { html("["); @@ -176,8 +176,8 @@ static void count_diff_lines(char *line, int len) if (!render_line_fn || render_suppressed) return; if ( - cap_diffs && - ctx.cfg.max_diff_lines > 0 && + cap_diffs && + ctx.cfg.max_diff_lines > 0 && lines_added + lines_removed > ctx.cfg.max_diff_lines ) { render_suppressed = 1; diff --git a/source/ui-shared.c b/source/ui-shared.c index 25a84a6..4417975 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1113,9 +1113,9 @@ static char *submodule_url_path(const char *url) return NULL; } } else if ( - skip_prefix(url, "http://", &rest) || - skip_prefix(url, "https://", &rest) || - skip_prefix(url, "git://", &rest) || + skip_prefix(url, "http://", &rest) || + skip_prefix(url, "https://", &rest) || + skip_prefix(url, "git://", &rest) || skip_prefix(url, "ssh://", &rest) ) { rest = strchr(rest, '/'); diff --git a/source/ui-snapshot.c b/source/ui-snapshot.c index 5f2d69d..348fd9c 100644 --- a/source/ui-snapshot.c +++ b/source/ui-snapshot.c @@ -139,13 +139,13 @@ static int write_tar_zstd_archive(const char *hex, const char *prefix) // ui-shared.c reads entry zero as the tar whose signature stands in for every // tar variant, so this order cannot change. const struct cgit_snapshot_format cgit_snapshot_formats[] = { - { ".tar", "application/x-tar", write_tar_archive, NULL }, - { ".tar.gz", "application/gzip", write_tar_gzip_archive, "gzip" }, - { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, "bzip2" }, - { ".tar.lz", "application/x-lzip", write_tar_lzip_archive, "lzip" }, - { ".tar.xz", "application/x-xz", write_tar_xz_archive, "xz" }, - { ".tar.zst", "application/zstd", write_tar_zstd_archive, "zstd" }, - { ".zip", "application/zip", write_zip_archive, NULL }, + { ".tar", "application/x-tar", write_tar_archive, NULL }, + { ".tar.gz", "application/gzip", write_tar_gzip_archive, "gzip" }, + { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, "bzip2" }, + { ".tar.lz", "application/x-lzip", write_tar_lzip_archive, "lzip" }, + { ".tar.xz", "application/x-xz", write_tar_xz_archive, "xz" }, + { ".tar.zst", "application/zstd", write_tar_zstd_archive, "zstd" }, + { ".zip", "application/zip", write_zip_archive, NULL }, { 0 } }; diff --git a/source/ui-summary.c b/source/ui-summary.c index da530e5..0b33a96 100644 --- a/source/ui-summary.c +++ b/source/ui-summary.c @@ -94,8 +94,8 @@ static char *resolve_about_path(const char *filename, const char *ref, const cha resolved_full = realpath(full_path, NULL); resolved_repo = realpath(ctx.repo->path, NULL); if ( - !resolved_base || !resolved_full || !resolved_repo || - path_within(resolved_base, resolved_repo) || + !resolved_base || !resolved_full || !resolved_repo || + path_within(resolved_base, resolved_repo) || !path_within(resolved_base, resolved_full) ) { free(full_path); diff --git a/tests/extensions/lib.sh b/tests/extensions/lib.sh index ec1ef85..30a9cc8 100644 --- a/tests/extensions/lib.sh +++ b/tests/extensions/lib.sh @@ -45,15 +45,15 @@ cgit_lua_probe() { echo "function filter_open(...) end" echo "function filter_write(str) end" echo "function filter_close()" - echo " local ok = true" + echo "local ok = true" for cgit_lua_probe_module in "$@" do - echo " if not pcall(require, '$cgit_lua_probe_module') then" - echo " ok = false" - echo " end" + echo "if not pcall(require, '$cgit_lua_probe_module') then" + echo "ok = false" + echo "end" done - echo " if ok then html('LUA_PROBE_YES') else html('LUA_PROBE_NO') end" - echo " return 0" + echo "if ok then html('LUA_PROBE_YES') else html('LUA_PROBE_NO') end" + echo "return 0" echo "end" } >lua-probe.lua cat >lua-probe-cgitrc <makefile_version ' @@ -27,7 +27,7 @@ test_expect_success 'extract Git version from Makefile' ' test_expect_success 'test Git version matches Makefile' ' ( cat "$TEST_OUTPUT_DIRECTORY/../vendor/git/GIT-VERSION-FILE" || echo "No GIT-VERSION-FILE" ) | - sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version && + sed -e "s/GIT_VERSION[[:space:]]*=[[:space:]]*//" -e "s/\\.dirty$//" >git_version && sed -e "s/-/./g" makefile_version >makefile_git_version && test_cmp git_version makefile_git_version ' @@ -42,7 +42,7 @@ test_expect_success 'test submodule version matches Makefile' ' ( cd "$TEST_OUTPUT_DIRECTORY/.." && submodule_oid=$(git ls-files --stage -- vendor/git | - sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") && + sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9][[:space:]].*$/\\1/") && cd vendor/git && git describe --match "v[0-9]*" $submodule_oid ) | sed -e "s/^v//" -e "s/-/./" >submodule_version && diff --git a/tools/release-build.sh b/tools/release-build.sh index a22b70e..c5ca6e9 100755 --- a/tools/release-build.sh +++ b/tools/release-build.sh @@ -15,10 +15,16 @@ then exit 2 fi case "${1:-}" in -"") set -- NO_LUA=1 ;; -lua) set -- ;; -*) echo "$0: unknown argument \"$1\", expected \"lua\" or nothing" >&2 - exit 2 ;; +"") + set -- NO_LUA=1 + ;; +lua) + set -- + ;; +*) + echo "$0: unknown argument \"$1\", expected \"lua\" or nothing" >&2 + exit 2 + ;; esac # Every make target below is written relative to the repository root. -- cgit v2.8.0