diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-05-29 12:34:45 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-29 12:34:45 +0900 |
commit | 220c6a70803d520a7cd19f9f2889650d54574470 (patch) | |
tree | 511bbcf9b63f7152729a716d8dbd049d2376ed29 /git-compat-util.h | |
parent | 15c96723457cfa1be6cdbd74e3131ecf13cd9790 (diff) | |
parent | 3d7dd2d3b6ccc8903a37cffe3a2f39cf1be21c86 (diff) | |
download | git-220c6a70803d520a7cd19f9f2889650d54574470.tar.gz |
Merge branch 'jk/bug-to-abort'
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.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index ab7552a7ce..98670a3c9a 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1069,6 +1069,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 |