Skip to content

Commit 52c0f33

Browse files
ttaylorrgitster
andcommitted
run-command.c: fix missing include under NO_PTHREADS
Git 2.41-rc0 fails to compile run-command.c with `NO_PTHREADS` defined, i.e. $ make NO_PTHREADS=1 run-command.o as `ALLOC_GROW()` macro is used in the `atexit()` emulation but the macro definition is not available. This bisects to 36bf195 (alloc.h: move ALLOC_GROW() functions from cache.h, 2023-02-24), which replaced includes of <cache.h> with <alloc.h>, which is the new home of `ALLOC_GROW()` (and `ALLOC_GROW_BY()`). We can see that run-command.c is the only one that try to use these macros without including <alloc.h>. $ git grep -l -e '[^_]ALLOC_GROW(' -e 'ALLOC_GROW_BY(' \*.c | sort >/tmp/1 $ git grep -l 'alloc\.h' \*.c | sort >/tmp/2 $ comm -23 /tmp/[12] compat/simple-ipc/ipc-unix-socket.c run-command.c The "compat/" file only talks about the macro in the comment, and is not broken. We could fix this by conditionally including "alloc.h" when `NO_PTHREADS` is defined. But we have relatively few examples of conditional includes throughout the tree[^1]. Instead, include "alloc.h" unconditionally in run-command.c to allow it to successfully compile even when NO_PTHREADS is defined. [^1]: With `git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1`. Reported-by: Randall S. Becker <[email protected]> Co-authored-by: Junio C Hamano <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 88cc8ed commit 52c0f33

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

run-command.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "packfile.h"
1212
#include "hook.h"
1313
#include "compat/nonblock.h"
14+
#include "alloc.h"
1415

1516
void child_process_init(struct child_process *child)
1617
{

0 commit comments

Comments
 (0)