refs.c: replace the onerr argument in update_ref with a strbuf err

Get rid of the action_on_err enum and replace the action argument to
update_ref with a strbuf *err for error reporting.

Update all callers to the new api including two callers in transport*.c
which used the literal 0 instead of an enum.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: make add_packed_ref return an error instead of calling die

Change add_packed_ref to return an error instead of calling die().
Update all callers to check the return value of add_packed_ref.

We can also skip checking the refname format since this function is now
static and only called from the transaction code.
If we are updating a ref and the refname is bad then we fail the transaction
already in transaction_update_sha1().
For the ref deletion case the only caveat is that we would not want
to move the badly named ref into the packed refs file during transaction
commit. This again is not a problem since if the name is bad, then
resolve_ref_unsafe() will fail which protects us from calling add_packed_ref()
with the bad name.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: make lock_packed_refs take an err argument

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add an err argument to commit_packed_refs

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: add an err argument to pack_refs

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
receive-pack.c: add protocol support to negotiate atomic-push

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
send-pack.c: add an --atomic-push command line argument

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
receive-pack.c: use a single transaction when atomic-push is negotiated

Update receive-pack to use an atomic transaction IFF the client negotiated
that it wanted atomic-push.
This leaves the default behaviour to be the old non-atomic one ref at a
time update. This is to cause as little disruption as possible to existing
clients. It is unknown if there are client scripts that depend on the old
non-atomic behaviour so we make it opt-in for now.

Later patch in this series also adds a configuration variable where you can
override the atomic push behaviour on the receiving repo and force it
to use atomic updates always.

If it turns out over time that there are no client scripts that depend on the
old behaviour we can change git to default to use atomic pushes and instead
offer an opt-out argument for people that do not want atomic pushes.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
receive-pack.c: add receive.atomicpush configuration option

Add a configuration argument to the receive side to force atomic pushes
for all pushes to the repo.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
push.c: add an --atomic-push argument

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>