receive-pack: use bug() and BUG_if_bug()

Amend code added in a6a84319686 (receive-pack.c: shorten the execute_commands loop over all commands, 2015-01-07) and amended to hard die in b6a4788586d (receive-pack.c: die instead of error in case of possible future bug, 2015-01-07) to use the new bug() function instead. Let's also rename the warn_if_*() function that code is in to BUG_if_*(), its name became outdated in b6a4788586d. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 2, 2022 at 14:25 UTC 07b1d8f184e126eef8223757844587cf91d6e14c
1 file changed +6 -10
builtin/receive-pack.c
+6 -10
@@ -1810,21 +1810,17 @@ static int should_process_cmd(struct command *cmd)
1810 return !cmd->error_string && !cmd->skip_update;
1811 }
1812
1813 -static void warn_if_skipped_connectivity_check(struct command *commands,
1813 +static void BUG_if_skipped_connectivity_check(struct command *commands,
1814 struct shallow_info *si)
1815 {
1816 struct command *cmd;
1817 - int checked_connectivity = 1;
1817
1818 for (cmd = commands; cmd; cmd = cmd->next) {
1820 - if (should_process_cmd(cmd) && si->shallow_ref[cmd->index]) {
1821 - error("BUG: connectivity check has not been run on ref %s",
1822 - cmd->ref_name);
1823 - checked_connectivity = 0;
1824 - }
1819 + if (should_process_cmd(cmd) && si->shallow_ref[cmd->index])
1820 + bug("connectivity check has not been run on ref %s",
1821 + cmd->ref_name);
1822 }
1826 - if (!checked_connectivity)
1827 - BUG("connectivity check skipped???");
1823 + BUG_if_bug("connectivity check skipped???");
1824 }
1825
1826 static void execute_commands_non_atomic(struct command *commands,
@@ -2005,7 +2001,7 @@ static void execute_commands(struct command *commands,
2001 execute_commands_non_atomic(commands, si);
2002
2003 if (shallow_update)
2008 - warn_if_skipped_connectivity_check(commands, si);
2004 + BUG_if_skipped_connectivity_check(commands, si);
2005 }
2006
2007 static struct command **queue_command(struct command **tail,