]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-send-pack.c
Merge branch 'ar/maint-mksnpath' into maint
[git.git] / builtin-send-pack.c
index bb9c33a6506290edad096acaa52330dd48df6135..ed94f9a460336d84ef5c1edcc0c4b5a26163c74d 100644 (file)
@@ -8,7 +8,7 @@
 #include "send-pack.h"
 
 static const char send_pack_usage[] =
-"git-send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
+"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
 "  --all and explicit <ref> specification are mutually exclusive.";
 
 static struct send_pack_args args = {
@@ -43,7 +43,7 @@ static int pack_objects(int fd, struct ref *refs)
        po.out = fd;
        po.git_cmd = 1;
        if (start_command(&po))
-               die("git-pack-objects failed (%s)", strerror(errno));
+               die("git pack-objects failed (%s)", strerror(errno));
 
        /*
         * We feed the pack-objects we just spawned with revision
@@ -132,7 +132,13 @@ static struct ref *remote_refs, **remote_tail;
 static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct ref *ref;
-       int len = strlen(refname) + 1;
+       int len;
+
+       /* we already know it starts with refs/ to get here */
+       if (check_ref_format(refname + 5))
+               return 0;
+
+       len = strlen(refname) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
        hashcpy(ref->new_sha1, sha1);
        memcpy(ref->name, refname, len);
@@ -226,8 +232,7 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
                if (args.verbose)
                        fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst);
                if (ref->deletion) {
-                       if (delete_ref(rs.dst, NULL))
-                               error("Failed to delete");
+                       delete_ref(rs.dst, NULL, 0);
                } else
                        update_ref("update by push", rs.dst,
                                        ref->new_sha1, NULL, 0, 0);
@@ -537,9 +542,17 @@ static void verify_remote_names(int nr_heads, const char **heads)
        int i;
 
        for (i = 0; i < nr_heads; i++) {
+               const char *local = heads[i];
                const char *remote = strrchr(heads[i], ':');
 
-               remote = remote ? (remote + 1) : heads[i];
+               if (*local == '+')
+                       local++;
+
+               /* A matching refspec is okay.  */
+               if (remote == local && remote[1] == '\0')
+                       continue;
+
+               remote = remote ? (remote + 1) : local;
                switch (check_ref_format(remote)) {
                case 0: /* ok */
                case CHECK_REF_FORMAT_ONELEVEL: