{"thread":{"id":"59951","subject":"[PATCH v5 1/6] git-compat-util: move strbuf.c funcs to its header","startedAt":"2023-07-05T17:09:44Z","lastAt":"2023-07-05T17:15:47Z","messageCount":7,"participants":["Calvin Wan"],"isPatch":true,"patchVersion":5,"patchTotal":6},"messages":[{"id":"479201","messageId":"20230705170924.3833828-1-calvinwan@google.com","threadId":"59951","inReplyTo":"20230705170812.3833103-1-calvinwan@google.com","subject":"[PATCH v5 1/6] git-compat-util: move strbuf.c funcs to its header","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:09:19Z","receivedAt":"2023-07-05T17:09:44Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"While functions like starts_with() probably should not belong in the\nboundaries of the strbuf library, this commit focuses on first splitting\nout headers from git-compat-util.h.\n\nSigned-off-by: Calvin Wan <calvinwan@google.com>\n---\n builtin/symbolic-ref.c   |  1 +\n builtin/unpack-objects.c |  1 +\n git-compat-util.h        | 32 --------------------------------\n strbuf.h                 | 32 ++++++++++++++++++++++++++++++++\n versioncmp.c             |  1 +\n 5 files changed, 35 insertions(+), 32 deletions(-)\n\ndiff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c\nindex a61fa3c0f8..c9defe4d2e 100644\n--- a/builtin/symbolic-ref.c\n+++ b/builtin/symbolic-ref.c\n@@ -3,6 +3,7 @@\n #include \"gettext.h\"\n #include \"refs.h\"\n #include \"parse-options.h\"\n+#include \"strbuf.h\"\n \n static const char * const git_symbolic_ref_usage[] = {\n \tN_(\"git symbolic-ref [-m <reason>] <name> <ref>\"),\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 1979532a9d..84b68304ed 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -12,6 +12,7 @@\n #include \"blob.h\"\n #include \"commit.h\"\n #include \"replace-object.h\"\n+#include \"strbuf.h\"\n #include \"tag.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex ae88291976..78a993c604 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -679,9 +679,6 @@ void set_warn_routine(report_fn routine);\n report_fn get_warn_routine(void);\n void set_die_is_recursing_routine(int (*routine)(void));\n \n-int starts_with(const char *str, const char *prefix);\n-int istarts_with(const char *str, const char *prefix);\n-\n /*\n  * If the string \"str\" begins with the string found in \"prefix\", return 1.\n  * The \"out\" parameter is set to \"str + strlen(prefix)\" (i.e., to the point in\n@@ -710,29 +707,6 @@ static inline int skip_prefix(const char *str, const char *prefix,\n \treturn 0;\n }\n \n-/*\n- * If the string \"str\" is the same as the string in \"prefix\", then the \"arg\"\n- * parameter is set to the \"def\" parameter and 1 is returned.\n- * If the string \"str\" begins with the string found in \"prefix\" and then a\n- * \"=\" sign, then the \"arg\" parameter is set to \"str + strlen(prefix) + 1\"\n- * (i.e., to the point in the string right after the prefix and the \"=\" sign),\n- * and 1 is returned.\n- *\n- * Otherwise, return 0 and leave \"arg\" untouched.\n- *\n- * When we accept both a \"--key\" and a \"--key=<val>\" option, this function\n- * can be used instead of !strcmp(arg, \"--key\") and then\n- * skip_prefix(arg, \"--key=\", &arg) to parse such an option.\n- */\n-int skip_to_optional_arg_default(const char *str, const char *prefix,\n-\t\t\t\t const char **arg, const char *def);\n-\n-static inline int skip_to_optional_arg(const char *str, const char *prefix,\n-\t\t\t\t       const char **arg)\n-{\n-\treturn skip_to_optional_arg_default(str, prefix, arg, \"\");\n-}\n-\n /*\n  * Like skip_prefix, but promises never to read past \"len\" bytes of the input\n  * buffer, and returns the remaining number of bytes in \"out\" via \"outlen\".\n@@ -777,12 +751,6 @@ static inline int strip_suffix(const char *str, const char *suffix, size_t *len)\n \treturn strip_suffix_mem(str, len, suffix);\n }\n \n-static inline int ends_with(const char *str, const char *suffix)\n-{\n-\tsize_t len;\n-\treturn strip_suffix(str, suffix, &len);\n-}\n-\n #define SWAP(a, b) do {\t\t\t\t\t\t\\\n \tvoid *_swap_a_ptr = &(a);\t\t\t\t\\\n \tvoid *_swap_b_ptr = &(b);\t\t\t\t\\\ndiff --git a/strbuf.h b/strbuf.h\nindex 0528ab5010..fd43c46433 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -671,4 +671,36 @@ char *xstrvfmt(const char *fmt, va_list ap);\n __attribute__((format (printf, 1, 2)))\n char *xstrfmt(const char *fmt, ...);\n \n+int starts_with(const char *str, const char *prefix);\n+int istarts_with(const char *str, const char *prefix);\n+\n+/*\n+ * If the string \"str\" is the same as the string in \"prefix\", then the \"arg\"\n+ * parameter is set to the \"def\" parameter and 1 is returned.\n+ * If the string \"str\" begins with the string found in \"prefix\" and then a\n+ * \"=\" sign, then the \"arg\" parameter is set to \"str + strlen(prefix) + 1\"\n+ * (i.e., to the point in the string right after the prefix and the \"=\" sign),\n+ * and 1 is returned.\n+ *\n+ * Otherwise, return 0 and leave \"arg\" untouched.\n+ *\n+ * When we accept both a \"--key\" and a \"--key=<val>\" option, this function\n+ * can be used instead of !strcmp(arg, \"--key\") and then\n+ * skip_prefix(arg, \"--key=\", &arg) to parse such an option.\n+ */\n+int skip_to_optional_arg_default(const char *str, const char *prefix,\n+\t\t\t\t const char **arg, const char *def);\n+\n+static inline int skip_to_optional_arg(const char *str, const char *prefix,\n+\t\t\t\t       const char **arg)\n+{\n+\treturn skip_to_optional_arg_default(str, prefix, arg, \"\");\n+}\n+\n+static inline int ends_with(const char *str, const char *suffix)\n+{\n+\tsize_t len;\n+\treturn strip_suffix(str, suffix, &len);\n+}\n+\n #endif /* STRBUF_H */\ndiff --git a/versioncmp.c b/versioncmp.c\nindex 74cc7c43f0..45e676cbca 100644\n--- a/versioncmp.c\n+++ b/versioncmp.c\n@@ -1,5 +1,6 @@\n #include \"git-compat-util.h\"\n #include \"config.h\"\n+#include \"strbuf.h\"\n #include \"string-list.h\"\n #include \"versioncmp.h\"\n \n-- \n2.41.0.255.g8b1d071c50-goog\n\n"},{"id":"479202","messageId":"20230705170924.3833828-2-calvinwan@google.com","threadId":"59951","inReplyTo":"20230705170812.3833103-1-calvinwan@google.com","subject":"[PATCH v5 2/6] git-compat-util: move wrapper.c funcs to its header","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:09:20Z","receivedAt":"2023-07-05T17:09:52Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"Since the functions in wrapper.c are widely used across the codebase,\ninclude it by default in git-compat-util.h. A future patch will remove\nnow unnecessary inclusions of wrapper.h from other files.\n\nSigned-off-by: Calvin Wan <calvinwan@google.com>\n---\n git-compat-util.h | 112 +---------------------------------------------\n wrapper.h         | 111 +++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 112 insertions(+), 111 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 78a993c604..9140f43bbf 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -627,7 +627,7 @@ static inline int git_has_dir_sep(const char *path)\n \n #include \"compat/bswap.h\"\n \n-struct strbuf;\n+#include \"wrapper.h\"\n \n /* General helper functions */\n NORETURN void usage(const char *err);\n@@ -1047,36 +1047,6 @@ static inline int cast_size_t_to_int(size_t a)\n # define xalloca(size)      (xmalloc(size))\n # define xalloca_free(p)    (free(p))\n #endif\n-char *xstrdup(const char *str);\n-void *xmalloc(size_t size);\n-void *xmallocz(size_t size);\n-void *xmallocz_gently(size_t size);\n-void *xmemdupz(const void *data, size_t len);\n-char *xstrndup(const char *str, size_t len);\n-void *xrealloc(void *ptr, size_t size);\n-void *xcalloc(size_t nmemb, size_t size);\n-void xsetenv(const char *name, const char *value, int overwrite);\n-void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);\n-const char *mmap_os_err(void);\n-void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);\n-int xopen(const char *path, int flags, ...);\n-ssize_t xread(int fd, void *buf, size_t len);\n-ssize_t xwrite(int fd, const void *buf, size_t len);\n-ssize_t xpread(int fd, void *buf, size_t len, off_t offset);\n-int xdup(int fd);\n-FILE *xfopen(const char *path, const char *mode);\n-FILE *xfdopen(int fd, const char *mode);\n-int xmkstemp(char *temp_filename);\n-int xmkstemp_mode(char *temp_filename, int mode);\n-char *xgetcwd(void);\n-FILE *fopen_for_writing(const char *path);\n-FILE *fopen_or_warn(const char *path, const char *mode);\n-\n-/*\n- * Like strncmp, but only return zero if s is NUL-terminated and exactly len\n- * characters long.  If it is not, consider it greater than t.\n- */\n-int xstrncmpz(const char *s, const char *t, size_t len);\n \n /*\n  * FREE_AND_NULL(ptr) is like free(ptr) followed by ptr = NULL. Note\n@@ -1178,15 +1148,10 @@ static inline size_t xsize_t(off_t len)\n \treturn (size_t) len;\n }\n \n-__attribute__((format (printf, 3, 4)))\n-int xsnprintf(char *dst, size_t max, const char *fmt, ...);\n-\n #ifndef HOST_NAME_MAX\n #define HOST_NAME_MAX 256\n #endif\n \n-int xgethostname(char *buf, size_t len);\n-\n /* in ctype.c, for kwset users */\n extern const unsigned char tolower_trans_tbl[256];\n \n@@ -1427,72 +1392,6 @@ void bug_fl(const char *file, int line, const char *fmt, ...);\n #endif\n #endif\n \n-enum fsync_action {\n-\tFSYNC_WRITEOUT_ONLY,\n-\tFSYNC_HARDWARE_FLUSH\n-};\n-\n-/*\n- * Issues an fsync against the specified file according to the specified mode.\n- *\n- * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating\n- * systems to flush the OS cache without issuing a flush command to the storage\n- * controller. If those interfaces are unavailable, the function fails with\n- * ENOSYS.\n- *\n- * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that\n- * changes are durable. It is not expected to fail.\n- */\n-int git_fsync(int fd, enum fsync_action action);\n-\n-/*\n- * Writes out trace statistics for fsync using the trace2 API.\n- */\n-void trace_git_fsync_stats(void);\n-\n-/*\n- * Preserves errno, prints a message, but gives no warning for ENOENT.\n- * Returns 0 on success, which includes trying to unlink an object that does\n- * not exist.\n- */\n-int unlink_or_warn(const char *path);\n- /*\n-  * Tries to unlink file.  Returns 0 if unlink succeeded\n-  * or the file already didn't exist.  Returns -1 and\n-  * appends a message to err suitable for\n-  * 'error(\"%s\", err->buf)' on error.\n-  */\n-int unlink_or_msg(const char *file, struct strbuf *err);\n-/*\n- * Preserves errno, prints a message, but gives no warning for ENOENT.\n- * Returns 0 on success, which includes trying to remove a directory that does\n- * not exist.\n- */\n-int rmdir_or_warn(const char *path);\n-/*\n- * Calls the correct function out of {unlink,rmdir}_or_warn based on\n- * the supplied file mode.\n- */\n-int remove_or_warn(unsigned int mode, const char *path);\n-\n-/*\n- * Call access(2), but warn for any error except \"missing file\"\n- * (ENOENT or ENOTDIR).\n- */\n-#define ACCESS_EACCES_OK (1U << 0)\n-int access_or_warn(const char *path, int mode, unsigned flag);\n-int access_or_die(const char *path, int mode, unsigned flag);\n-\n-/* Warn on an inaccessible file if errno indicates this is an error */\n-int warn_on_fopen_errors(const char *path);\n-\n-/*\n- * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent\n- * may be racy. Do not use this as protection against an attacker who can\n- * simultaneously create paths.\n- */\n-int open_nofollow(const char *path, int flags);\n-\n #ifndef SHELL_PATH\n # define SHELL_PATH \"/bin/sh\"\n #endif\n@@ -1632,13 +1531,4 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset)\n \t((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))\n #endif /* !__GNUC__ */\n \n-void sleep_millisec(int millisec);\n-\n-/*\n- * Generate len bytes from the system cryptographically secure PRNG.\n- * Returns 0 on success and -1 on error, setting errno.  The inability to\n- * satisfy the full request is an error.\n- */\n-int csprng_bytes(void *buf, size_t len);\n-\n #endif\ndiff --git a/wrapper.h b/wrapper.h\nindex f0c7d0616d..c85b1328d1 100644\n--- a/wrapper.h\n+++ b/wrapper.h\n@@ -1,6 +1,42 @@\n #ifndef WRAPPER_H\n #define WRAPPER_H\n \n+char *xstrdup(const char *str);\n+void *xmalloc(size_t size);\n+void *xmallocz(size_t size);\n+void *xmallocz_gently(size_t size);\n+void *xmemdupz(const void *data, size_t len);\n+char *xstrndup(const char *str, size_t len);\n+void *xrealloc(void *ptr, size_t size);\n+void *xcalloc(size_t nmemb, size_t size);\n+void xsetenv(const char *name, const char *value, int overwrite);\n+void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);\n+const char *mmap_os_err(void);\n+void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);\n+int xopen(const char *path, int flags, ...);\n+ssize_t xread(int fd, void *buf, size_t len);\n+ssize_t xwrite(int fd, const void *buf, size_t len);\n+ssize_t xpread(int fd, void *buf, size_t len, off_t offset);\n+int xdup(int fd);\n+FILE *xfopen(const char *path, const char *mode);\n+FILE *xfdopen(int fd, const char *mode);\n+int xmkstemp(char *temp_filename);\n+int xmkstemp_mode(char *temp_filename, int mode);\n+char *xgetcwd(void);\n+FILE *fopen_for_writing(const char *path);\n+FILE *fopen_or_warn(const char *path, const char *mode);\n+\n+/*\n+ * Like strncmp, but only return zero if s is NUL-terminated and exactly len\n+ * characters long.  If it is not, consider it greater than t.\n+ */\n+int xstrncmpz(const char *s, const char *t, size_t len);\n+\n+__attribute__((format (printf, 3, 4)))\n+int xsnprintf(char *dst, size_t max, const char *fmt, ...);\n+\n+int xgethostname(char *buf, size_t len);\n+\n /* set default permissions by passing mode arguments to open(2) */\n int git_mkstemps_mode(char *pattern, int suffix_len, int mode);\n int git_mkstemp_mode(char *pattern, int mode);\n@@ -33,4 +69,79 @@ void write_file(const char *path, const char *fmt, ...);\n /* Return 1 if the file is empty or does not exists, 0 otherwise. */\n int is_empty_or_missing_file(const char *filename);\n \n+enum fsync_action {\n+\tFSYNC_WRITEOUT_ONLY,\n+\tFSYNC_HARDWARE_FLUSH\n+};\n+\n+/*\n+ * Issues an fsync against the specified file according to the specified mode.\n+ *\n+ * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating\n+ * systems to flush the OS cache without issuing a flush command to the storage\n+ * controller. If those interfaces are unavailable, the function fails with\n+ * ENOSYS.\n+ *\n+ * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that\n+ * changes are durable. It is not expected to fail.\n+ */\n+int git_fsync(int fd, enum fsync_action action);\n+\n+/*\n+ * Writes out trace statistics for fsync using the trace2 API.\n+ */\n+void trace_git_fsync_stats(void);\n+\n+/*\n+ * Preserves errno, prints a message, but gives no warning for ENOENT.\n+ * Returns 0 on success, which includes trying to unlink an object that does\n+ * not exist.\n+ */\n+int unlink_or_warn(const char *path);\n+ /*\n+  * Tries to unlink file.  Returns 0 if unlink succeeded\n+  * or the file already didn't exist.  Returns -1 and\n+  * appends a message to err suitable for\n+  * 'error(\"%s\", err->buf)' on error.\n+  */\n+int unlink_or_msg(const char *file, struct strbuf *err);\n+/*\n+ * Preserves errno, prints a message, but gives no warning for ENOENT.\n+ * Returns 0 on success, which includes trying to remove a directory that does\n+ * not exist.\n+ */\n+int rmdir_or_warn(const char *path);\n+/*\n+ * Calls the correct function out of {unlink,rmdir}_or_warn based on\n+ * the supplied file mode.\n+ */\n+int remove_or_warn(unsigned int mode, const char *path);\n+\n+/*\n+ * Call access(2), but warn for any error except \"missing file\"\n+ * (ENOENT or ENOTDIR).\n+ */\n+#define ACCESS_EACCES_OK (1U << 0)\n+int access_or_warn(const char *path, int mode, unsigned flag);\n+int access_or_die(const char *path, int mode, unsigned flag);\n+\n+/* Warn on an inaccessible file if errno indicates this is an error */\n+int warn_on_fopen_errors(const char *path);\n+\n+/*\n+ * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent\n+ * may be racy. Do not use this as protection against an attacker who can\n+ * simultaneously create paths.\n+ */\n+int open_nofollow(const char *path, int flags);\n+\n+void sleep_millisec(int millisec);\n+\n+/*\n+ * Generate len bytes from the system cryptographically secure PRNG.\n+ * Returns 0 on success and -1 on error, setting errno.  The inability to\n+ * satisfy the full request is an error.\n+ */\n+int csprng_bytes(void *buf, size_t len);\n+\n #endif /* WRAPPER_H */\n-- \n2.41.0.255.g8b1d071c50-goog\n\n"},{"id":"479203","messageId":"20230705170924.3833828-3-calvinwan@google.com","threadId":"59951","inReplyTo":"20230705170812.3833103-1-calvinwan@google.com","subject":"[PATCH v5 3/6] sane-ctype.h: create header for sane-ctype macros","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:09:21Z","receivedAt":"2023-07-05T17:09:55Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"Splitting these macros from git-compat-util.h cleans up the file and\nallows future third-party sources to not use these overrides if they do\nnot wish to.\n\nSigned-off-by: Calvin Wan <calvinwan@google.com>\n---\n git-compat-util.h | 62 +-------------------------------------------\n sane-ctype.h      | 66 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 67 insertions(+), 61 deletions(-)\n create mode 100644 sane-ctype.h\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 9140f43bbf..5f916e1094 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1155,67 +1155,7 @@ static inline size_t xsize_t(off_t len)\n /* in ctype.c, for kwset users */\n extern const unsigned char tolower_trans_tbl[256];\n \n-/* Sane ctype - no locale, and works with signed chars */\n-#undef isascii\n-#undef isspace\n-#undef isdigit\n-#undef isalpha\n-#undef isalnum\n-#undef isprint\n-#undef islower\n-#undef isupper\n-#undef tolower\n-#undef toupper\n-#undef iscntrl\n-#undef ispunct\n-#undef isxdigit\n-\n-extern const unsigned char sane_ctype[256];\n-extern const signed char hexval_table[256];\n-#define GIT_SPACE 0x01\n-#define GIT_DIGIT 0x02\n-#define GIT_ALPHA 0x04\n-#define GIT_GLOB_SPECIAL 0x08\n-#define GIT_REGEX_SPECIAL 0x10\n-#define GIT_PATHSPEC_MAGIC 0x20\n-#define GIT_CNTRL 0x40\n-#define GIT_PUNCT 0x80\n-#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)\n-#define isascii(x) (((x) & ~0x7f) == 0)\n-#define isspace(x) sane_istest(x,GIT_SPACE)\n-#define isdigit(x) sane_istest(x,GIT_DIGIT)\n-#define isalpha(x) sane_istest(x,GIT_ALPHA)\n-#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)\n-#define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)\n-#define islower(x) sane_iscase(x, 1)\n-#define isupper(x) sane_iscase(x, 0)\n-#define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)\n-#define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)\n-#define iscntrl(x) (sane_istest(x,GIT_CNTRL))\n-#define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \\\n-\t\tGIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)\n-#define isxdigit(x) (hexval_table[(unsigned char)(x)] != -1)\n-#define tolower(x) sane_case((unsigned char)(x), 0x20)\n-#define toupper(x) sane_case((unsigned char)(x), 0)\n-#define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)\n-\n-static inline int sane_case(int x, int high)\n-{\n-\tif (sane_istest(x, GIT_ALPHA))\n-\t\tx = (x & ~0x20) | high;\n-\treturn x;\n-}\n-\n-static inline int sane_iscase(int x, int is_lower)\n-{\n-\tif (!sane_istest(x, GIT_ALPHA))\n-\t\treturn 0;\n-\n-\tif (is_lower)\n-\t\treturn (x & 0x20) != 0;\n-\telse\n-\t\treturn (x & 0x20) == 0;\n-}\n+#include \"sane-ctype.h\"\n \n /*\n  * Like skip_prefix, but compare case-insensitively. Note that the comparison\ndiff --git a/sane-ctype.h b/sane-ctype.h\nnew file mode 100644\nindex 0000000000..cbea1b299b\n--- /dev/null\n+++ b/sane-ctype.h\n@@ -0,0 +1,66 @@\n+#ifndef SANE_CTYPE_H\n+#define SANE_CTYPE_H\n+\n+/* Sane ctype - no locale, and works with signed chars */\n+#undef isascii\n+#undef isspace\n+#undef isdigit\n+#undef isalpha\n+#undef isalnum\n+#undef isprint\n+#undef islower\n+#undef isupper\n+#undef tolower\n+#undef toupper\n+#undef iscntrl\n+#undef ispunct\n+#undef isxdigit\n+\n+extern const unsigned char sane_ctype[256];\n+extern const signed char hexval_table[256];\n+#define GIT_SPACE 0x01\n+#define GIT_DIGIT 0x02\n+#define GIT_ALPHA 0x04\n+#define GIT_GLOB_SPECIAL 0x08\n+#define GIT_REGEX_SPECIAL 0x10\n+#define GIT_PATHSPEC_MAGIC 0x20\n+#define GIT_CNTRL 0x40\n+#define GIT_PUNCT 0x80\n+#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)\n+#define isascii(x) (((x) & ~0x7f) == 0)\n+#define isspace(x) sane_istest(x,GIT_SPACE)\n+#define isdigit(x) sane_istest(x,GIT_DIGIT)\n+#define isalpha(x) sane_istest(x,GIT_ALPHA)\n+#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)\n+#define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)\n+#define islower(x) sane_iscase(x, 1)\n+#define isupper(x) sane_iscase(x, 0)\n+#define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)\n+#define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)\n+#define iscntrl(x) (sane_istest(x,GIT_CNTRL))\n+#define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \\\n+\t\tGIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)\n+#define isxdigit(x) (hexval_table[(unsigned char)(x)] != -1)\n+#define tolower(x) sane_case((unsigned char)(x), 0x20)\n+#define toupper(x) sane_case((unsigned char)(x), 0)\n+#define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)\n+\n+static inline int sane_case(int x, int high)\n+{\n+\tif (sane_istest(x, GIT_ALPHA))\n+\t\tx = (x & ~0x20) | high;\n+\treturn x;\n+}\n+\n+static inline int sane_iscase(int x, int is_lower)\n+{\n+\tif (!sane_istest(x, GIT_ALPHA))\n+\t\treturn 0;\n+\n+\tif (is_lower)\n+\t\treturn (x & 0x20) != 0;\n+\telse\n+\t\treturn (x & 0x20) == 0;\n+}\n+\n+#endif\n-- \n2.41.0.255.g8b1d071c50-goog\n\n"},{"id":"479204","messageId":"20230705170924.3833828-5-calvinwan@google.com","threadId":"59951","inReplyTo":"20230705170812.3833103-1-calvinwan@google.com","subject":"[PATCH v5 5/6] treewide: remove unnecessary includes for wrapper.h","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:09:23Z","receivedAt":"2023-07-05T17:10:05Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"Signed-off-by: Calvin Wan <calvinwan@google.com>\n---\n apply.c                          | 1 -\n builtin/am.c                     | 1 -\n builtin/bisect.c                 | 1 -\n builtin/branch.c                 | 1 -\n builtin/bugreport.c              | 1 -\n builtin/clone.c                  | 1 -\n builtin/config.c                 | 1 -\n builtin/credential-cache.c       | 1 -\n builtin/difftool.c               | 1 -\n builtin/fast-import.c            | 1 -\n builtin/fmt-merge-msg.c          | 1 -\n builtin/gc.c                     | 1 -\n builtin/get-tar-commit-id.c      | 1 -\n builtin/index-pack.c             | 1 -\n builtin/init-db.c                | 1 -\n builtin/merge.c                  | 1 -\n builtin/pack-objects.c           | 1 -\n builtin/rebase.c                 | 1 -\n builtin/receive-pack.c           | 1 -\n builtin/rerere.c                 | 1 -\n builtin/unpack-file.c            | 1 -\n builtin/worktree.c               | 1 -\n bulk-checkin.c                   | 1 -\n combine-diff.c                   | 1 -\n commit-graph.c                   | 1 -\n compat/terminal.c                | 1 -\n config.c                         | 1 -\n convert.c                        | 1 -\n copy.c                           | 1 -\n csum-file.c                      | 1 -\n daemon.c                         | 1 -\n diff.c                           | 1 -\n dir.c                            | 1 -\n editor.c                         | 1 -\n entry.c                          | 1 -\n environment.c                    | 1 -\n fetch-pack.c                     | 1 -\n gpg-interface.c                  | 1 -\n grep.c                           | 1 -\n http-backend.c                   | 1 -\n imap-send.c                      | 1 -\n merge-ll.c                       | 1 -\n merge-recursive.c                | 1 -\n notes-merge.c                    | 1 -\n object-file.c                    | 1 -\n pack-write.c                     | 1 -\n packfile.c                       | 1 -\n parallel-checkout.c              | 1 -\n path.c                           | 1 -\n pkt-line.c                       | 1 -\n read-cache.c                     | 1 -\n rebase-interactive.c             | 1 -\n refs.c                           | 1 -\n rerere.c                         | 1 -\n send-pack.c                      | 1 -\n sequencer.c                      | 1 -\n server-info.c                    | 1 -\n setup.c                          | 1 -\n shallow.c                        | 1 -\n strbuf.c                         | 1 -\n streaming.c                      | 1 -\n t/helper/test-delta.c            | 1 -\n t/helper/test-fsmonitor-client.c | 1 -\n t/helper/test-read-cache.c       | 1 -\n tag.c                            | 1 -\n tempfile.c                       | 1 -\n trace.c                          | 1 -\n transport-helper.c               | 1 -\n transport.c                      | 1 -\n upload-pack.c                    | 1 -\n usage.c                          | 1 -\n worktree.c                       | 1 -\n wrapper.c                        | 1 -\n write-or-die.c                   | 1 -\n 74 files changed, 74 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 45dcd645e6..dde124066b 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -37,7 +37,6 @@\n #include \"symlinks.h\"\n #include \"wildmatch.h\"\n #include \"ws.h\"\n-#include \"wrapper.h\"\n \n struct gitdiff_data {\n \tstruct strbuf *root;\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 5fab159599..dcb89439b1 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -44,7 +44,6 @@\n #include \"path.h\"\n #include \"repository.h\"\n #include \"pretty.h\"\n-#include \"wrapper.h\"\n \n /**\n  * Returns the length of the first line of msg.\ndiff --git a/builtin/bisect.c b/builtin/bisect.c\nindex 6478df3489..65478ef40f 100644\n--- a/builtin/bisect.c\n+++ b/builtin/bisect.c\n@@ -15,7 +15,6 @@\n #include \"prompt.h\"\n #include \"quote.h\"\n #include \"revision.h\"\n-#include \"wrapper.h\"\n \n static GIT_PATH_FUNC(git_path_bisect_terms, \"BISECT_TERMS\")\n static GIT_PATH_FUNC(git_path_bisect_expected_rev, \"BISECT_EXPECTED_REV\")\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex e8ff3ecc07..a27bc0a3df 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -28,7 +28,6 @@\n #include \"worktree.h\"\n #include \"help.h\"\n #include \"commit-reach.h\"\n-#include \"wrapper.h\"\n \n static const char * const builtin_branch_usage[] = {\n \tN_(\"git branch [<options>] [-r | -a] [--merged] [--no-merged]\"),\ndiff --git a/builtin/bugreport.c b/builtin/bugreport.c\nindex daf6c23657..d2ae5c305d 100644\n--- a/builtin/bugreport.c\n+++ b/builtin/bugreport.c\n@@ -11,7 +11,6 @@\n #include \"diagnose.h\"\n #include \"object-file.h\"\n #include \"setup.h\"\n-#include \"wrapper.h\"\n \n static void get_system_info(struct strbuf *sys_info)\n {\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex da35f1a6b4..c65378b3d2 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -45,7 +45,6 @@\n #include \"hook.h\"\n #include \"bundle.h\"\n #include \"bundle-uri.h\"\n-#include \"wrapper.h\"\n \n /*\n  * Overall FIXMEs:\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 1c75cbc43d..787d85edac 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -15,7 +15,6 @@\n #include \"setup.h\"\n #include \"strbuf.h\"\n #include \"worktree.h\"\n-#include \"wrapper.h\"\n \n static const char *const builtin_config_usage[] = {\n \tN_(\"git config [<options>]\"),\ndiff --git a/builtin/credential-cache.c b/builtin/credential-cache.c\nindex ff3a47badb..43b9d0e5b1 100644\n--- a/builtin/credential-cache.c\n+++ b/builtin/credential-cache.c\n@@ -3,7 +3,6 @@\n #include \"parse-options.h\"\n #include \"path.h\"\n #include \"strbuf.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n #ifndef NO_UNIX_SOCKETS\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 24d88f88ba..0f5eae9cd4 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -32,7 +32,6 @@\n #include \"dir.h\"\n #include \"entry.h\"\n #include \"setup.h\"\n-#include \"wrapper.h\"\n \n static int trust_exit_code;\n \ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 2ee19c7373..4dbb10aff3 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -26,7 +26,6 @@\n #include \"commit-reach.h\"\n #include \"khash.h\"\n #include \"date.h\"\n-#include \"wrapper.h\"\n \n #define PACK_ID_BITS 16\n #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex cc81241642..0f9855b680 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -3,7 +3,6 @@\n #include \"fmt-merge-msg.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n-#include \"wrapper.h\"\n \n static const char * const fmt_merge_msg_usage[] = {\n \tN_(\"git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]\"),\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 91eec7703a..19d73067aa 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -41,7 +41,6 @@\n #include \"hook.h\"\n #include \"setup.h\"\n #include \"trace2.h\"\n-#include \"wrapper.h\"\n \n #define FAILED_RUN \"failed to run %s\"\n \ndiff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c\nindex 9303e386cc..20d0dfe9cf 100644\n--- a/builtin/get-tar-commit-id.c\n+++ b/builtin/get-tar-commit-id.c\n@@ -5,7 +5,6 @@\n #include \"commit.h\"\n #include \"tar.h\"\n #include \"quote.h\"\n-#include \"wrapper.h\"\n \n static const char builtin_get_tar_commit_id_usage[] =\n \"git get-tar-commit-id\";\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex e280180cac..66202b304d 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -25,7 +25,6 @@\n #include \"replace-object.h\"\n #include \"promisor-remote.h\"\n #include \"setup.h\"\n-#include \"wrapper.h\"\n \n static const char index_pack_usage[] =\n \"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])\";\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 0d8bd4d721..cb727c826f 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -13,7 +13,6 @@\n #include \"path.h\"\n #include \"setup.h\"\n #include \"strbuf.h\"\n-#include \"wrapper.h\"\n \n static int guess_repository_type(const char *git_dir)\n {\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 06cf6afdcb..404700a35c 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -53,7 +53,6 @@\n #include \"commit-reach.h\"\n #include \"wt-status.h\"\n #include \"commit-graph.h\"\n-#include \"wrapper.h\"\n \n #define DEFAULT_TWOHEAD (1<<0)\n #define DEFAULT_OCTOPUS (1<<1)\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8e77638145..8251961042 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -43,7 +43,6 @@\n #include \"promisor-remote.h\"\n #include \"pack-mtimes.h\"\n #include \"parse-options.h\"\n-#include \"wrapper.h\"\n \n /*\n  * Objects we are going to pack are collected in the `to_pack` structure.\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 1b3f68d9b0..50cb85751f 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -37,7 +37,6 @@\n #include \"reset.h\"\n #include \"trace2.h\"\n #include \"hook.h\"\n-#include \"wrapper.h\"\n \n static char const * const builtin_rebase_usage[] = {\n \tN_(\"git rebase [-i] [options] [--exec <cmd>] \"\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex faa8f84c5a..a7fe8c4d9a 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -40,7 +40,6 @@\n #include \"worktree.h\"\n #include \"shallow.h\"\n #include \"parse-options.h\"\n-#include \"wrapper.h\"\n \n static const char * const receive_pack_usage[] = {\n \tN_(\"git receive-pack <git-dir>\"),\ndiff --git a/builtin/rerere.c b/builtin/rerere.c\nindex 0458db9cad..07a9d37275 100644\n--- a/builtin/rerere.c\n+++ b/builtin/rerere.c\n@@ -6,7 +6,6 @@\n #include \"repository.h\"\n #include \"string-list.h\"\n #include \"rerere.h\"\n-#include \"wrapper.h\"\n #include \"xdiff/xdiff.h\"\n #include \"xdiff-interface.h\"\n #include \"pathspec.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 6842a6c499..c129e2bb6c 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -3,7 +3,6 @@\n #include \"hex.h\"\n #include \"object-name.h\"\n #include \"object-store-ll.h\"\n-#include \"wrapper.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 7c114d56a3..2ce39b593c 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -24,7 +24,6 @@\n #include \"submodule.h\"\n #include \"utf8.h\"\n #include \"worktree.h\"\n-#include \"wrapper.h\"\n #include \"quote.h\"\n \n #define BUILTIN_WORKTREE_ADD_USAGE \\\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex e2f71db0f6..fec6816259 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -17,7 +17,6 @@\n #include \"packfile.h\"\n #include \"object-file.h\"\n #include \"object-store-ll.h\"\n-#include \"wrapper.h\"\n \n static int odb_transaction_nesting;\n \ndiff --git a/combine-diff.c b/combine-diff.c\nindex 11e9d7494a..f90f442482 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -17,7 +17,6 @@\n #include \"userdiff.h\"\n #include \"oid-array.h\"\n #include \"revision.h\"\n-#include \"wrapper.h\"\n \n static int compare_paths(const struct combine_diff_path *one,\n \t\t\t  const struct diff_filespec *two)\ndiff --git a/commit-graph.c b/commit-graph.c\nindex f70afccada..38185c8529 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -26,7 +26,6 @@\n #include \"trace2.h\"\n #include \"tree.h\"\n #include \"chunk-format.h\"\n-#include \"wrapper.h\"\n \n void git_test_write_commit_graph_or_die(void)\n {\ndiff --git a/compat/terminal.c b/compat/terminal.c\nindex d87e321189..83d95e8656 100644\n--- a/compat/terminal.c\n+++ b/compat/terminal.c\n@@ -6,7 +6,6 @@\n #include \"run-command.h\"\n #include \"string-list.h\"\n #include \"hashmap.h\"\n-#include \"wrapper.h\"\n \n #if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)\n \ndiff --git a/config.c b/config.c\nindex 85c5f35132..59fad84eb7 100644\n--- a/config.c\n+++ b/config.c\n@@ -39,7 +39,6 @@\n #include \"wildmatch.h\"\n #include \"worktree.h\"\n #include \"ws.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n struct config_source {\ndiff --git a/convert.c b/convert.c\nindex cb64117cc0..a8870baff3 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -16,7 +16,6 @@\n #include \"trace.h\"\n #include \"utf8.h\"\n #include \"merge-ll.h\"\n-#include \"wrapper.h\"\n \n /*\n  * convert.c - convert a file when checking it out and checking it in.\ndiff --git a/copy.c b/copy.c\nindex 882c79cffb..23d84c6c1d 100644\n--- a/copy.c\n+++ b/copy.c\n@@ -1,7 +1,6 @@\n #include \"git-compat-util.h\"\n #include \"copy.h\"\n #include \"path.h\"\n-#include \"wrapper.h\"\n \n int copy_fd(int ifd, int ofd)\n {\ndiff --git a/csum-file.c b/csum-file.c\nindex daf9b06dff..cd01713244 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -11,7 +11,6 @@\n #include \"progress.h\"\n #include \"csum-file.h\"\n #include \"hash.h\"\n-#include \"wrapper.h\"\n \n static void verify_buffer_or_die(struct hashfile *f,\n \t\t\t\t const void *buf,\ndiff --git a/daemon.c b/daemon.c\nindex 3682bfdd08..a7fe89cd2d 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -10,7 +10,6 @@\n #include \"setup.h\"\n #include \"strbuf.h\"\n #include \"string-list.h\"\n-#include \"wrapper.h\"\n \n #ifdef NO_INITGROUPS\n #define initgroups(x, y) (0) /* nothing */\ndiff --git a/diff.c b/diff.c\nindex f265afa6c4..9e4d87a8db 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -43,7 +43,6 @@\n #include \"setup.h\"\n #include \"strmap.h\"\n #include \"ws.h\"\n-#include \"wrapper.h\"\n \n #ifdef NO_FAST_WORKING_DIRECTORY\n #define FAST_WORKING_DIRECTORY 0\ndiff --git a/dir.c b/dir.c\nindex 3acac7beb1..d270a1be36 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -32,7 +32,6 @@\n #include \"symlinks.h\"\n #include \"trace2.h\"\n #include \"tree.h\"\n-#include \"wrapper.h\"\n \n /*\n  * Tells read_directory_recursive how a file or directory should be treated.\ndiff --git a/editor.c b/editor.c\nindex 38c5dbbb79..b67b802ddf 100644\n--- a/editor.c\n+++ b/editor.c\n@@ -11,7 +11,6 @@\n #include \"strvec.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n-#include \"wrapper.h\"\n \n #ifndef DEFAULT_EDITOR\n #define DEFAULT_EDITOR \"vi\"\ndiff --git a/entry.c b/entry.c\nindex f9a7c726a4..43767f9043 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -14,7 +14,6 @@\n #include \"fsmonitor.h\"\n #include \"entry.h\"\n #include \"parallel-checkout.h\"\n-#include \"wrapper.h\"\n \n static void create_directories(const char *path, int path_len,\n \t\t\t       const struct checkout *state)\ndiff --git a/environment.c b/environment.c\nindex 8128104373..a0d1d070d1 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -28,7 +28,6 @@\n #include \"setup.h\"\n #include \"shallow.h\"\n #include \"trace.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n int trust_executable_bit = 1;\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 1e0313a0a6..bb288d47f3 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -34,7 +34,6 @@\n #include \"commit-graph.h\"\n #include \"sigchain.h\"\n #include \"mergesort.h\"\n-#include \"wrapper.h\"\n \n static int transfer_unpack_limit = -1;\n static int fetch_unpack_limit = -1;\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex f7c1d385c1..48f43c5a21 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -12,7 +12,6 @@\n #include \"sigchain.h\"\n #include \"tempfile.h\"\n #include \"alias.h\"\n-#include \"wrapper.h\"\n #include \"environment.h\"\n \n static int git_gpg_config(const char *, const char *,\ndiff --git a/grep.c b/grep.c\nindex ea38687c8a..0904d55b24 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -12,7 +12,6 @@\n #include \"commit.h\"\n #include \"quote.h\"\n #include \"help.h\"\n-#include \"wrapper.h\"\n \n static int grep_source_load(struct grep_source *gs);\n static int grep_source_is_binary(struct grep_source *gs,\ndiff --git a/http-backend.c b/http-backend.c\nindex e1969c05dc..25a19c21b9 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -19,7 +19,6 @@\n #include \"object-store-ll.h\"\n #include \"protocol.h\"\n #include \"date.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n static const char content_type[] = \"Content-Type\";\ndiff --git a/imap-send.c b/imap-send.c\nindex 3518a4ace6..23c807fced 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -30,7 +30,6 @@\n #include \"parse-options.h\"\n #include \"setup.h\"\n #include \"strbuf.h\"\n-#include \"wrapper.h\"\n #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)\n typedef void *SSL;\n #endif\ndiff --git a/merge-ll.c b/merge-ll.c\nindex 95795b70f5..8fcf2d3710 100644\n--- a/merge-ll.c\n+++ b/merge-ll.c\n@@ -13,7 +13,6 @@\n #include \"merge-ll.h\"\n #include \"quote.h\"\n #include \"strbuf.h\"\n-#include \"wrapper.h\"\n \n struct ll_merge_driver;\n \ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 43f6b2d036..6a4081bb0f 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -38,7 +38,6 @@\n #include \"tag.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\n-#include \"wrapper.h\"\n #include \"xdiff-interface.h\"\n \n struct merge_options_internal {\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 071947894e..8799b522a5 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -20,7 +20,6 @@\n #include \"trace.h\"\n #include \"notes-utils.h\"\n #include \"commit-reach.h\"\n-#include \"wrapper.h\"\n \n struct notes_merge_pair {\n \tstruct object_id obj, base, local, remote;\ndiff --git a/object-file.c b/object-file.c\nindex 8d87720dd5..527b740018 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -44,7 +44,6 @@\n #include \"setup.h\"\n #include \"submodule.h\"\n #include \"fsck.h\"\n-#include \"wrapper.h\"\n \n /* The maximum size for an object header. */\n #define MAX_HEADER_LEN 32\ndiff --git a/pack-write.c b/pack-write.c\nindex af48813a9b..b19ddf15b2 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -12,7 +12,6 @@\n #include \"pack-revindex.h\"\n #include \"path.h\"\n #include \"strbuf.h\"\n-#include \"wrapper.h\"\n \n void reset_pack_idx_option(struct pack_idx_option *opts)\n {\ndiff --git a/packfile.c b/packfile.c\nindex c2e753ef8f..9126274b37 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -24,7 +24,6 @@\n #include \"commit-graph.h\"\n #include \"pack-revindex.h\"\n #include \"promisor-remote.h\"\n-#include \"wrapper.h\"\n \n char *odb_pack_name(struct strbuf *buf,\n \t\t    const unsigned char *hash,\ndiff --git a/parallel-checkout.c b/parallel-checkout.c\nindex 602fbf19d3..8637723461 100644\n--- a/parallel-checkout.c\n+++ b/parallel-checkout.c\n@@ -15,7 +15,6 @@\n #include \"symlinks.h\"\n #include \"thread-utils.h\"\n #include \"trace2.h\"\n-#include \"wrapper.h\"\n \n struct pc_worker {\n \tstruct child_process cp;\ndiff --git a/path.c b/path.c\nindex 044a50bad0..67e2690efe 100644\n--- a/path.c\n+++ b/path.c\n@@ -18,7 +18,6 @@\n #include \"object-store-ll.h\"\n #include \"lockfile.h\"\n #include \"exec-cmd.h\"\n-#include \"wrapper.h\"\n \n static int get_st_mode_bits(const char *path, int *mode)\n {\ndiff --git a/pkt-line.c b/pkt-line.c\nindex 62b4208b66..6e4166132d 100644\n--- a/pkt-line.c\n+++ b/pkt-line.c\n@@ -5,7 +5,6 @@\n #include \"hex.h\"\n #include \"run-command.h\"\n #include \"trace.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n char packet_buffer[LARGE_PACKET_MAX];\ndiff --git a/read-cache.c b/read-cache.c\nindex b9a995e5a1..140b4f96a0 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -46,7 +46,6 @@\n #include \"csum-file.h\"\n #include \"promisor-remote.h\"\n #include \"hook.h\"\n-#include \"wrapper.h\"\n \n /* Mask for the name length in ce_flags in the on-disk index */\n \ndiff --git a/rebase-interactive.c b/rebase-interactive.c\nindex f286404d4b..d9718409b3 100644\n--- a/rebase-interactive.c\n+++ b/rebase-interactive.c\n@@ -11,7 +11,6 @@\n #include \"config.h\"\n #include \"dir.h\"\n #include \"object-name.h\"\n-#include \"wrapper.h\"\n \n static const char edit_todo_list_advice[] =\n N_(\"You can fix this with 'git rebase --edit-todo' \"\ndiff --git a/refs.c b/refs.c\nindex c029f64982..d5e0184ca5 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -30,7 +30,6 @@\n #include \"date.h\"\n #include \"commit.h\"\n #include \"wildmatch.h\"\n-#include \"wrapper.h\"\n \n /*\n  * List of all available backends\ndiff --git a/rerere.c b/rerere.c\nindex e2b8597f88..4227c9612a 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -20,7 +20,6 @@\n #include \"object-store-ll.h\"\n #include \"hash-lookup.h\"\n #include \"strmap.h\"\n-#include \"wrapper.h\"\n \n #define RESOLVED 0\n #define PUNTED 1\ndiff --git a/send-pack.c b/send-pack.c\nindex 9510bef856..89aca9d829 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -15,7 +15,6 @@\n #include \"quote.h\"\n #include \"transport.h\"\n #include \"version.h\"\n-#include \"wrapper.h\"\n #include \"oid-array.h\"\n #include \"gpg-interface.h\"\n #include \"shallow.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex 7e6c556e0a..993dd8efbc 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -49,7 +49,6 @@\n #include \"rebase-interactive.h\"\n #include \"reset.h\"\n #include \"branch.h\"\n-#include \"wrapper.h\"\n \n #define GIT_REFLOG_ACTION \"GIT_REFLOG_ACTION\"\n \ndiff --git a/server-info.c b/server-info.c\nindex 382e481a2b..f350713ecf 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -14,7 +14,6 @@\n #include \"object-store-ll.h\"\n #include \"server-info.h\"\n #include \"strbuf.h\"\n-#include \"wrapper.h\"\n \n struct update_info_ctx {\n \tFILE *cur_fp;\ndiff --git a/setup.c b/setup.c\nindex 8e4b2cd2c3..18927a847b 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -17,7 +17,6 @@\n #include \"quote.h\"\n #include \"trace2.h\"\n #include \"worktree.h\"\n-#include \"wrapper.h\"\n \n static int inside_git_dir = -1;\n static int inside_work_tree = -1;\ndiff --git a/shallow.c b/shallow.c\nindex f3ef94d4c9..2fad3504b7 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -20,7 +20,6 @@\n #include \"shallow.h\"\n #include \"statinfo.h\"\n #include \"trace.h\"\n-#include \"wrapper.h\"\n \n void set_alternate_shallow_file(struct repository *r, const char *path, int override)\n {\ndiff --git a/strbuf.c b/strbuf.c\nindex b41d343ed0..ab8e52e9b4 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -6,7 +6,6 @@\n #include \"string-list.h\"\n #include \"utf8.h\"\n #include \"date.h\"\n-#include \"wrapper.h\"\n \n int starts_with(const char *str, const char *prefix)\n {\ndiff --git a/streaming.c b/streaming.c\nindex 49791ab958..10adf625b2 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -10,7 +10,6 @@\n #include \"object-store-ll.h\"\n #include \"replace-object.h\"\n #include \"packfile.h\"\n-#include \"wrapper.h\"\n \n typedef int (*open_istream_fn)(struct git_istream *,\n \t\t\t       struct repository *,\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex e7d134ec25..6bc787a474 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -11,7 +11,6 @@\n #include \"test-tool.h\"\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n-#include \"wrapper.h\"\n \n static const char usage_str[] =\n \t\"test-tool delta (-d|-p) <from_file> <data_file> <out_file>\";\ndiff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c\nindex 58d1dc5fc8..8280984d08 100644\n--- a/t/helper/test-fsmonitor-client.c\n+++ b/t/helper/test-fsmonitor-client.c\n@@ -11,7 +11,6 @@\n #include \"setup.h\"\n #include \"thread-utils.h\"\n #include \"trace2.h\"\n-#include \"wrapper.h\"\n \n #ifndef HAVE_FSMONITOR_DAEMON_BACKEND\n int cmd__fsmonitor_client(int argc UNUSED, const char **argv UNUSED)\ndiff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c\nindex 56c2d25f35..1acd362346 100644\n--- a/t/helper/test-read-cache.c\n+++ b/t/helper/test-read-cache.c\n@@ -4,7 +4,6 @@\n #include \"read-cache-ll.h\"\n #include \"repository.h\"\n #include \"setup.h\"\n-#include \"wrapper.h\"\n \n int cmd__read_cache(int argc, const char **argv)\n {\ndiff --git a/tag.c b/tag.c\nindex c5426484b2..fc3834db46 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -10,7 +10,6 @@\n #include \"gpg-interface.h\"\n #include \"hex.h\"\n #include \"packfile.h\"\n-#include \"wrapper.h\"\n \n const char *tag_type = \"tag\";\n \ndiff --git a/tempfile.c b/tempfile.c\nindex 6c88a63b42..ecdebf1afb 100644\n--- a/tempfile.c\n+++ b/tempfile.c\n@@ -47,7 +47,6 @@\n #include \"path.h\"\n #include \"tempfile.h\"\n #include \"sigchain.h\"\n-#include \"wrapper.h\"\n \n static VOLATILE_LIST_HEAD(tempfile_list);\n \ndiff --git a/trace.c b/trace.c\nindex 592c141d78..971a68abe8 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -27,7 +27,6 @@\n #include \"quote.h\"\n #include \"setup.h\"\n #include \"trace.h\"\n-#include \"wrapper.h\"\n \n struct trace_key trace_default_key = { \"GIT_TRACE\", 0, 0, 0 };\n struct trace_key trace_perf_key = TRACE_KEY_INIT(PERFORMANCE);\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 5c0bc6a896..49811ef176 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -19,7 +19,6 @@\n #include \"refspec.h\"\n #include \"transport-internal.h\"\n #include \"protocol.h\"\n-#include \"wrapper.h\"\n \n static int debug;\n \ndiff --git a/transport.c b/transport.c\nindex 4dc187a388..0a5794a944 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -30,7 +30,6 @@\n #include \"object-store-ll.h\"\n #include \"color.h\"\n #include \"bundle-uri.h\"\n-#include \"wrapper.h\"\n \n static int transport_use_color = -1;\n static char transport_colors[][COLOR_MAXLEN] = {\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 946074920a..0970392b41 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -32,7 +32,6 @@\n #include \"commit-graph.h\"\n #include \"commit-reach.h\"\n #include \"shallow.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n /* Remember to update object flag allocation in object.h */\ndiff --git a/usage.c b/usage.c\nindex 46d99f8bd4..09f0ed509b 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -6,7 +6,6 @@\n #include \"git-compat-util.h\"\n #include \"gettext.h\"\n #include \"trace2.h\"\n-#include \"wrapper.h\"\n \n static void vreportf(const char *prefix, const char *err, va_list params)\n {\ndiff --git a/worktree.c b/worktree.c\nindex 1b84e3a34d..2ea5d45e1e 100644\n--- a/worktree.c\n+++ b/worktree.c\n@@ -12,7 +12,6 @@\n #include \"dir.h\"\n #include \"wt-status.h\"\n #include \"config.h\"\n-#include \"wrapper.h\"\n \n void free_worktrees(struct worktree **worktrees)\n {\ndiff --git a/wrapper.c b/wrapper.c\nindex 67f5f5dbe1..22be9812a7 100644\n--- a/wrapper.c\n+++ b/wrapper.c\n@@ -9,7 +9,6 @@\n #include \"repository.h\"\n #include \"strbuf.h\"\n #include \"trace2.h\"\n-#include \"wrapper.h\"\n \n static intmax_t count_fsync_writeout_only;\n static intmax_t count_fsync_hardware_flush;\ndiff --git a/write-or-die.c b/write-or-die.c\nindex cc9e0787a1..d8355c0c3e 100644\n--- a/write-or-die.c\n+++ b/write-or-die.c\n@@ -1,7 +1,6 @@\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"run-command.h\"\n-#include \"wrapper.h\"\n #include \"write-or-die.h\"\n \n /*\n-- \n2.41.0.255.g8b1d071c50-goog\n\n"},{"id":"479205","messageId":"20230705170924.3833828-6-calvinwan@google.com","threadId":"59951","inReplyTo":"20230705170812.3833103-1-calvinwan@google.com","subject":"[PATCH v5 6/6] git-compat-util: move alloc macros to git-compat-util.h","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:09:24Z","receivedAt":"2023-07-05T17:10:08Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"alloc_nr, ALLOC_GROW, and ALLOC_GROW_BY are commonly used macros for\ndynamic array allocation. Moving these macros to git-compat-util.h with\nthe other alloc macros focuses alloc.[ch] to allocation for Git objects\nand additionally allows us to remove inclusions to alloc.h from files\nthat solely used the above macros.\n\nSigned-off-by: Calvin Wan <calvinwan@google.com>\n---\n add-patch.c                        |  1 -\n alias.c                            |  1 -\n alloc.h                            | 75 ------------------------------\n apply.c                            |  1 -\n archive-tar.c                      |  1 -\n archive.c                          |  1 -\n attr.c                             |  1 -\n builtin/blame.c                    |  1 -\n builtin/cat-file.c                 |  1 -\n builtin/checkout--worker.c         |  1 -\n builtin/config.c                   |  1 -\n builtin/credential-cache--daemon.c |  1 -\n builtin/fetch-pack.c               |  1 -\n builtin/fsmonitor--daemon.c        |  1 -\n builtin/grep.c                     |  1 -\n builtin/index-pack.c               |  1 -\n builtin/log.c                      |  1 -\n builtin/merge.c                    |  1 -\n builtin/mktree.c                   |  1 -\n builtin/mv.c                       |  1 -\n builtin/name-rev.c                 |  1 -\n builtin/pack-objects.c             |  1 -\n builtin/repack.c                   |  1 -\n builtin/rev-parse.c                |  1 -\n builtin/revert.c                   |  1 -\n builtin/rm.c                       |  1 -\n builtin/submodule--helper.c        |  1 -\n bulk-checkin.c                     |  1 -\n cache-tree.c                       |  1 -\n chunk-format.c                     |  1 -\n commit-reach.c                     |  1 -\n config.c                           |  1 -\n daemon.c                           |  1 -\n delta-islands.c                    |  1 -\n diff.c                             |  1 -\n diffcore-rename.c                  |  1 -\n dir-iterator.c                     |  1 -\n dir.c                              |  1 -\n ewah/bitmap.c                      |  1 -\n ewah/ewah_bitmap.c                 |  1 -\n fetch-pack.c                       |  1 -\n fmt-merge-msg.c                    |  1 -\n fsck.c                             |  1 -\n git-compat-util.h                  | 75 ++++++++++++++++++++++++++++++\n help.c                             |  1 -\n http-backend.c                     |  1 -\n line-log.c                         |  1 -\n list-objects-filter-options.c      |  1 -\n list-objects-filter.c              |  1 -\n midx.c                             |  1 -\n object-file.c                      |  1 -\n oid-array.c                        |  1 -\n oidtree.c                          |  1 -\n pack-bitmap-write.c                |  1 -\n pack-bitmap.c                      |  1 -\n pack-objects.c                     |  1 -\n packfile.c                         |  1 -\n parallel-checkout.c                |  1 -\n pretty.c                           |  1 -\n prio-queue.c                       |  1 -\n quote.c                            |  1 -\n read-cache.c                       |  1 -\n ref-filter.c                       |  1 -\n reflog-walk.c                      |  1 -\n refs.c                             |  1 -\n refspec.c                          |  1 -\n remote-curl.c                      |  1 -\n remote.c                           |  1 -\n rerere.c                           |  1 -\n revision.c                         |  1 -\n sequencer.c                        |  1 -\n server-info.c                      |  1 -\n shallow.c                          |  1 -\n sigchain.c                         |  1 -\n sparse-index.c                     |  1 -\n split-index.c                      |  1 -\n strbuf.c                           |  1 -\n string-list.c                      |  1 -\n strvec.c                           |  1 -\n submodule-config.c                 |  1 -\n submodule.c                        |  1 -\n t/helper/test-reach.c              |  1 -\n trace2/tr2_tls.c                   |  1 -\n trailer.c                          |  1 -\n transport.c                        |  1 -\n tree-walk.c                        |  1 -\n userdiff.c                         |  1 -\n worktree.c                         |  1 -\n 88 files changed, 75 insertions(+), 161 deletions(-)\n\ndiff --git a/add-patch.c b/add-patch.c\nindex ba629add62..bfe19876cd 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -1,7 +1,6 @@\n #include \"git-compat-util.h\"\n #include \"add-interactive.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"editor.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/alias.c b/alias.c\nindex 910dd252a0..5a238f2e30 100644\n--- a/alias.c\n+++ b/alias.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"alias.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"strbuf.h\"\ndiff --git a/alloc.h b/alloc.h\nindex 4312db4bd0..3f4a0ad310 100644\n--- a/alloc.h\n+++ b/alloc.h\n@@ -17,79 +17,4 @@ void *alloc_object_node(struct repository *r);\n struct alloc_state *allocate_alloc_state(void);\n void clear_alloc_state(struct alloc_state *s);\n \n-#define alloc_nr(x) (((x)+16)*3/2)\n-\n-/**\n- * Dynamically growing an array using realloc() is error prone and boring.\n- *\n- * Define your array with:\n- *\n- * - a pointer (`item`) that points at the array, initialized to `NULL`\n- *   (although please name the variable based on its contents, not on its\n- *   type);\n- *\n- * - an integer variable (`alloc`) that keeps track of how big the current\n- *   allocation is, initialized to `0`;\n- *\n- * - another integer variable (`nr`) to keep track of how many elements the\n- *   array currently has, initialized to `0`.\n- *\n- * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,\n- * alloc)`.  This ensures that the array can hold at least `n` elements by\n- * calling `realloc(3)` and adjusting `alloc` variable.\n- *\n- * ------------\n- * sometype *item;\n- * size_t nr;\n- * size_t alloc\n- *\n- * for (i = 0; i < nr; i++)\n- * \tif (we like item[i] already)\n- * \t\treturn;\n- *\n- * // we did not like any existing one, so add one\n- * ALLOC_GROW(item, nr + 1, alloc);\n- * item[nr++] = value you like;\n- * ------------\n- *\n- * You are responsible for updating the `nr` variable.\n- *\n- * If you need to specify the number of elements to allocate explicitly\n- * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.\n- *\n- * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some\n- * added niceties.\n- *\n- * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.\n- */\n-#define ALLOC_GROW(x, nr, alloc) \\\n-\tdo { \\\n-\t\tif ((nr) > alloc) { \\\n-\t\t\tif (alloc_nr(alloc) < (nr)) \\\n-\t\t\t\talloc = (nr); \\\n-\t\t\telse \\\n-\t\t\t\talloc = alloc_nr(alloc); \\\n-\t\t\tREALLOC_ARRAY(x, alloc); \\\n-\t\t} \\\n-\t} while (0)\n-\n-/*\n- * Similar to ALLOC_GROW but handles updating of the nr value and\n- * zeroing the bytes of the newly-grown array elements.\n- *\n- * DO NOT USE any expression with side-effect for any of the\n- * arguments.\n- */\n-#define ALLOC_GROW_BY(x, nr, increase, alloc) \\\n-\tdo { \\\n-\t\tif (increase) { \\\n-\t\t\tsize_t new_nr = nr + (increase); \\\n-\t\t\tif (new_nr < nr) \\\n-\t\t\t\tBUG(\"negative growth in ALLOC_GROW_BY\"); \\\n-\t\t\tALLOC_GROW(x, new_nr, alloc); \\\n-\t\t\tmemset((x) + nr, 0, sizeof(*(x)) * (increase)); \\\n-\t\t\tnr = new_nr; \\\n-\t\t} \\\n-\t} while (0)\n-\n #endif\ndiff --git a/apply.c b/apply.c\nindex dde124066b..3d69fec836 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -9,7 +9,6 @@\n \n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"base85.h\"\n #include \"config.h\"\n #include \"object-store-ll.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 218c901ec7..0726996839 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -2,7 +2,6 @@\n  * Copyright (c) 2005, 2006 Rene Scharfe\n  */\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n #include \"git-zlib.h\"\ndiff --git a/archive.c b/archive.c\nindex 1817cca9f4..ca11db185b 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"convert.h\"\n #include \"environment.h\"\ndiff --git a/attr.c b/attr.c\nindex e5785c55db..ff0a3e7b61 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -7,7 +7,6 @@\n  */\n \n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"exec-cmd.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex f9d316a7bf..9c987d6567 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -6,7 +6,6 @@\n  */\n \n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"color.h\"\n #include \"builtin.h\"\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex c9c93b80fc..694c8538df 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -5,7 +5,6 @@\n  */\n #define USE_THE_INDEX_VARIABLE\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"convert.h\"\n #include \"diff.h\"\ndiff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c\nindex c655dc4b13..6b62b5375b 100644\n--- a/builtin/checkout--worker.c\n+++ b/builtin/checkout--worker.c\n@@ -1,5 +1,4 @@\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"entry.h\"\n #include \"gettext.h\"\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 787d85edac..11a4d4ef14 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -1,6 +1,5 @@\n #include \"builtin.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"color.h\"\n #include \"editor.h\"\ndiff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c\nindex dc1cf2d25f..3a6a750a8e 100644\n--- a/builtin/credential-cache--daemon.c\n+++ b/builtin/credential-cache--daemon.c\n@@ -1,6 +1,5 @@\n #include \"builtin.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"object-file.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 3ba0fe5a39..44c05ee86c 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -1,5 +1,4 @@\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"object-file.h\"\ndiff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c\nindex b5796b4a4a..7e99c4d61b 100644\n--- a/builtin/fsmonitor--daemon.c\n+++ b/builtin/fsmonitor--daemon.c\n@@ -1,6 +1,5 @@\n #include \"builtin.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 22645c6244..ce866523e2 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -4,7 +4,6 @@\n  * Copyright (c) 2006 Junio C Hamano\n  */\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"repository.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 66202b304d..3da879d138 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1,5 +1,4 @@\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"delta.h\"\n #include \"environment.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 1aca560ec3..1b119eaf0b 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -6,7 +6,6 @@\n  */\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 404700a35c..de68910177 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -10,7 +10,6 @@\n #include \"builtin.h\"\n #include \"abspath.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"editor.h\"\n #include \"environment.h\"\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 0eea810c7e..9a22d4e277 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -4,7 +4,6 @@\n  * Copyright (c) Junio C Hamano, 2006, 2009\n  */\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"quote.h\"\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex ae462bd7d4..fa84fcb20d 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -7,7 +7,6 @@\n #include \"builtin.h\"\n #include \"abspath.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex c3b722b36f..c706fa3720 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -1,5 +1,4 @@\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8251961042..06b33d49e9 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1,5 +1,4 @@\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 51698e3c68..f913e9a8a2 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1,5 +1,4 @@\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"dir.h\"\n #include \"environment.h\"\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 3e2ee44177..434646b074 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -6,7 +6,6 @@\n #define USE_THE_INDEX_VARIABLE\n #include \"builtin.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"commit.h\"\n #include \"environment.h\"\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex f6f07d9b53..e6f9a1ad26 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 463eeabcea..dff819ae50 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -5,7 +5,6 @@\n  */\n #define USE_THE_INDEX_VARIABLE\n #include \"builtin.h\"\n-#include \"alloc.h\"\n #include \"advice.h\"\n #include \"config.h\"\n #include \"lockfile.h\"\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 42706150cf..f6871efd95 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1,7 +1,6 @@\n #define USE_THE_INDEX_VARIABLE\n #include \"builtin.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex fec6816259..73bff3a23d 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -2,7 +2,6 @@\n  * Copyright (c) 2011, Google Inc.\n  */\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"bulk-checkin.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 84d7491420..641427ed41 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"hex.h\"\n #include \"lockfile.h\"\ndiff --git a/chunk-format.c b/chunk-format.c\nindex e7d613c907..140dfa0dcc 100644\n--- a/chunk-format.c\n+++ b/chunk-format.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"chunk-format.h\"\n #include \"csum-file.h\"\n #include \"gettext.h\"\ndiff --git a/commit-reach.c b/commit-reach.c\nindex f15d84566b..4b7c233fd4 100644\n--- a/commit-reach.c\n+++ b/commit-reach.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"commit.h\"\n #include \"commit-graph.h\"\n #include \"decorate.h\"\ndiff --git a/config.c b/config.c\nindex 59fad84eb7..3846a37be9 100644\n--- a/config.c\n+++ b/config.c\n@@ -8,7 +8,6 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"date.h\"\n #include \"branch.h\"\n #include \"config.h\"\ndiff --git a/daemon.c b/daemon.c\nindex a7fe89cd2d..f5e597114b 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"path.h\"\ndiff --git a/delta-islands.c b/delta-islands.c\nindex 5fc6ea6ff5..5de5759f3f 100644\n--- a/delta-islands.c\n+++ b/delta-islands.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"attr.h\"\n #include \"object.h\"\n #include \"blob.h\"\ndiff --git a/diff.c b/diff.c\nindex 9e4d87a8db..ee3eb629e3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3,7 +3,6 @@\n  */\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"base85.h\"\n #include \"config.h\"\n #include \"convert.h\"\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 926b554bd5..5a6e2bcac7 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -3,7 +3,6 @@\n  * Copyright (C) 2005 Junio C Hamano\n  */\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n #include \"object-store-ll.h\"\ndiff --git a/dir-iterator.c b/dir-iterator.c\nindex fb7c47f0e8..278b04243a 100644\n--- a/dir-iterator.c\n+++ b/dir-iterator.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"dir.h\"\n #include \"iterator.h\"\n #include \"dir-iterator.h\"\ndiff --git a/dir.c b/dir.c\nindex d270a1be36..c9dc69fc24 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -7,7 +7,6 @@\n  */\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"convert.h\"\n #include \"dir.h\"\ndiff --git a/ewah/bitmap.c b/ewah/bitmap.c\nindex 12d6aa398e..7b525b1ecd 100644\n--- a/ewah/bitmap.c\n+++ b/ewah/bitmap.c\n@@ -17,7 +17,6 @@\n  * along with this program; if not, see <http://www.gnu.org/licenses/>.\n  */\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"ewok.h\"\n \n #define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))\ndiff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c\nindex c6d4ffc87c..8785cbc54a 100644\n--- a/ewah/ewah_bitmap.c\n+++ b/ewah/ewah_bitmap.c\n@@ -17,7 +17,6 @@\n  * along with this program; if not, see <http://www.gnu.org/licenses/>.\n  */\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"ewok.h\"\n #include \"ewok_rlw.h\"\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex bb288d47f3..65c1ff4bb4 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"repository.h\"\n #include \"config.h\"\n #include \"date.h\"\ndiff --git a/fmt-merge-msg.c b/fmt-merge-msg.c\nindex 4239594ad8..66e47449a0 100644\n--- a/fmt-merge-msg.c\n+++ b/fmt-merge-msg.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"refs.h\"\ndiff --git a/fsck.c b/fsck.c\nindex 3be86616c5..b160b6f9d0 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"date.h\"\n #include \"dir.h\"\n #include \"hex.h\"\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 1832444fa2..d32aa754ae 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1136,6 +1136,81 @@ static inline void move_array(void *dst, const void *src, size_t n, size_t size)\n #define FLEXPTR_ALLOC_STR(x, ptrname, str) \\\n \tFLEXPTR_ALLOC_MEM((x), ptrname, (str), strlen(str))\n \n+#define alloc_nr(x) (((x)+16)*3/2)\n+\n+/**\n+ * Dynamically growing an array using realloc() is error prone and boring.\n+ *\n+ * Define your array with:\n+ *\n+ * - a pointer (`item`) that points at the array, initialized to `NULL`\n+ *   (although please name the variable based on its contents, not on its\n+ *   type);\n+ *\n+ * - an integer variable (`alloc`) that keeps track of how big the current\n+ *   allocation is, initialized to `0`;\n+ *\n+ * - another integer variable (`nr`) to keep track of how many elements the\n+ *   array currently has, initialized to `0`.\n+ *\n+ * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,\n+ * alloc)`.  This ensures that the array can hold at least `n` elements by\n+ * calling `realloc(3)` and adjusting `alloc` variable.\n+ *\n+ * ------------\n+ * sometype *item;\n+ * size_t nr;\n+ * size_t alloc\n+ *\n+ * for (i = 0; i < nr; i++)\n+ * \tif (we like item[i] already)\n+ * \t\treturn;\n+ *\n+ * // we did not like any existing one, so add one\n+ * ALLOC_GROW(item, nr + 1, alloc);\n+ * item[nr++] = value you like;\n+ * ------------\n+ *\n+ * You are responsible for updating the `nr` variable.\n+ *\n+ * If you need to specify the number of elements to allocate explicitly\n+ * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.\n+ *\n+ * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some\n+ * added niceties.\n+ *\n+ * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.\n+ */\n+#define ALLOC_GROW(x, nr, alloc) \\\n+\tdo { \\\n+\t\tif ((nr) > alloc) { \\\n+\t\t\tif (alloc_nr(alloc) < (nr)) \\\n+\t\t\t\talloc = (nr); \\\n+\t\t\telse \\\n+\t\t\t\talloc = alloc_nr(alloc); \\\n+\t\t\tREALLOC_ARRAY(x, alloc); \\\n+\t\t} \\\n+\t} while (0)\n+\n+/*\n+ * Similar to ALLOC_GROW but handles updating of the nr value and\n+ * zeroing the bytes of the newly-grown array elements.\n+ *\n+ * DO NOT USE any expression with side-effect for any of the\n+ * arguments.\n+ */\n+#define ALLOC_GROW_BY(x, nr, increase, alloc) \\\n+\tdo { \\\n+\t\tif (increase) { \\\n+\t\t\tsize_t new_nr = nr + (increase); \\\n+\t\t\tif (new_nr < nr) \\\n+\t\t\t\tBUG(\"negative growth in ALLOC_GROW_BY\"); \\\n+\t\t\tALLOC_GROW(x, new_nr, alloc); \\\n+\t\t\tmemset((x) + nr, 0, sizeof(*(x)) * (increase)); \\\n+\t\t\tnr = new_nr; \\\n+\t\t} \\\n+\t} while (0)\n+\n static inline char *xstrdup_or_null(const char *str)\n {\n \treturn str ? xstrdup(str) : NULL;\ndiff --git a/help.c b/help.c\nindex 389382b148..6d2ebfbd2a 100644\n--- a/help.c\n+++ b/help.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"exec-cmd.h\"\ndiff --git a/http-backend.c b/http-backend.c\nindex 25a19c21b9..e24399ed10 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"git-zlib.h\"\ndiff --git a/line-log.c b/line-log.c\nindex 2eff914bf3..790ab73212 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"line-range.h\"\n #include \"hex.h\"\n #include \"tag.h\"\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex 2a3b7881af..8a08b7af49 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"commit.h\"\n #include \"config.h\"\n #include \"gettext.h\"\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex e075a66c99..9327ccd505 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"dir.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/midx.c b/midx.c\nindex db459e448b..3a16acabbc 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"csum-file.h\"\n #include \"dir.h\"\ndiff --git a/object-file.c b/object-file.c\nindex 527b740018..5ebe1b00c5 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -8,7 +8,6 @@\n  */\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"convert.h\"\n #include \"environment.h\"\ndiff --git a/oid-array.c b/oid-array.c\nindex e8228c777b..8e4717746c 100644\n--- a/oid-array.c\n+++ b/oid-array.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"oid-array.h\"\n #include \"hash-lookup.h\"\n \ndiff --git a/oidtree.c b/oidtree.c\nindex 7d57b7b19e..daef175dc7 100644\n--- a/oidtree.c\n+++ b/oidtree.c\n@@ -4,7 +4,6 @@\n  */\n #include \"git-compat-util.h\"\n #include \"oidtree.h\"\n-#include \"alloc.h\"\n #include \"hash.h\"\n \n struct oidtree_iter_data {\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex d86f4e739a..f6757c3cbf 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 7367f62bb6..01fbc0a657 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"commit.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/pack-objects.c b/pack-objects.c\nindex ccab09fe65..1b8052bece 100644\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"object.h\"\n #include \"pack.h\"\n #include \"pack-objects.h\"\ndiff --git a/packfile.c b/packfile.c\nindex 9126274b37..030b7ec7a8 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/parallel-checkout.c b/parallel-checkout.c\nindex 8637723461..b5a714c711 100644\n--- a/parallel-checkout.c\n+++ b/parallel-checkout.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"entry.h\"\n #include \"gettext.h\"\ndiff --git a/pretty.c b/pretty.c\nindex 7862be105d..4df716686f 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"commit.h\"\n #include \"environment.h\"\ndiff --git a/prio-queue.c b/prio-queue.c\nindex dc2476be53..450775a374 100644\n--- a/prio-queue.c\n+++ b/prio-queue.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"prio-queue.h\"\n \n static inline int compare(struct prio_queue *queue, int i, int j)\ndiff --git a/quote.c b/quote.c\nindex 43c739671e..3c05194496 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"path.h\"\n #include \"quote.h\"\n #include \"strbuf.h\"\ndiff --git a/read-cache.c b/read-cache.c\nindex 140b4f96a0..53d71134e2 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -4,7 +4,6 @@\n  * Copyright (C) Linus Torvalds, 2005\n  */\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"bulk-checkin.h\"\n #include \"config.h\"\n #include \"date.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex e0d03a9f8e..2ed0ecf260 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"gpg-interface.h\"\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex d337e64431..d216f6f966 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"diff.h\"\ndiff --git a/refs.c b/refs.c\nindex d5e0184ca5..c1b3d1f13f 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -4,7 +4,6 @@\n \n #include \"git-compat-util.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"hashmap.h\"\ndiff --git a/refspec.c b/refspec.c\nindex 57f6c2aaf9..d60932f4de 100644\n--- a/refspec.c\n+++ b/refspec.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"hash.h\"\n #include \"hex.h\"\ndiff --git a/remote-curl.c b/remote-curl.c\nindex acf7b2bb40..8a976a0253 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/remote.c b/remote.c\nindex 6e13993bdc..55e7d22a00 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 4227c9612a..7070f75014 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"copy.h\"\n #include \"gettext.h\"\ndiff --git a/revision.c b/revision.c\nindex d66857ecc0..0976d41404 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex 993dd8efbc..cc9821ece2 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1,7 +1,6 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"copy.h\"\n #include \"environment.h\"\ndiff --git a/server-info.c b/server-info.c\nindex f350713ecf..e2fe0f9143 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"hex.h\"\ndiff --git a/shallow.c b/shallow.c\nindex 2fad3504b7..5413719fd4 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"hex.h\"\n #include \"repository.h\"\n #include \"tempfile.h\"\ndiff --git a/sigchain.c b/sigchain.c\nindex ee778c0580..66123bdbab 100644\n--- a/sigchain.c\n+++ b/sigchain.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"sigchain.h\"\n \n #define SIGCHAIN_MAX_SIGNALS 32\ndiff --git a/sparse-index.c b/sparse-index.c\nindex 90d0462256..1fdb07a9e6 100644\n--- a/sparse-index.c\n+++ b/sparse-index.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"name-hash.h\"\ndiff --git a/split-index.c b/split-index.c\nindex 0ee3865a55..8c38687c04 100644\n--- a/split-index.c\n+++ b/split-index.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"hash.h\"\n #include \"mem-pool.h\"\ndiff --git a/strbuf.c b/strbuf.c\nindex ab8e52e9b4..f65d7bee4c 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\ndiff --git a/string-list.c b/string-list.c\nindex 0f8ac117fd..954569f381 100644\n--- a/string-list.c\n+++ b/string-list.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"string-list.h\"\n-#include \"alloc.h\"\n \n void string_list_init_nodup(struct string_list *list)\n {\ndiff --git a/strvec.c b/strvec.c\nindex 17d54b6c3b..89dc9e7e75 100644\n--- a/strvec.c\n+++ b/strvec.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"strvec.h\"\n-#include \"alloc.h\"\n #include \"hex.h\"\n #include \"strbuf.h\"\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex b6908e295f..6a48fd12f6 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"dir.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/submodule.c b/submodule.c\nindex f0f8788d2e..e603a19a87 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"repository.h\"\n #include \"config.h\"\n #include \"submodule-config.h\"\ndiff --git a/t/helper/test-reach.c b/t/helper/test-reach.c\nindex 5b6f217441..119f4908cf 100644\n--- a/t/helper/test-reach.c\n+++ b/t/helper/test-reach.c\n@@ -1,5 +1,4 @@\n #include \"test-tool.h\"\n-#include \"alloc.h\"\n #include \"commit.h\"\n #include \"commit-reach.h\"\n #include \"config.h\"\ndiff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c\nindex 9f46ae12f5..601c9e5036 100644\n--- a/trace2/tr2_tls.c\n+++ b/trace2/tr2_tls.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"thread-utils.h\"\n #include \"trace.h\"\n #include \"trace2/tr2_tls.h\"\ndiff --git a/trailer.c b/trailer.c\nindex 06dc0b7f68..f408f9b058 100644\n--- a/trailer.c\n+++ b/trailer.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\ndiff --git a/transport.c b/transport.c\nindex 0a5794a944..219af8fd50 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"advice.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"environment.h\"\n #include \"hex.h\"\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 42ed86ef58..6c07913f3f 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"tree-walk.h\"\n-#include \"alloc.h\"\n #include \"dir.h\"\n #include \"gettext.h\"\n #include \"hex.h\"\ndiff --git a/userdiff.c b/userdiff.c\nindex 664c7c1402..e399543823 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -1,5 +1,4 @@\n #include \"git-compat-util.h\"\n-#include \"alloc.h\"\n #include \"config.h\"\n #include \"userdiff.h\"\n #include \"attr.h\"\ndiff --git a/worktree.c b/worktree.c\nindex 2ea5d45e1e..b8cf29e6a1 100644\n--- a/worktree.c\n+++ b/worktree.c\n@@ -1,6 +1,5 @@\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"alloc.h\"\n #include \"environment.h\"\n #include \"gettext.h\"\n #include \"path.h\"\n-- \n2.41.0.255.g8b1d071c50-goog\n\n"},{"id":"479206","messageId":"20230705170924.3833828-4-calvinwan@google.com","threadId":"59951","inReplyTo":"20230705170812.3833103-1-calvinwan@google.com","subject":"[PATCH v5 4/6] kwset: move translation table from ctype","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:09:22Z","receivedAt":"2023-07-05T17:10:09Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"This table was originally introduced to solely be used with kwset\nmachinery (0f871cf56e), so it would make sense for it to belong in\nkwset.[ch] rather than ctype.c and git-compat-util.h. It is only used in\ndiffcore-pickaxe.c, which already includes kwset.h so no other headers\nhave to be modified.\n\nSigned-off-by: Calvin Wan <calvinwan@google.com>\n---\n ctype.c           | 36 ------------------------------------\n git-compat-util.h |  3 ---\n kwset.c           | 36 ++++++++++++++++++++++++++++++++++++\n kwset.h           |  2 ++\n 4 files changed, 38 insertions(+), 39 deletions(-)\n\ndiff --git a/ctype.c b/ctype.c\nindex fc0225cebd..3451745550 100644\n--- a/ctype.c\n+++ b/ctype.c\n@@ -28,39 +28,3 @@ const unsigned char sane_ctype[256] = {\n \tA, A, A, A, A, A, A, A, A, A, A, R, R, U, P, X,\t\t/* 112..127 */\n \t/* Nothing in the 128.. range */\n };\n-\n-/* For case-insensitive kwset */\n-const unsigned char tolower_trans_tbl[256] = {\n-\t0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n-\t0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n-\t0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n-\t0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n-\t ' ',  '!',  '\"',  '#',  '$',  '%',  '&', 0x27,\n-\t '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',\n-\t '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',\n-\t '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',\n-\t '@',  'a',  'b',  'c',  'd',  'e',  'f',  'g',\n-\t 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',\n-\t 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',\n-\t 'x',  'y',  'z',  '[', 0x5c,  ']',  '^',  '_',\n-\t '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',\n-\t 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',\n-\t 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',\n-\t 'x',  'y',  'z',  '{',  '|',  '}',  '~', 0x7f,\n-\t0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,\n-\t0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,\n-\t0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,\n-\t0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,\n-\t0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,\n-\t0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,\n-\t0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,\n-\t0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,\n-\t0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,\n-\t0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,\n-\t0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,\n-\t0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,\n-\t0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,\n-\t0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,\n-\t0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,\n-\t0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,\n-};\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 5f916e1094..1832444fa2 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1152,9 +1152,6 @@ static inline size_t xsize_t(off_t len)\n #define HOST_NAME_MAX 256\n #endif\n \n-/* in ctype.c, for kwset users */\n-extern const unsigned char tolower_trans_tbl[256];\n-\n #include \"sane-ctype.h\"\n \n /*\ndiff --git a/kwset.c b/kwset.c\nindex 4b14d4f86b..bbfcf815a5 100644\n--- a/kwset.c\n+++ b/kwset.c\n@@ -49,6 +49,42 @@ static void *obstack_chunk_alloc(long size)\n \n #define U(c) ((unsigned char) (c))\n \n+/* For case-insensitive kwset */\n+const unsigned char tolower_trans_tbl[256] = {\n+\t0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n+\t0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n+\t0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n+\t0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n+\t ' ',  '!',  '\"',  '#',  '$',  '%',  '&', 0x27,\n+\t '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',\n+\t '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',\n+\t '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',\n+\t '@',  'a',  'b',  'c',  'd',  'e',  'f',  'g',\n+\t 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',\n+\t 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',\n+\t 'x',  'y',  'z',  '[', 0x5c,  ']',  '^',  '_',\n+\t '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',\n+\t 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',\n+\t 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',\n+\t 'x',  'y',  'z',  '{',  '|',  '}',  '~', 0x7f,\n+\t0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,\n+\t0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,\n+\t0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,\n+\t0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,\n+\t0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,\n+\t0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,\n+\t0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,\n+\t0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,\n+\t0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,\n+\t0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,\n+\t0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,\n+\t0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,\n+\t0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,\n+\t0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,\n+\t0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,\n+\t0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,\n+};\n+\n /* Balanced tree of edges and labels leaving a given trie node. */\n struct tree\n {\ndiff --git a/kwset.h b/kwset.h\nindex f50ecae573..d42a793a30 100644\n--- a/kwset.h\n+++ b/kwset.h\n@@ -26,6 +26,8 @@\n    The author may be reached (Email) at the address mike@ai.mit.edu,\n    or (US mail) as Mike Haertel c/o Free Software Foundation. */\n \n+extern const unsigned char tolower_trans_tbl[256];\n+\n struct kwsmatch\n {\n   int index;\t\t\t/* Index number of matching keyword. */\n-- \n2.41.0.255.g8b1d071c50-goog\n\n"},{"id":"479207","messageId":"20230705170812.3833103-1-calvinwan@google.com","threadId":"59951","inReplyTo":"20230630202237.3069327-1-calvinwan@google.com","subject":"[PATCH v5 0/6] git-compat-util cleanups","fromName":"Calvin Wan","fromEmail":"calvinwan@google.com","sentAt":"2023-07-05T17:08:11Z","receivedAt":"2023-07-05T17:15:47Z","isPatch":true,"sender":{"key":"calvinwan@google.com","avatar":"https://avatars.githubusercontent.com/u/92547554?v=4"},"body":"Originally[1], this series intended to move out all non-compat specific\nheaders and macros to either their respective files or common.h.\nHowever, moving headers specifically to usage.h and common.h would cause\ncircular header inclusions (i.e usage.h includes git-compat-util.h which\nincludes usage.h) so that the rest of the codebase would not have to\nalso include usage.h and common.h. The tradeoff between simplifying\ngit-compat-util.h versus a confusing inclusion setup was deemed not\nworthwhile so those patches have been dropped.\n\nThe first 4 patches of this series now focuses on cleaning up and\nreducing the scope of git-compat-util.h by moving headers to their\nrespective files in cases that do not cause circular header inclusions.\nThe rest of series focuses on removing unnecessary headers.\n\n[1] https://lore.kernel.org/git/cover.1687874975.git.phillip.wood@dunelm.org.uk/T/#m4f75ad7065a74659ee0f648b50200330a925481a\n\nCalvin Wan (6):\n  git-compat-util: move strbuf.c funcs to its header\n  git-compat-util: move wrapper.c funcs to its header\n  sane-ctype.h: create header for sane-ctype macros\n  kwset: move translation table from ctype\n  treewide: remove unnecessary includes for wrapper.h\n  git-compat-util: move alloc macros to git-compat-util.h\n\n add-patch.c                        |   1 -\n alias.c                            |   1 -\n alloc.h                            |  75 --------\n apply.c                            |   2 -\n archive-tar.c                      |   1 -\n archive.c                          |   1 -\n attr.c                             |   1 -\n builtin/am.c                       |   1 -\n builtin/bisect.c                   |   1 -\n builtin/blame.c                    |   1 -\n builtin/branch.c                   |   1 -\n builtin/bugreport.c                |   1 -\n builtin/cat-file.c                 |   1 -\n builtin/checkout--worker.c         |   1 -\n builtin/clone.c                    |   1 -\n builtin/config.c                   |   2 -\n builtin/credential-cache--daemon.c |   1 -\n builtin/credential-cache.c         |   1 -\n builtin/difftool.c                 |   1 -\n builtin/fast-import.c              |   1 -\n builtin/fetch-pack.c               |   1 -\n builtin/fmt-merge-msg.c            |   1 -\n builtin/fsmonitor--daemon.c        |   1 -\n builtin/gc.c                       |   1 -\n builtin/get-tar-commit-id.c        |   1 -\n builtin/grep.c                     |   1 -\n builtin/index-pack.c               |   2 -\n builtin/init-db.c                  |   1 -\n builtin/log.c                      |   1 -\n builtin/merge.c                    |   2 -\n builtin/mktree.c                   |   1 -\n builtin/mv.c                       |   1 -\n builtin/name-rev.c                 |   1 -\n builtin/pack-objects.c             |   2 -\n builtin/rebase.c                   |   1 -\n builtin/receive-pack.c             |   1 -\n builtin/repack.c                   |   1 -\n builtin/rerere.c                   |   1 -\n builtin/rev-parse.c                |   1 -\n builtin/revert.c                   |   1 -\n builtin/rm.c                       |   1 -\n builtin/submodule--helper.c        |   1 -\n builtin/symbolic-ref.c             |   1 +\n builtin/unpack-file.c              |   1 -\n builtin/unpack-objects.c           |   1 +\n builtin/worktree.c                 |   1 -\n bulk-checkin.c                     |   2 -\n cache-tree.c                       |   1 -\n chunk-format.c                     |   1 -\n combine-diff.c                     |   1 -\n commit-graph.c                     |   1 -\n commit-reach.c                     |   1 -\n compat/terminal.c                  |   1 -\n config.c                           |   2 -\n convert.c                          |   1 -\n copy.c                             |   1 -\n csum-file.c                        |   1 -\n ctype.c                            |  36 ----\n daemon.c                           |   2 -\n delta-islands.c                    |   1 -\n diff.c                             |   2 -\n diffcore-rename.c                  |   1 -\n dir-iterator.c                     |   1 -\n dir.c                              |   2 -\n editor.c                           |   1 -\n entry.c                            |   1 -\n environment.c                      |   1 -\n ewah/bitmap.c                      |   1 -\n ewah/ewah_bitmap.c                 |   1 -\n fetch-pack.c                       |   2 -\n fmt-merge-msg.c                    |   1 -\n fsck.c                             |   1 -\n git-compat-util.h                  | 284 ++++++++---------------------\n gpg-interface.c                    |   1 -\n grep.c                             |   1 -\n help.c                             |   1 -\n http-backend.c                     |   2 -\n imap-send.c                        |   1 -\n kwset.c                            |  36 ++++\n kwset.h                            |   2 +\n line-log.c                         |   1 -\n list-objects-filter-options.c      |   1 -\n list-objects-filter.c              |   1 -\n merge-ll.c                         |   1 -\n merge-recursive.c                  |   1 -\n midx.c                             |   1 -\n notes-merge.c                      |   1 -\n object-file.c                      |   2 -\n oid-array.c                        |   1 -\n oidtree.c                          |   1 -\n pack-bitmap-write.c                |   1 -\n pack-bitmap.c                      |   1 -\n pack-objects.c                     |   1 -\n pack-write.c                       |   1 -\n packfile.c                         |   2 -\n parallel-checkout.c                |   2 -\n path.c                             |   1 -\n pkt-line.c                         |   1 -\n pretty.c                           |   1 -\n prio-queue.c                       |   1 -\n quote.c                            |   1 -\n read-cache.c                       |   2 -\n rebase-interactive.c               |   1 -\n ref-filter.c                       |   1 -\n reflog-walk.c                      |   1 -\n refs.c                             |   2 -\n refspec.c                          |   1 -\n remote-curl.c                      |   1 -\n remote.c                           |   1 -\n rerere.c                           |   2 -\n revision.c                         |   1 -\n sane-ctype.h                       |  66 +++++++\n send-pack.c                        |   1 -\n sequencer.c                        |   2 -\n server-info.c                      |   2 -\n setup.c                            |   1 -\n shallow.c                          |   2 -\n sigchain.c                         |   1 -\n sparse-index.c                     |   1 -\n split-index.c                      |   1 -\n strbuf.c                           |   2 -\n strbuf.h                           |  32 ++++\n streaming.c                        |   1 -\n string-list.c                      |   1 -\n strvec.c                           |   1 -\n submodule-config.c                 |   1 -\n submodule.c                        |   1 -\n t/helper/test-delta.c              |   1 -\n t/helper/test-fsmonitor-client.c   |   1 -\n t/helper/test-reach.c              |   1 -\n t/helper/test-read-cache.c         |   1 -\n tag.c                              |   1 -\n tempfile.c                         |   1 -\n trace.c                            |   1 -\n trace2/tr2_tls.c                   |   1 -\n trailer.c                          |   1 -\n transport-helper.c                 |   1 -\n transport.c                        |   2 -\n tree-walk.c                        |   1 -\n upload-pack.c                      |   1 -\n usage.c                            |   1 -\n userdiff.c                         |   1 -\n versioncmp.c                       |   1 +\n worktree.c                         |   2 -\n wrapper.c                          |   1 -\n wrapper.h                          | 111 +++++++++++\n write-or-die.c                     |   1 -\n 147 files changed, 327 insertions(+), 478 deletions(-)\n create mode 100644 sane-ctype.h\n\nRange-diff against v4:\n-:  ---------- > 1:  144284a8f1 git-compat-util: move strbuf.c funcs to its header\n-:  ---------- > 2:  39913c44e8 git-compat-util: move wrapper.c funcs to its header\n-:  ---------- > 3:  c495762940 sane-ctype.h: create header for sane-ctype macros\n-:  ---------- > 4:  2750d35e6d kwset: move translation table from ctype\n-:  ---------- > 5:  b5fb55d235 treewide: remove unnecessary includes for wrapper.h\n1:  140d98111f ! 6:  e4d8ad39d0 common: move alloc macros to common.h\n    @@ Metadata\n     Author: Calvin Wan <calvinwan@google.com>\n     \n      ## Commit message ##\n    -    common: move alloc macros to common.h\n    +    git-compat-util: move alloc macros to git-compat-util.h\n     \n         alloc_nr, ALLOC_GROW, and ALLOC_GROW_BY are commonly used macros for\n         dynamic array allocation. Moving these macros to git-compat-util.h with\n-- \n2.41.0.255.g8b1d071c50-goog\n\n"}]}