receive-pack.c: use a reference transaction for updating the refs
commit762ed0bac8b712ab4055a4474ef8b99e6f5b1deb
authorRonnie Sahlberg <sahlberg@google.com>
Mon, 28 Apr 2014 21:36:15 +0000 (28 14:36 -0700)
committerJonathan Nieder <jrnieder@gmail.com>
Tue, 2 Sep 2014 20:43:41 +0000 (2 13:43 -0700)
treee8be3b6cc210bbb734ec84c8b7efe9a3cd68c843
parentb66e8d11b8a538c798c888c1fccac666085a4ef8
receive-pack.c: use a reference transaction for updating the refs

Wrap all the ref updates inside a transaction.

In the new API there is no distinction between failure to lock and
failure to write a ref.  Both can be permanent (e.g., a ref
"refs/heads/topic" is blocking creation of the lock file
"refs/heads/topic/1.lock") or transient (e.g., file system full) and
there's no clear difference in how the client should respond, so
replace the two statuses "failed to lock" and "failed to write" with
a single status "failed to update ref".  In both cases a more
detailed message is sent by sideband to diagnose the problem.

Example, before:

 error: there are still refs under 'refs/heads/topic'
 remote: error: failed to lock refs/heads/topic
 To foo
  ! [remote rejected] HEAD -> topic (failed to lock)

After:

 error: there are still refs under 'refs/heads/topic'
 remote: error: Cannot lock the ref 'refs/heads/topic'.
 To foo
  ! [remote rejected] HEAD -> topic (failed to update ref)

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
builtin/receive-pack.c