X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=connect.c;h=66daa11a5737efd6ee2dbd6ff2ad0e1475fcba20;hb=e27e609bbf81271318d99f2643f378f3fde6c6c6;hp=b9666cc0d826890b5e84a58c7f7ed52ff56c3e79;hpb=54acddce99ee0260b7b0a47fda3e2f74c3b983c3;p=git.git diff --git a/connect.c b/connect.c index b9666cc0d..66daa11a5 100644 --- a/connect.c +++ b/connect.c @@ -3,12 +3,6 @@ #include "pkt-line.h" #include "quote.h" #include "refs.h" -#include -#include -#include -#include -#include -#include static char *server_capabilities; @@ -144,6 +138,7 @@ struct refspec { * +A:B means overwrite remote B with local A. * +A is a shorthand for +A:A. * A is a shorthand for A:A. + * :B means delete remote B. */ static struct refspec *parse_ref_spec(int nr_refspec, char **refspec) { @@ -240,6 +235,13 @@ static struct ref *try_explicit_object_name(const char *name) unsigned char sha1[20]; struct ref *ref; int len; + + if (!*name) { + ref = xcalloc(1, sizeof(*ref) + 20); + strcpy(ref->name, "(delete)"); + hashclr(ref->new_sha1); + return ref; + } if (get_sha1(name, sha1)) return NULL; len = strlen(name) + 1; @@ -262,7 +264,8 @@ static int match_explicit_refs(struct ref *src, struct ref *dst, break; case 0: /* The source could be in the get_sha1() format - * not a reference name. + * not a reference name. :refs/other is a + * way to delete 'other' ref at the remote end. */ matched_src = try_explicit_object_name(rs[i].src); if (matched_src)