summaryrefslogtreecommitdiffstats
path: root/test/norm.c
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 /test/norm.c
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 'test/norm.c')
-rw-r--r--test/norm.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/test/norm.c b/test/norm.c
index acfb6ec..4b8a35a 100644
--- a/test/norm.c
+++ b/test/norm.c
@@ -1,10 +1,5 @@
-/* norm.c - Refs and repositories have one spelling each internally. This is the file
- * that pins "main", "heads/main" and "refs/heads/main" being one branch, and
- * a bare name never meaning a tag.
- *
- * Part of the direct suite: this links the library, not the command
- * line. test/run.sh is the other half, and drives the program the way git does.
- */
+// One spelling per ref: "main", "heads/main" and "refs/heads/main" are one
+// branch, and a bare name is never a tag.
#include "test.h"
static void test_normalisation(void)
@@ -21,7 +16,7 @@ static void test_normalisation(void)
CHECK_STR(s, "refs/heads/main");
free(s);
s = authz_norm_ref("v1.0");
- CHECK_STR(s, "refs/heads/v1.0"); /* a bare name is never a tag */
+ CHECK_STR(s, "refs/heads/v1.0"); // a bare name is never a tag
free(s);
s = authz_norm_ref("tags/v1.0");
CHECK_STR(s, "refs/tags/v1.0");
@@ -49,7 +44,7 @@ static void test_normalisation(void)
CHECK_STR(s, "*");
free(s);
s = authz_norm_repo(".git");
- CHECK_STR(s, ".git"); /* a repository called ".git" is not a suffix */
+ CHECK_STR(s, ".git"); // a repository called ".git" is not a suffix
free(s);
CHECK_INT(authz_level_of("write"), LV_WRITE);
@@ -66,13 +61,13 @@ static void test_normalisation(void)
CHECK(authz_user_pattern_ok("@all"));
CHECK(authz_user_pattern_ok("a[bc]d"));
CHECK(!authz_user_pattern_ok(""));
- CHECK(!authz_user_pattern_ok("a/b")); /* a path is not a user name */
+ CHECK(!authz_user_pattern_ok("a/b")); // a path is not a user name
CHECK(!authz_user_pattern_ok("a$b"));
CHECK(!authz_user_pattern_ok("-x"));
CHECK(authz_repo_pattern_ok("team"));
CHECK(authz_repo_pattern_ok("*"));
CHECK(authz_repo_pattern_ok("team-*"));
- CHECK(!authz_repo_pattern_ok("group/team")); /* flat names only */
+ CHECK(!authz_repo_pattern_ok("group/team")); // flat names only
CHECK(!authz_repo_pattern_ok(""));
CHECK(!authz_repo_pattern_ok("a$b"));
}