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

Re: error from 'git push' on v1.7.8-rc0

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 3, 2011, 19:15 UTC
Message-ID
<7vhb2lf26b.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vmxcdf2x7.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> Stefan Näwe <stefan.naewe@gmail.com> writes:
>
>> I get errors from git push when trying to delete a (remote) branch:
>>
>> $ ./bin-wrappers/git versiongit version 1.7.8.rc0
>> $ ./bin-wrappers/git push -q . :refs/heads/nogofatal: bad object
>> 0000000000000000000000000000000000000000fatal: bad object
>> 0000000000000000000000000000000000000000remote: warning: Allowing
>> deletion of corrupt ref.
>
> Thanks. I think the operation does _not_ error out and fail to delete, but
> I agree that the "fatal:" message should be squelched.
-- >8 --
Subject: receive-pack: do not expect object 0{40} to exist

When pushing to delete a ref, it uses 0{40} as an object name to signal that the request is a deletion. We shouldn't trigger "deletion of a corrupt ref" warning in such a case, which was designed to notice that a ref points at an object that is truly missing from the repository.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/receive-pack.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 261b610..7ec68a1 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -634,7 +634,7 @@ static int command_singleton_iterator(void *cb_data, unsigned char sha1[20])
 	struct command **cmd_list = cb_data;
 	struct command *cmd = *cmd_list;
 
-	if (!cmd)
+	if (!cmd || is_null_sha1(cmd->new_sha1))
 		return -1; /* end of list */
 	*cmd_list = NULL; /* this returns only one */
 	hashcpy(sha1, cmd->new_sha1);
@@ -659,11 +659,16 @@ static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])
 	struct command **cmd_list = cb_data;
 	struct command *cmd = *cmd_list;
 
-	if (!cmd)
-		return -1; /* end of list */
-	*cmd_list = cmd->next;
-	hashcpy(sha1, cmd->new_sha1);
-	return 0;
+	while (cmd) {
+		if (!is_null_sha1(cmd->new_sha1)) {
+			hashcpy(sha1, cmd->new_sha1);
+			*cmd_list = cmd->next;
+			return 0;
+		}
+		cmd = cmd->next;
+	}
+	*cmd_list = NULL;
+	return -1; /* end of list */
 }
 
 static void execute_commands(struct command *commands, const char *unpacker_error)
Previous: Junio C Hamano
Message 5 of 5 in “error from 'git push' on v1.7.8-rc0”
  1. Stefan NäweNov 3, 2011
  2. Stefan NäweNov 3, 2011
  3. Stefan NaeweNov 3, 2011
  4. Junio C HamanoNov 3, 2011
  5. Junio C HamanoNov 3, 2011

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.