diff options
author | Junio C Hamano <junkio@cox.net> | 2006-11-24 11:26:49 +0300 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-11-24 14:59:05 +0300 |
commit | d4f694ba89857a87e259557d0f236c761b4041ef (patch) | |
tree | 08453ccc3a39a74ad5e74ff4bf1cf13dd88b85c7 /connect.c | |
parent | 634b8d05142a4812bf35fe8b14cc62c84494c78f (diff) |
Allow git push to delete remote ref.
This allows you to say
git send-pack $URL :refs/heads/$branch
to delete the named remote branch. The refspec $src:$dst means
replace the destination ref with the object known as $src on the
local side, so this is a natural extension to make an empty $src
mean "No object" to delete the target.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/connect.c b/connect.c index b9666cc0d82..f7edba82c4d 100644 --- a/connect.c +++ b/connect.c @@ -144,6 +144,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 +241,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 +270,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) |