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>
Jeff King committed
May 25, 2009 at 06:40 UTC
fa250759794ab98e6edfbbf2f6aa2cb912e535eb
1 file changed
+8
-3
builtin-fetch.c
+8
-3
@@ -167,6 +167,9 @@ static struct ref *get_ref_map(struct transport *transport,
167
return ref_map;
168
}
169
170
+#define STORE_REF_ERROR_OTHER 1
171
+#define STORE_REF_ERROR_DF_CONFLICT 2
172
+
173
static int s_update_ref(const char *action,
174
struct ref *ref,
175
int check_old)
@@ -181,9 +184,11 @@ static int s_update_ref(const char *action,
184
lock = lock_any_ref_for_update(ref->name,
185
check_old ? ref->old_sha1 : NULL, 0);
186
if (!lock)
184
- return 2;
187
+ return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
188
+ STORE_REF_ERROR_OTHER;
189
if (write_ref_sha1(lock, ref->new_sha1, msg) < 0)
186
- return 2;
190
+ return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
191
+ STORE_REF_ERROR_OTHER;
192
return 0;
193
}
194
@@ -377,7 +382,7 @@ static int store_updated_refs(const char *url, const char *remote_name,
382
}
383
}
384
fclose(fp);
380
- if (rc & 2)
385
+ if (rc & STORE_REF_ERROR_DF_CONFLICT)
386
error("some local refs could not be updated; try running\n"
387
" 'git remote prune %s' to remove any old, conflicting "
388
"branches", remote_name);