[PATCH 1/2] http-push: push <remote> :<branch> deletes remote branch

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Clemens Buchacher
Date: Wednesday, February 27, 2008 - 12:27 pm

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] http-push: add regression tests, Clemens Buchacher, (Sat Feb 23, 2:28 pm)
Re: [PATCH] http-push: add regression tests, Mike Hommey, (Sun Feb 24, 1:58 am)
[PATCH] http-push: add regression tests, Clemens Buchacher, (Sun Feb 24, 11:03 am)
Re: [PATCH] http-push: add regression tests, Mike Hommey, (Sun Feb 24, 11:48 am)
Re: [PATCH] http-push: add regression tests, Clemens Buchacher, (Sun Feb 24, 12:14 pm)
[PATCH] http-push: add regression tests, Clemens Buchacher, (Mon Feb 25, 4:28 pm)
Re: [PATCH] http-push: add regression tests, Junio C Hamano, (Mon Feb 25, 5:24 pm)
Re: [PATCH] http-push: add regression tests, Mike Hommey, (Tue Feb 26, 12:32 pm)
[PATCH] http-push: add regression tests, Clemens Buchacher, (Wed Feb 27, 1:54 am)
Re: [PATCH] http-push: add regression tests, Mike Hommey, (Wed Feb 27, 2:16 am)
Re: [PATCH] http-push: add regression tests, Johannes Schindelin, (Wed Feb 27, 2:51 am)
Re: [PATCH] http-push: add regression tests, Clemens Buchacher, (Wed Feb 27, 12:23 pm)
[PATCH 1/2] http-push: push <remote> :<branch> deletes rem ..., Clemens Buchacher, (Wed Feb 27, 12:27 pm)
[PATCH 2/2] http-push: add regression tests, Clemens Buchacher, (Wed Feb 27, 12:28 pm)
Re: [PATCH] http-push: add regression tests, Johannes Schindelin, (Wed Feb 27, 3:24 pm)