<feed xmlns='http://www.w3.org/2005/Atom'>
<title>access-control/src/authz.h, branch ai/test-branch</title>
<subtitle>Unnamed repository
</subtitle>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/'/>
<entry>
<title>Denials to the pusher: one line, and the reason moved to check</title>
<updated>2026-11-15T12:10:23+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-15T12:10:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=85b7fa7f8456c84f65a0d81b760c430098ae7fd8'/>
<id>85b7fa7f8456c84f65a0d81b760c430098ae7fd8</id>
<content type='text'>
The person pushing used to get a sentence about a file they cannot read:

    deny: bob holds write on team, but not on refs/heads/main; that ref needs write

It is true, and it is not theirs.  The level they hold, the level the ref costs
and why are all facts about somebody else's configuration, and quoting them at a
terminal sends a colleague to a file that is not theirs to edit while telling a
monitor nothing the exit status did not.  A refusal is now one line naming the
input it refused:

    git-authz: permission denied [user=bob, obj=refs/heads/main]
    git-authz: permission denied [obj=refs/heads/main]        # no identity

and `check` is where whoever owns the policy reads the reason out, unchanged.
`authorize --explain` prints the same sentence in the hook's own seat, for the
operator who is already standing there.

The other two denials got the same treatment and a reclassification:

  invalid policy file   exit 3, for an unreadable policy and an unparsable one
                        alike - no path, no line number, no errno
  invalid operation     exit 3, was 1, for a stdin line that is not an update:
                        not three fields, not object ids, not a ref under refs/

Exit 3 now means "the host is broken, not this person" and covers both, which is
what the split was always for: no real git writes those lines, so a hook that
rejects one has a pipe, a wrapper or a debugging session behind it, not a pusher.
Nothing about enforcement changed - a non-zero pre-receive exit stops the push
either way - only which status it is and what the line says.

To keep the pusher's output to one line, policy_load writes its findings to
p-&gt;log, stderr by default and NULL for the hook and for authorize mode: the mode
is the audience, not the name it was reached by.  check and validate still print
line numbers and errno, so nothing an operator needs has gone missing.

src/ and cmd/ are 1,488 non-blank lines.  make strict, make test and
make sanitizer are clean - 128 assertions, up from 113, now pinning the exact
terse line, that a denial is one line, that no policy prose leaks to the pusher,
and that nothing of a rejected line is echoed back.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The person pushing used to get a sentence about a file they cannot read:

    deny: bob holds write on team, but not on refs/heads/main; that ref needs write

It is true, and it is not theirs.  The level they hold, the level the ref costs
and why are all facts about somebody else's configuration, and quoting them at a
terminal sends a colleague to a file that is not theirs to edit while telling a
monitor nothing the exit status did not.  A refusal is now one line naming the
input it refused:

    git-authz: permission denied [user=bob, obj=refs/heads/main]
    git-authz: permission denied [obj=refs/heads/main]        # no identity

and `check` is where whoever owns the policy reads the reason out, unchanged.
`authorize --explain` prints the same sentence in the hook's own seat, for the
operator who is already standing there.

The other two denials got the same treatment and a reclassification:

  invalid policy file   exit 3, for an unreadable policy and an unparsable one
                        alike - no path, no line number, no errno
  invalid operation     exit 3, was 1, for a stdin line that is not an update:
                        not three fields, not object ids, not a ref under refs/

Exit 3 now means "the host is broken, not this person" and covers both, which is
what the split was always for: no real git writes those lines, so a hook that
rejects one has a pipe, a wrapper or a debugging session behind it, not a pusher.
Nothing about enforcement changed - a non-zero pre-receive exit stops the push
either way - only which status it is and what the line says.

To keep the pusher's output to one line, policy_load writes its findings to
p-&gt;log, stderr by default and NULL for the hook and for authorize mode: the mode
is the audience, not the name it was reached by.  check and validate still print
line numbers and errno, so nothing an operator needs has gone missing.

src/ and cmd/ are 1,488 non-blank lines.  make strict, make test and
make sanitizer are clean - 128 assertions, up from 113, now pinning the exact
terse line, that a denial is one line, that no policy prose leaks to the pusher,
and that nothing of a rejected line is echoed back.
</pre>
</div>
</content>
</entry>
<entry>
<title>Three things the removal left behind</title>
<updated>2026-11-15T11:32:51+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-15T11:32:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=2e6dd4a8e9e5302efae6b7532f7f4609882fc21d'/>
<id>2e6dd4a8e9e5302efae6b7532f7f4609882fc21d</id>
<content type='text'>
The shipped example policy still told operators that `git-authz grant`
and `revoke` edit a source copy. Both exit 64 now, so the header says
why the deployed copy is read-only instead - the hook must not be able
to change who can push - and stops short of naming a command that no
longer exists.

container/git-host-key made the same claim from the other side: that
`validate` cross-checks keys and the rest of the wiring. It does not
any more. The text now says what git-host-key itself guarantees, the
option prefix it writes onto each key, and what it does not: a key
edited in by hand can still lose the identity, and the name still needs
a rule.

sb_init/sb_add/sb_addf/sb_free and strbuf_t were orphaned when edit.c
went - nothing else ever built a string buffer - so they are gone, with
the stdarg.h include that only sb_addf needed. 64 lines.

src/ and cmd/ are 1,431 non-blank lines. make strict, make test and
make sanitizer are clean, sanitizers silent, and the example policy
still parses to its 7 rules.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The shipped example policy still told operators that `git-authz grant`
and `revoke` edit a source copy. Both exit 64 now, so the header says
why the deployed copy is read-only instead - the hook must not be able
to change who can push - and stops short of naming a command that no
longer exists.

container/git-host-key made the same claim from the other side: that
`validate` cross-checks keys and the rest of the wiring. It does not
any more. The text now says what git-host-key itself guarantees, the
option prefix it writes onto each key, and what it does not: a key
edited in by hand can still lose the identity, and the name still needs
a rule.

sb_init/sb_add/sb_addf/sb_free and strbuf_t were orphaned when edit.c
went - nothing else ever built a string buffer - so they are gone, with
the stdarg.h include that only sb_addf needed. 64 lines.

src/ and cmd/ are 1,431 non-blank lines. make strict, make test and
make sanitizer are clean, sanitizers silent, and the example policy
still parses to its 7 rules.
</pre>
</div>
</content>
</entry>
<entry>
<title>Drop grant/revoke and validate's host-wiring checks</title>
<updated>2026-11-15T11:28:47+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-15T11:28:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=c2b95afc6aefbab69133a202cab95a50a2df82fc'/>
<id>c2b95afc6aefbab69133a202cab95a50a2df82fc</id>
<content type='text'>
Two features out, to answer a size target: src/ and cmd/ go from 2,306
non-blank lines to 1,495.

`grant` and `revoke` were a convenience wrapper over a file that is a
read-only mount in production by design, so they sat outside the
enforcement path. src/edit.c is gone; both names now report an unknown
command with exit 64.

`validate` keeps the policy checks - parse errors with their line
numbers, an unreadable policy, the @all-whole-repo and not-readable-by-
the-git-account warnings - and stops cross-checking the machine around
it. The repository cross-check, hook/hooksPath, sshd, the git account's
shell and the key/htpasswd identity checks are deleted, along with
--root, --hook-dir, --gitconfig, --sshd-config, --passwd, --keys,
--htpasswd and --no-host; plain `validate` is what `validate --no-host`
used to be. The container's build gate and the test suite are updated to
match, since both called the removed flag.

Orphaned by the removals and deleted with them: authz_repo_reachable,
and authz_rule_validate's ref_ok parameter, which existed only so grant
could interleave its own ref-pattern test.

Surviving behaviour is unchanged. A 1,370-invocation differential run
against the pre-removal binary - the check matrix, every authorize path,
the hook reached through its own name, fake-git ancestry and HEAD,
policy-only validate, the failure modes - differs only in the usage text
that documented the removed surface. make strict, make test and
make sanitizer are all clean, with ASan and UBSan silent.

Also folded in from the same effort, since it touched the same files:
authz_rule_validate as the single grammar, rule_covers() as the single
answer for rule/ref coverage, vmsgv() behind the validate message tags,
one kv reader for gitconfig and sshd_config while both were still there,
and `sanitizer:` in the Makefile appending to CFLAGS rather than
replacing it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Two features out, to answer a size target: src/ and cmd/ go from 2,306
non-blank lines to 1,495.

`grant` and `revoke` were a convenience wrapper over a file that is a
read-only mount in production by design, so they sat outside the
enforcement path. src/edit.c is gone; both names now report an unknown
command with exit 64.

`validate` keeps the policy checks - parse errors with their line
numbers, an unreadable policy, the @all-whole-repo and not-readable-by-
the-git-account warnings - and stops cross-checking the machine around
it. The repository cross-check, hook/hooksPath, sshd, the git account's
shell and the key/htpasswd identity checks are deleted, along with
--root, --hook-dir, --gitconfig, --sshd-config, --passwd, --keys,
--htpasswd and --no-host; plain `validate` is what `validate --no-host`
used to be. The container's build gate and the test suite are updated to
match, since both called the removed flag.

