Skip to content

Commit

Permalink
http-push: push <remote> :<branch> deletes remote branch
Browse files Browse the repository at this point in the history
This mirrors current ssh/git push syntax.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Clemens Buchacher authored and Junio C Hamano committed Feb 27, 2008
1 parent 2db511f commit 6eaf406
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6eaf406

Please sign in to comment.