git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Mike Hommey <mh@glandium.org>,
	git@vger.kernel.org
Subject: [PATCH 1/2] http-push: push <remote> :<branch> deletes remote branch
Date: Wed, 27 Feb 2008 20:27:53 +0100	[thread overview]
Message-ID: <20080227192753.GB1818@localhost> (raw)
In-Reply-To: <20080227192334.GA1818@localhost>

This mirrors current ssh/git push syntax.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
 http-push.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/http-push.c b/http-push.c
index 0beb740..4b31070 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);
-- 
1.5.4.2.156.ge3c5

  reply	other threads:[~2008-02-27 19:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-18 13:07 [PATCH] http-push: Fix error message for push <remote> :<branch> Clemens Buchacher
2008-02-18 13:45 ` Johannes Schindelin
2008-02-18 15:55   ` [PATCH] http-push: push <remote> :<branch> deletes remote branch Clemens Buchacher
2008-02-18 16:44     ` Clemens Buchacher
2008-02-18 17:35       ` Johannes Schindelin
2008-02-18 17:34     ` Johannes Schindelin
2008-02-19 12:58       ` Clemens Buchacher
2008-02-19 13:17         ` Johannes Schindelin
2008-02-19 13:24           ` Mike Hommey
2008-02-19 13:31             ` Johannes Schindelin
2008-02-19 21:35               ` Junio C Hamano
2008-02-19 22:25                 ` Johannes Schindelin
2008-02-23 21:28       ` [PATCH] http-push: add regression tests Clemens Buchacher
2008-02-24  8:58         ` Mike Hommey
2008-02-24 18:03           ` Clemens Buchacher
2008-02-24 18:48             ` Mike Hommey
2008-02-24 19:14               ` Clemens Buchacher
2008-02-25 23:28               ` Clemens Buchacher
2008-02-26  0:24                 ` Junio C Hamano
2008-02-27  8:54                   ` Clemens Buchacher
2008-02-27  9:16                     ` Mike Hommey
2008-02-27  9:51                     ` Johannes Schindelin
2008-02-27 19:23                       ` Clemens Buchacher
2008-02-27 19:27                         ` Clemens Buchacher [this message]
2008-02-27 19:28                         ` [PATCH 2/2] " Clemens Buchacher
2008-02-27 22:24                         ` [PATCH] " Johannes Schindelin
2008-02-26 19:32                 ` Mike Hommey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080227192753.GB1818@localhost \
    --to=drizzd@aon.at \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mh@glandium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).