]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ab/bug-if-bug'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Jun 2022 22:04:15 +0000 (15:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jun 2022 22:04:15 +0000 (15:04 -0700)
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

1  2 
builtin/receive-pack.c
cache-tree.c
git-compat-util.h

Simple merge
diff --cc cache-tree.c
Simple merge
index d9457b9aae4f88a3afd461826d77a87e7e776ddb,ce007102f76ded24ed284001a8f966f194729614..fd36d3bfdc4c7370e24f411515d5bd0da9dbe735
@@@ -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