git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Clemens Buchacher <drizzd@aon.at>
Date
Feb 18, 2008, 16:44 UTC
Message-ID
<20080218164423.GA8832@localhost>
In-Reply-To
<20080218155546.GA8934@localhost>

This mirrors current ssh/git push syntax. ---

The previous patch gives the wrong branch name in the failure message.
Clemens
 http-push.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/http-push.c b/http-push.c
index f9b77d6..2c928fc 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.183.g69d3
Previous: Clemens BuchacherNext: Johannes Schindelin
Message 4 of 27 in “http-push: Fix error message for push <remote> :<branch>”
  1. http-push: Fix error message for push <remote> :<branch>Clemens Buchacher, Feb 18, 2008
  2. Johannes SchindelinFeb 18, 2008
  3. http-push: push <remote> :<branch> deletes remote branchClemens Buchacher, Feb 18, 2008
  4. http-push: push <remote> :<branch> deletes remote branchClemens Buchacher, Feb 18, 2008
  5. Johannes SchindelinFeb 18, 2008
  6. Johannes SchindelinFeb 18, 2008
  7. Clemens BuchacherFeb 19, 2008
  8. Johannes SchindelinFeb 19, 2008
  9. Mike HommeyFeb 19, 2008
  10. Johannes SchindelinFeb 19, 2008
  11. Junio C HamanoFeb 19, 2008
  12. Johannes SchindelinFeb 19, 2008
  13. http-push: add regression testsClemens Buchacher, Feb 23, 2008
  14. Mike HommeyFeb 24, 2008
  15. http-push: add regression testsClemens Buchacher, Feb 24, 2008
  16. Mike HommeyFeb 24, 2008
  17. Clemens BuchacherFeb 24, 2008
  18. http-push: add regression testsClemens Buchacher, Feb 25, 2008
  19. Junio C HamanoFeb 26, 2008
  20. http-push: add regression testsClemens Buchacher, Feb 27, 2008
  21. Mike HommeyFeb 27, 2008
  22. Johannes SchindelinFeb 27, 2008
  23. Clemens BuchacherFeb 27, 2008
  24. 1/2 http-push: push <remote> :<branch> deletes remote branchClemens Buchacher, Feb 27, 2008
  25. 2/2 http-push: add regression testsClemens Buchacher, Feb 27, 2008
  26. Johannes SchindelinFeb 27, 2008
  27. Mike HommeyFeb 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.