Skip to content

Commit ee6dfb2

Browse files
committed
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. Reported-by: Stefan Näwe Signed-off-by: Junio C Hamano <[email protected]>
1 parent db85b3a commit ee6dfb2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

builtin/receive-pack.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ static int command_singleton_iterator(void *cb_data, unsigned char sha1[20])
634634
struct command **cmd_list = cb_data;
635635
struct command *cmd = *cmd_list;
636636

637-
if (!cmd)
637+
if (!cmd || is_null_sha1(cmd->new_sha1))
638638
return -1; /* end of list */
639639
*cmd_list = NULL; /* this returns only one */
640640
hashcpy(sha1, cmd->new_sha1);
@@ -659,11 +659,16 @@ static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])
659659
struct command **cmd_list = cb_data;
660660
struct command *cmd = *cmd_list;
661661

662-
if (!cmd)
663-
return -1; /* end of list */
664-
*cmd_list = cmd->next;
665-
hashcpy(sha1, cmd->new_sha1);
666-
return 0;
662+
while (cmd) {
663+
if (!is_null_sha1(cmd->new_sha1)) {
664+
hashcpy(sha1, cmd->new_sha1);
665+
*cmd_list = cmd->next;
666+
return 0;
667+
}
668+
cmd = cmd->next;
669+
}
670+
*cmd_list = NULL;
671+
return -1; /* end of list */
667672
}
668673

669674
static void execute_commands(struct command *commands, const char *unpacker_error)

0 commit comments

Comments
 (0)