refs.c: ref_transaction_commit: distinguish name conflicts from other errors
commit28e6a97e39edb84599693db971e36d793d36e413
authorRonnie Sahlberg <sahlberg@google.com>
Fri, 16 May 2014 21:14:38 +0000 (16 14:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Oct 2014 17:47:23 +0000 (15 10:47 -0700)
tree610a68dd8e91e16a77d19a696d210f4f7dd741d9
parent5fe7d825da8af83a9a3b9bc7f3295f836b6e3a75
refs.c: ref_transaction_commit: distinguish name conflicts from other errors

In _commit, ENOTDIR can happen in the call to lock_ref_sha1_basic, either
when we lstat the new refname or if the name checking function reports that
the same type of conflict happened.  In both cases, it means that we can not
create the new ref due to a name conflict.

Start defining specific return codes for _commit.  TRANSACTION_NAME_CONFLICT
refers to a failure to create a ref due to a name conflict with another ref.
TRANSACTION_GENERIC_ERROR is for all other errors.

When "git fetch" is creating refs, name conflicts differ from other errors in
that they are likely to be resolved by running "git remote prune <remote>".
"git fetch" currently inspects errno to decide whether to give that advice.
Once it switches to the transaction API, it can check for
TRANSACTION_NAME_CONFLICT instead.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs.h