From: Junio C Hamano Date: Fri, 10 Jun 2022 22:04:15 +0000 (-0700) Subject: Merge branch 'ab/bug-if-bug' X-Git-Tag: v2.37.0-rc0~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4da14b574f2e52eb05e4fef7ed169a8f9e3a8b67;p=thirdparty%2Fgit.git Merge branch 'ab/bug-if-bug' A new bug() and BUG_if_bug() API is introduced to make it easier to uniformly log "detect multiple bugs and abort in the end" pattern. * ab/bug-if-bug: cache-tree.c: use bug() and BUG_if_bug() receive-pack: use bug() and BUG_if_bug() parse-options.c: use optbug() instead of BUG() "opts" check parse-options.c: use new bug() API for optbug() usage.c: add a non-fatal bug() function to go with BUG() common-main.c: move non-trace2 exit() behavior out of trace2.c --- 4da14b574f2e52eb05e4fef7ed169a8f9e3a8b67 diff --cc git-compat-util.h index d9457b9aae,ce007102f7..fd36d3bfdc --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -1329,8 -1326,14 +1332,15 @@@ extern int bug_called_must_BUG __attribute__((format (printf, 3, 4))) NORETURN void BUG_fl(const char *file, int line, const char *fmt, ...); #define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__) + __attribute__((format (printf, 3, 4))) + void bug_fl(const char *file, int line, const char *fmt, ...); + #define bug(...) bug_fl(__FILE__, __LINE__, __VA_ARGS__) + #define BUG_if_bug(...) do { \ + if (bug_called_must_BUG) \ + BUG_fl(__FILE__, __LINE__, __VA_ARGS__); \ + } while (0) +#ifndef FSYNC_METHOD_DEFAULT #ifdef __APPLE__ #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY #else