]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-fetch.c
Merge git://git.kernel.org/pub/scm/gitk/gitk
[git.git] / builtin-fetch.c
index 7c16d38de7ddd52883cee79392cf4aa9d8492a96..7eec4a0e43ad5760f1060a7d5bcf2a5083015130 100644 (file)
@@ -5,14 +5,14 @@
 #include "refs.h"
 #include "commit.h"
 #include "builtin.h"
-#include "path-list.h"
+#include "string-list.h"
 #include "remote.h"
 #include "transport.h"
 #include "run-command.h"
 #include "parse-options.h"
 
 static const char * const builtin_fetch_usage[] = {
-       "git-fetch [options] [<repository> <refspec>...]",
+       "git fetch [options] [<repository> <refspec>...]",
        NULL
 };
 
@@ -181,9 +181,9 @@ 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 1;
+               return 2;
        if (write_ref_sha1(lock, ref->new_sha1, msg) < 0)
-               return 1;
+               return 2;
        return 0;
 }
 
@@ -294,7 +294,8 @@ static int update_local_ref(struct ref *ref,
        }
 }
 
-static int store_updated_refs(const char *url, struct ref *ref_map)
+static int store_updated_refs(const char *url, const char *remote_name,
+               struct ref *ref_map)
 {
        FILE *fp;
        struct commit *commit;
@@ -380,6 +381,10 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
                }
        }
        fclose(fp);
+       if (rc & 2)
+               error("some local refs could not be updated; try running\n"
+                     " 'git remote prune %s' to remove any old, conflicting "
+                     "branches", remote_name);
        return rc;
 }
 
@@ -450,7 +455,9 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
        if (ret)
                ret = transport_fetch_refs(transport, ref_map);
        if (!ret)
-               ret |= store_updated_refs(transport->url, ref_map);
+               ret |= store_updated_refs(transport->url,
+                               transport->remote->name,
+                               ref_map);
        transport_unlock_pack(transport);
        return ret;
 }
@@ -458,8 +465,8 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
 static int add_existing(const char *refname, const unsigned char *sha1,
                        int flag, void *cbdata)
 {
-       struct path_list *list = (struct path_list *)cbdata;
-       path_list_insert(refname, list);
+       struct string_list *list = (struct string_list *)cbdata;
+       string_list_insert(refname, list);
        return 0;
 }
 
@@ -478,8 +485,8 @@ static void find_non_local_tags(struct transport *transport,
                        struct ref **head,
                        struct ref ***tail)
 {
-       struct path_list existing_refs = { NULL, 0, 0, 0 };
-       struct path_list new_refs = { NULL, 0, 0, 1 };
+       struct string_list existing_refs = { NULL, 0, 0, 0 };
+       struct string_list new_refs = { NULL, 0, 0, 1 };
        char *ref_name;
        int ref_name_len;
        const unsigned char *ref_sha1;
@@ -508,11 +515,11 @@ static void find_non_local_tags(struct transport *transport,
                        }
                }
 
-               if (!path_list_has_path(&existing_refs, ref_name) &&
-                   !path_list_has_path(&new_refs, ref_name) &&
+               if (!string_list_has_string(&existing_refs, ref_name) &&
+                   !string_list_has_string(&new_refs, ref_name) &&
                    (has_sha1_file(ref->old_sha1) ||
                     will_fetch(head, ref->old_sha1))) {
-                       path_list_insert(ref_name, &new_refs);
+                       string_list_insert(ref_name, &new_refs);
 
                        rm = alloc_ref_from_str(ref_name);
                        rm->peer_ref = alloc_ref_from_str(ref_name);
@@ -523,8 +530,8 @@ static void find_non_local_tags(struct transport *transport,
                }
                free(ref_name);
        }
-       path_list_clear(&existing_refs, 0);
-       path_list_clear(&new_refs, 0);
+       string_list_clear(&existing_refs, 0);
+       string_list_clear(&new_refs, 0);
 }
 
 static int do_fetch(struct transport *transport,