From c6144faa41eb8ee0efd101f18e5b3190c0e58e00 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 20 Jun 2024 19:26:48 +0900 Subject: [PATCH] Apply https://lore.kernel.org/git/pull.1752.git.1718777398765.gitgitgadget@gmail.com/ --- src/build.mk | 7 ++++-- src/mingw.c | 2 +- src/mingw.c.patch | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 src/mingw.c.patch diff --git a/src/build.mk b/src/build.mk index 9cc141bf9..1fdf14666 100644 --- a/src/build.mk +++ b/src/build.mk @@ -70,7 +70,7 @@ CINNABAR_OBJECTS += regex.o PATCHES = $(notdir $(wildcard $(SOURCE_DIR)/src/*.patch)) define patch -$1.patched.c: $$(SOURCE_DIR)/src/$1.c.patch $$(firstword $$(wildcard $$(SOURCE_DIR)/git-core/$1.c $$(SOURCE_DIR)/git-core/builtin/$1.c $$(SOURCE_DIR)/git-core/compat/win32/$1.c)) +$1.patched.c: $$(SOURCE_DIR)/src/$1.c.patch $$(firstword $$(wildcard $$(SOURCE_DIR)/git-core/$1.c $$(SOURCE_DIR)/git-core/builtin/$1.c $$(SOURCE_DIR)/git-core/compat/$1.c $$(SOURCE_DIR)/git-core/compat/win32/$1.c)) patch -p1 -F0 -o $$@ $$(lastword $$^) < $$< endef @@ -99,7 +99,7 @@ missing_obj_dirs := $(filter-out $(wildcard $(obj_dirs)),$(obj_dirs)) $(ALL_CINNABAR_OBJECTS) $(LIB_OBJS) $(REFTABLE_OBJS) $(XDIFF_OBJS): $(missing_obj_dirs) endif -PATCHED_GIT_OBJECTS := $(filter-out fast-import.patched.o,$(PATCHES:%.c.patch=%.patched.o)) +PATCHED_GIT_OBJECTS := $(filter-out mingw.patched.o fast-import.patched.o,$(PATCHES:%.c.patch=%.patched.o)) ifeq (,$(filter compat/win32/fscache.o,$(LIB_OBJS))) PATCHED_GIT_OBJECTS := $(filter-out fscache.patched.o,$(PATCHED_GIT_OBJECTS)) endif @@ -137,6 +137,9 @@ linker-flags: GIT-LDFLAGS FORCE $(CINNABAR_OBJECTS): %.o: $(SOURCE_DIR)/src/%.c $(PATCHED_GIT_OBJECTS): %.o: %.c cinnabar-fast-import.o: fast-import.patched.c +ifeq ($(uname_S),MINGW) +mingw.o: mingw.patched.c +endif $(ALL_CINNABAR_OBJECTS): GIT-CFLAGS $(missing_dep_dirs) $(ALL_CINNABAR_OBJECTS): diff --git a/src/mingw.c b/src/mingw.c index be5c4043b..08596ddda 100644 --- a/src/mingw.c +++ b/src/mingw.c @@ -8,7 +8,7 @@ static inline void winansi_init(void) {} extern int cinnabar_main(int argc, const char *argv[]); // Work around the function being declared despite NO_UNIX_SOCKETS. int mingw_have_unix_sockets(void); -#include "compat/mingw.c" +#include "mingw.patched.c" #else typedef int make_pedantic_happy; #endif diff --git a/src/mingw.c.patch b/src/mingw.c.patch new file mode 100644 index 000000000..80b6d767e --- /dev/null +++ b/src/mingw.c.patch @@ -0,0 +1,57 @@ +diff --git a/compat/mingw.c b/compat/mingw.c +index 303ffaa19f..e87f407f95 100644 +--- a/compat/mingw.c ++++ b/compat/mingw.c +@@ -1,30 +1,30 @@ +-#include "../git-compat-util.h" ++#include "git-compat-util.h" + #include "win32.h" + #include + #include + #include + #include + #include +-#include "../strbuf.h" +-#include "../run-command.h" +-#include "../abspath.h" +-#include "../alloc.h" ++#include "strbuf.h" ++#include "run-command.h" ++#include "abspath.h" ++#include "alloc.h" + #include "win32/exit-process.h" + #include "win32/lazyload.h" +-#include "../config.h" +-#include "../environment.h" +-#include "../trace2.h" +-#include "../symlinks.h" +-#include "../wrapper.h" ++#include "config.h" ++#include "environment.h" ++#include "trace2.h" ++#include "symlinks.h" ++#include "wrapper.h" + #include "dir.h" + #include "gettext.h" + #define SECURITY_WIN32 + #include +-#include "../write-or-die.h" +-#include "../repository.h" ++#include "write-or-die.h" ++#include "repository.h" + #include "win32/fscache.h" +-#include "../attr.h" +-#include "../string-list.h" ++#include "attr.h" ++#include "string-list.h" + #include "win32/wsl.h" + + #define HCAST(type, handle) ((type)(intptr_t)handle) +@@ -32,7 +32,6 @@ + void open_in_gdb(void) + { + static struct child_process cp = CHILD_PROCESS_INIT; +- extern char *_pgmptr; + + strvec_pushl(&cp.args, "mintty", "gdb", NULL); + strvec_pushf(&cp.args, "--pid=%d", getpid());