summaryrefslogtreecommitdiff
path: root/http-push.c
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2008-02-27 20:27:53 +0100
committerJunio C Hamano <gitster@pobox.com>2008-02-27 15:38:24 -0800
commit6eaf40608dfe0c23aa990a8c7d4a135df1af3cab (patch)
tree481f9e8ca39880aa1e743c28bd2ba1802d291794 /http-push.c
parent2db511fdbdbe1c8aab80f4bc13f0df037bce8a33 (diff)
downloadgit-6eaf40608dfe0c23aa990a8c7d4a135df1af3cab.tar.gz
http-push: push <remote> :<branch> deletes remote branch
This mirrors current ssh/git push syntax. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-push.c')
-rw-r--r--http-push.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/http-push.c b/http-push.c
index 0beb7406c3..4b31070eb9 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2138,6 +2138,8 @@ static int delete_remote_branch(char *pattern, int force)
/* Send delete request */
fprintf(stderr, "Removing remote branch '%s'\n", remote_ref->name);
+ if (dry_run)
+ return 0;
url = xmalloc(strlen(remote->url) + strlen(remote_ref->name) + 1);
sprintf(url, "%s%s", remote->url, remote_ref->name);
slot = get_active_slot();
@@ -2311,6 +2313,16 @@ int main(int argc, char **argv)
if (!ref->peer_ref)
continue;
+
+ if (is_zero_sha1(ref->peer_ref->new_sha1)) {
+ if (delete_remote_branch(ref->name, 1) == -1) {
+ error("Could not remove %s", ref->name);
+ rc = -4;
+ }
+ new_refs++;
+ continue;
+ }
+
if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
if (push_verbosely || 1)
fprintf(stderr, "'%s': up-to-date\n", ref->name);
@@ -2342,11 +2354,6 @@ int main(int argc, char **argv)
}
}
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
- if (is_zero_sha1(ref->new_sha1)) {
- error("cannot happen anymore");
- rc = -3;
- continue;
- }
new_refs++;
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
new_hex = sha1_to_hex(ref->new_sha1);