summaryrefslogtreecommitdiffstats
path: root/container/git-http-backend.cgi
diff options
context:
space:
mode:
authordev <dev@example>2026-11-14 01:05:08 +0000
committerdev <dev@example>2026-11-14 01:05:08 +0000
commit312ddd4936f09ae27a180ca495cacf2c06faf33e (patch)
tree2fa46ab568ad55f7e8fb844c3447b1d296b2e340 /container/git-http-backend.cgi
parente737f3d560de2b8172e6dd83901bc1359283303c (diff)
downloadaccess-control-312ddd4936f09ae27a180ca495cacf2c06faf33e.tar.gz
access-control-312ddd4936f09ae27a180ca495cacf2c06faf33e.zip
Comments: cut to what the code cannot say
The comments had grown into essays. A file header explaining why the file exists, then a paragraph above each function restating what the next eight lines do, then a paragraph above that one explaining why that matters. The reader gets no further than the first paragraph, and the second is the one that goes stale: it describes code that has since changed, and nothing fails when it does. Cut by about half. What is left is the three things a comment can do that code cannot: say why the constraint exists (no regex because a hook must not depend on what might be missing at 3am), say what is not obvious from the shape (a bare ref name is a branch, never a tag; the seventh field of /etc/passwd is the shell), and say where it hurts (the NULL in an execvp array, the mode and owner that have to survive an atomic rewrite, the child that must not keep the hook's stdin). Block comments became // lines, which is also what the other C trees here use, and the file headers went to two or three lines. Section banners stayed: they are navigation, not prose. Behaviour is unchanged and the suites prove it: 171 direct checks, 162 behavioural, clean under -Werror and under ASan/UBSan.
Diffstat (limited to 'container/git-http-backend.cgi')
-rw-r--r--container/git-http-backend.cgi16
1 files changed, 4 insertions, 12 deletions
diff --git a/container/git-http-backend.cgi b/container/git-http-backend.cgi
index e086525..c69758b 100644
--- a/container/git-http-backend.cgi
+++ b/container/git-http-backend.cgi
@@ -1,17 +1,9 @@
#!/bin/sh
-# git-http-backend.cgi - a .cgi-named door to the stock git-http-backend.
+# A .cgi-named door onto the stock backend, because mod_cgi dispatches by
+# extension. No policy in here: writes are decided by the pre-receive hook.
#
-# There is no policy in here. Reads are open, and writes are decided by the
-# global pre-receive hook, which is a symlink to git-authz and is reached by
-# every repository through core.hooksPath in /etc/gitconfig.
-#
-# This file exists for one reason: lighttpd's mod_cgi dispatches by extension,
-# and the alias in lighttpd.conf needs something named *.cgi in front of it.
-#
-# REMOTE_USER is set by mod_auth on push requests (auth.conf) and the receive
-# hooks authorise the push from it, so this script must stay a plain exec:
-# unsetting or rewriting the environment here turns every push into "no
-# identity" and denies them all.
+# It must stay a plain exec. REMOTE_USER is the identity the hooks authorise
+# from, and rewriting the environment here denies every push.
set -eu
BACKEND="${GIT_HOST_HTTP_BACKEND:-/usr/libexec/git-core/git-http-backend}"