summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 13:26:59 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 13:26:59 -0700
commit7a190a215dbcf782c33ed531104389de8504e29d (patch)
tree05b00d7adb3abb89de530834599a5daa04a6d026 /git-compat-util.h
parentMerge branch 'sb/checkout-recurse-submodules' into maint (diff)
parentusage: add NORETURN to BUG() function definitions (diff)
downloadtgif-7a190a215dbcf782c33ed531104389de8504e29d.tar.xz
Merge branch 'jk/bug-to-abort' into maint
Introduce the BUG() macro to improve die("BUG: ..."). * jk/bug-to-abort: usage: add NORETURN to BUG() function definitions config: complain about --local outside of a git repo setup_git_env: convert die("BUG") to BUG() usage.c: add BUG() function
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index bd04564a69..4575b3890b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1064,6 +1064,15 @@ static inline int regexec_buf(const regex_t *preg, const char *buf, size_t size,
#define HAVE_VARIADIC_MACROS 1
#endif
+#ifdef HAVE_VARIADIC_MACROS
+__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__)
+#else
+__attribute__((format (printf, 1, 2))) NORETURN
+void BUG(const char *fmt, ...);
+#endif
+
/*
* Preserves errno, prints a message, but gives no warning for ENOENT.
* Returns 0 on success, which includes trying to unlink an object that does