From: Junio C Hamano Date: Mon, 29 May 2017 03:34:45 +0000 (+0900) Subject: Merge branch 'jk/bug-to-abort' X-Git-Tag: v2.14.0-rc0~161 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/220c6a70803d520a7cd19f9f2889650d54574470?ds=inline;hp=-c 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 --- 220c6a70803d520a7cd19f9f2889650d54574470 diff --combined environment.c index 560408953c,1f0bda5afa..aa478e71de --- a/environment.c +++ b/environment.c @@@ -169,7 -169,7 +169,7 @@@ static void setup_git_env(void git_dir = getenv(GIT_DIR_ENVIRONMENT); if (!git_dir) { if (!startup_info->have_repository) - die("BUG: setup_git_env called without repository"); + BUG("setup_git_env called without repository"); git_dir = DEFAULT_GIT_DIR_ENVIRONMENT; } gitfile = read_gitfile(git_dir); @@@ -217,8 -217,6 +217,8 @@@ const char *get_git_dir(void const char *get_git_common_dir(void) { + if (!git_dir) + setup_git_env(); return git_common_dir; } diff --combined git-compat-util.h index ab7552a7ce,4575b3890b..98670a3c9a --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -319,11 -319,6 +319,11 @@@ extern char *gitdirname(char *) #define PRIo32 "o" #endif +typedef uintmax_t timestamp_t; +#define PRItime PRIuMAX +#define parse_timestamp strtoumax +#define TIME_MAX UINTMAX_MAX + #ifndef PATH_SEP #define PATH_SEP ':' #endif @@@ -621,7 -616,7 +621,7 @@@ extern int git_lstat(const char *, stru #endif #define DEFAULT_PACKED_GIT_LIMIT \ - ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? 8192 : 256)) + ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? (32 * 1024L * 1024L) : 256)) #ifdef NO_PREAD #define pread git_pread @@@ -1069,6 -1064,15 +1069,15 @@@ static inline int regexec_buf(const reg #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