Orphaned by the removals and deleted with them: authz_repo_reachable,
and authz_rule_validate's ref_ok parameter, which existed only so grant
could interleave its own ref-pattern test.

Surviving behaviour is unchanged. A 1,370-invocation differential run
against the pre-removal binary - the check matrix, every authorize path,
the hook reached through its own name, fake-git ancestry and HEAD,
policy-only validate, the failure modes - differs only in the usage text
that documented the removed surface. make strict, make test and
make sanitizer are all clean, with ASan and UBSan silent.

Also folded in from the same effort, since it touched the same files:
authz_rule_validate as the single grammar, rule_covers() as the single
answer for rule/ref coverage, vmsgv() behind the validate message tags,
one kv reader for gitconfig and sshd_config while both were still there,
and `sanitizer:` in the Makefile appending to CFLAGS rather than
replacing it.
</pre>
</div>
</content>
</entry>
<entry>
<title>One reader for every file, one voice for every finding</title>
<updated>2026-11-14T17:46:44+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T17:46:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=11c976ec713b975568594cf57d9118f58ba8c511'/>
<id>11c976ec713b975568594cf57d9118f58ba8c511</id>
<content type='text'>
Seven places opened a file, ran a getline loop, freed the line buffer and
closed the handle, and five of them also rewrote the same skip-the-blank-
and-comment preamble.  authz_read_lines() does it once, and keeps the
distinction policy_load needed: a file that would not give an answer is
not an empty file.

lines_t moves to util.c with it, so edit.c's private copy goes too.

verr, vwarn and vok were one function with three tags.

cmd_authorize now frees what it read on one path instead of four.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Seven places opened a file, ran a getline loop, freed the line buffer and
closed the handle, and five of them also rewrote the same skip-the-blank-
and-comment preamble.  authz_read_lines() does it once, and keeps the
distinction policy_load needed: a file that would not give an answer is
not an empty file.

lines_t moves to util.c with it, so edit.c's private copy goes too.

verr, vwarn and vok were one function with three tags.

cmd_authorize now frees what it read on one path instead of four.
</pre>
</div>
</content>
</entry>
<entry>
<title>Options: getopt_long instead of three hand-rolled parsers</title>
<updated>2026-11-14T17:42:44+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T17:42:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=12dcb09794c48a333bb850d353540c688c503b76'/>
<id>12dcb09794c48a333bb850d353540c688c503b76</id>
<content type='text'>
option() in hook.c and one_option() in cmd/main.c were the same function
under two names, and validate's seven options were a chain of seven calls
to one of them.  getopt_long does all of it - both --opt value and
--opt=value, the lot - so the parsers are gone and what is left is a table
and what each entry sets.

Two small helpers carry what getopt_long cannot: the name behind a long
option's val, for the 'wants a value' message, and the optind reset that
lets a run parse options twice on two different argv slices.

A command now gets argv[0] as its own name, which is where getopt_long
expects argv[0]; the commands that take names step over it.

strip() in validate.c was authz_trim() again, and cmd_authorize freed the
same three pointers on four exit paths.

One behaviour change: 'authorize --' is now the end-of-options marker
rather than an unknown argument.  Anything after it is still refused.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
option() in hook.c and one_option() in cmd/main.c were the same function
under two names, and validate's seven options were a chain of seven calls
to one of them.  getopt_long does all of it - both --opt value and
--opt=value, the lot - so the parsers are gone and what is left is a table
and what each entry sets.

Two small helpers carry what getopt_long cannot: the name behind a long
option's val, for the 'wants a value' message, and the optind reset that
lets a run parse options twice on two different argv slices.

A command now gets argv[0] as its own name, which is where getopt_long
expects argv[0]; the commands that take names step over it.

strip() in validate.c was authz_trim() again, and cmd_authorize freed the
same three pointers on four exit paths.

