diff options
author | Jeff King <peff@peff.net> | 2009-05-25 06:40:54 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-05-25 12:07:07 -0700 |
commit | fa250759794ab98e6edfbbf2f6aa2cb912e535eb (patch) | |
tree | e602888e98cde7976fb4184cca3970759883d3c6 /builtin-fetch.c | |
parent | f475e08edbbabe38bd758fd42f08f646551468d9 (diff) | |
download | git-fa250759794ab98e6edfbbf2f6aa2cb912e535eb.tar.gz |
fetch: report ref storage DF errors more accurately
When we fail to store a fetched ref, we recommend that the
user try running "git prune" to remove up any old refs that
have been deleted by the remote, which would clear up any DF
conflicts. However, ref storage might fail for other
reasons (e.g., permissions problems) in which case the
advice is useless and misleading.
This patch detects when there is an actual DF situation and
only issues the advice when one is found.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r-- | builtin-fetch.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c index 3c998ea740..1f7a3f1ce6 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -167,6 +167,9 @@ static struct ref *get_ref_map(struct transport *transport, return ref_map; } +#define STORE_REF_ERROR_OTHER 1 +#define STORE_REF_ERROR_DF_CONFLICT 2 + static int s_update_ref(const char *action, struct ref *ref, int check_old) @@ -181,9 +184,11 @@ static int s_update_ref(const char *action, lock = lock_any_ref_for_update(ref->name, check_old ? ref->old_sha1 : NULL, 0); if (!lock) - return 2; + return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT : + STORE_REF_ERROR_OTHER; if (write_ref_sha1(lock, ref->new_sha1, msg) < 0) - return 2; + return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT : + STORE_REF_ERROR_OTHER; return 0; } @@ -377,7 +382,7 @@ static int store_updated_refs(const char *url, const char *remote_name, } } fclose(fp); - if (rc & 2) + if (rc & STORE_REF_ERROR_DF_CONFLICT) error("some local refs could not be updated; try running\n" " 'git remote prune %s' to remove any old, conflicting " "branches", remote_name); |