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 <gitster@pobox.com>
Junio C Hamano committed
Nov 3, 2011 at 12:15 UTC
ee6dfb2d83ba1b057943e705f707fa27e34e47f9
1 file changed
+11
-6
builtin/receive-pack.c
+11
-6
@@ -634,7 +634,7 @@ static int command_singleton_iterator(void *cb_data, unsigned char sha1[20])
634
struct command **cmd_list = cb_data;
635
struct command *cmd = *cmd_list;
636
637
- if (!cmd)
637
+ if (!cmd || is_null_sha1(cmd->new_sha1))
638
return -1; /* end of list */
639
*cmd_list = NULL; /* this returns only one */
640
hashcpy(sha1, cmd->new_sha1);
@@ -659,11 +659,16 @@ static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])
659
struct command **cmd_list = cb_data;
660
struct command *cmd = *cmd_list;
661
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 */
672
}
673
674
static void execute_commands(struct command *commands, const char *unpacker_error)