Skip to content

Commit

Permalink
receive-pack: do not expect object 0{40} to exist
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Nov 3, 2011
1 parent db85b3a commit ee6dfb2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit ee6dfb2

Please sign in to comment.