One behaviour change: 'authorize --' is now the end-of-options marker
rather than an unknown argument.  Anything after it is still refused.
</pre>
</div>
</content>
</entry>
<entry>
<title>Comments: cut to what the code cannot say</title>
<updated>2026-11-14T01:05:08+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T01:05:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=312ddd4936f09ae27a180ca495cacf2c06faf33e'/>
<id>312ddd4936f09ae27a180ca495cacf2c06faf33e</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove protected-refs: a rule covers what it names, and nothing else</title>
<updated>2026-11-13T22:28:22+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-13T22:28:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=50f296cf7609ce77d41b9fb3df51d6aeec8330d6'/>
<id>50f296cf7609ce77d41b9fb3df51d6aeec8330d6</id>
<content type='text'>
`set protected-refs` raised the price of a listed ref by one level: write
needed force on main, force needed admin.  It was a second, invisible list, and
it was the one part of the model that could not be read off the rules.  The
question it was supposed to answer - "who can move main?" - stopped having an
answer in the file: you had to hold both the rules and the protection list in
your head and combine them, and the combination was where surprises lived.
Giving someone force so they could rewrite their own branches quietly let them
fast-forward main, because a fast-forward costs write, protection raised it to
force, and there it was.

Now a rule says what it says.  An unscoped rule covers main; a rule that means
to leave main alone names what it covers instead, and the refusal says "bob
holds write on team, but not on refs/heads/main" rather than blaming a list
nobody remembered.  Excluding one person from one branch is a matter of what
their lines name, which is the same mechanism as everything else here.

The setting is refused by name rather than ignored.  A policy that still carries
one would otherwise mean "everyone with write can fast-forward main" while
looking like it said the opposite, and the operator would learn that from a push
rather than from the parser; so `set protected-refs` is now an error that says
what to write instead, and the suite asserts both halves - that it is refused,
and that cleaning it out makes the file valid again.

What stays: refs outside refs/heads and refs/tags still need admin whatever a
rule appears to grant about them.  That one the policy genuinely cannot name in
advance, because it is the part of the namespace no policy was written with in
mind.

`protect` goes with it, so the editing commands are grant and revoke.  The
example policy now names frank, whose two refs are main and the release tags,
because that is the shape the file is now meant to be written in.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`set protected-refs` raised the price of a listed ref by one level: write
needed force on main, force needed admin.  It was a second, invisible list, and
it was the one part of the model that could not be read off the rules.  The
question it was supposed to answer - "who can move main?" - stopped having an
answer in the file: you had to hold both the rules and the protection list in
your head and combine them, and the combination was where surprises lived.
Giving someone force so they could rewrite their own branches quietly let them
fast-forward main, because a fast-forward costs write, protection raised it to
force, and there it was.

Now a rule says what it says.  An unscoped rule covers main; a rule that means
to leave main alone names what it covers instead, and the refusal says "bob
holds write on team, but not on refs/heads/main" rather than blaming a list
nobody remembered.  Excluding one person from one branch is a matter of what
their lines name, which is the same mechanism as everything else here.

The setting is refused by name rather than ignored.  A policy that still carries
one would otherwise mean "everyone with write can fast-forward main" while
looking like it said the opposite, and the operator would learn that from a push
rather than from the parser; so `set protected-refs` is now an error that says
what to write instead, and the suite asserts both halves - that it is refused,
and that cleaning it out makes the file valid again.

What stays: refs outside refs/heads and refs/tags still need admin whatever a
rule appears to grant about them.  That one the policy genuinely cannot name in
advance, because it is the part of the namespace no policy was written with in
mind.

`protect` goes with it, so the editing commands are grant and revoke.  The
example policy now names frank, whose two refs are main and the release tags,
because that is the shape the file is now meant to be written in.
</pre>
</div>
</content>
</entry>
<entry>
<title>A refusal names the level held on the ref in question</title>
<updated>2026-11-13T20:34:17+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-13T20:33:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=1fd64267f678b8c6d17b2bcae702d577df1fc9e4'/>
<id>1fd64267f678b8c6d17b2bcae702d577df1fc9e4</id>
<content type='text'>
"carol has force on team; refs/heads/main needs force", said while refusing
carol a force push to main, is a sentence nobody can act on: her force is on
refs/heads/feature/*, and the message reported the strongest level she holds
somewhere in the repository rather than the one she holds on the ref that was
refused.  scope() now records both, and the refusal uses the level that covers
the ref, with a separate sentence for the case where nothing covers it at all -
"a rule for team but nothing on this ref" is a different problem from "not
enough for this ref", and the person pushing cannot tell them apart without
reading the file the way the matcher does.

Also: a policy that could not be opened is remembered (unreadable), so
validate reports "every push is denied until it is mounted" instead of
announcing that an empty policy is in force, and /etc/passwd is split by its
seven fields rather than eight - the old loop marked the colons as the fields
and so never found the git account at all, which meant a login shell for git
passed validation.

Both were found by driving the binary the way a receive hook is driven; that
suite is in a later commit of this series.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
"carol has force on team; refs/heads/main needs force", said while refusing
carol a force push to main, is a sentence nobody can act on: her force is on
refs/heads/feature/*, and the message reported the strongest level she holds
somewhere in the repository rather than the one she holds on the ref that was
refused.  scope() now records both, and the refusal uses the level that covers
the ref, with a separate sentence for the case where nothing covers it at all -
"a rule for team but nothing on this ref" is a different problem from "not
enough for this ref", and the person pushing cannot tell them apart without
reading the file the way the matcher does.

Also: a policy that could not be opened is remembered (unreadable), so
validate reports "every push is denied until it is mounted" instead of
announcing that an empty policy is in force, and /etc/passwd is split by its
seven fields rather than eight - the old loop marked the colons as the fields
and so never found the git account at all, which meant a login shell for git
passed validation.

Both were found by driving the binary the way a receive hook is driven; that
suite is in a later commit of this series.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-authz: one C program for who may move which refs</title>
<updated>2026-11-13T19:04:50+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-13T19:04:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=f87a792743227ea06cfa1580f8d30a618b4d1a04'/>
<id>f87a792743227ea06cfa1580f8d30a618b4d1a04</id>
<content type='text'>
A git host that anonymous-clones and shared-pushes has one question left to
answer: which human may move which ref.  This answers it from one plain file,
in one binary, with no runtime beyond libc.

Four modes, because they must agree exactly about what a rule means - a check
that answers differently from the hook is a program that lies:

  check      one question, for an operator or a script
  authorize  a whole push, the way core.hooksPath hands it over: identity from
             GIT_HOST_USER (ssh key option) or REMOTE_USER (http auth), and one
             "old new ref" line per ref on stdin.  Also runs as "pre-receive",
             which is how git finds it.
  validate   does the policy parse, and is the host wired to run it
  edit       grant, revoke, protect (the deployed policy is a read-only mount on
             purpose, so these are for the source copy and say so when told)

The verdict is the exit status, since the caller is a hook: 0 allowed, 1 denied,
3 no usable policy, 64 usage.  A policy that cannot be read or does not parse
denies everything rather than guessing, and one bad line poisons the whole file
on purpose: a mistyped rule that quietly widens access is worse than an evening
of refused pushes.

Semantics kept from the shell engine this replaces: levels are monotone (admin
implies force implies write), rules add up rather than order, "@" is only
everyone the policy already names, protected refs cost one step more than the
action asked for, and refs that are neither branches nor tags are for admins.
"main", "heads/main" and "refs/heads/main" are one branch; a bare name is never
a tag.

Two facts a push does not carry - is old an ancestor of new, and which branch
HEAD points at - are asked of git, and an answer that cannot be had is taken the
expensive way.  tests/unit.c covers the matcher directly (173 checks); the
behavioural suite that drives this the way git does follows next.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A git host that anonymous-clones and shared-pushes has one question left to
answer: which human may move which ref.  This answers it from one plain file,
in one binary, with no runtime beyond libc.

Four modes, because they must agree exactly about what a rule means - a check
that answers differently from the hook is a program that lies:

  check      one question, for an operator or a script
  authorize  a whole push, the way core.hooksPath hands it over: identity from
             GIT_HOST_USER (ssh key option) or REMOTE_USER (http auth), and one
             "old new ref" line per ref on stdin.  Also runs as "pre-receive",
             which is how git finds it.
  validate   does the policy parse, and is the host wired to run it
  edit       grant, revoke, protect (the deployed policy is a read-only mount on
             purpose, so these are for the source copy and say so when told)

The verdict is the exit status, since the caller is a hook: 0 allowed, 1 denied,
3 no usable policy, 64 usage.  A policy that cannot be read or does not parse
denies everything rather than guessing, and one bad line poisons the whole file
on purpose: a mistyped rule that quietly widens access is worse than an evening
of refused pushes.

Semantics kept from the shell engine this replaces: levels are monotone (admin
implies force implies write), rules add up rather than order, "@" is only
everyone the policy already names, protected refs cost one step more than the
action asked for, and refs that are neither branches nor tags are for admins.
"main", "heads/main" and "refs/heads/main" are one branch; a bare name is never
a tag.

Two facts a push does not carry - is old an ancestor of new, and which branch
HEAD points at - are asked of git, and an answer that cannot be had is taken the
expensive way.  tests/unit.c covers the matcher directly (173 checks); the
behavioural suite that drives this the way git does follows next.
</pre>
</div>
</content>
</entry>
</feed>
