Git fork

exec_cmd: RUNTIME_PREFIX on z/OS systems

Enable Git to resolve its own binary location using __getprogramdir
and getprogname.

Since /proc is not a mandatory filesystem on z/OS, we cannot rely on the
git_get_exec_path_procfs method to determine Git's executable path. To
address this, we have implemented git_get_exec_path_zos, which resolves
the executable path by extracting it from the current program's
directory and filename.

Signed-off-by: D Harithamma <harithamma.d@ibm.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

D Harithamma and committed by
Junio C Hamano
987bbcd0 3a7362eb

+32
+8
Makefile
··· 385 # supports calling _NSGetExecutablePath to retrieve the path of the running 386 # executable. 387 # 388 # When using RUNTIME_PREFIX, define HAVE_WPGMPTR if your platform offers 389 # the global variable _wpgmptr containing the absolute path of the current 390 # executable (this is the case on Windows). ··· 2153 2154 ifdef HAVE_NS_GET_EXECUTABLE_PATH 2155 BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH 2156 endif 2157 2158 ifdef HAVE_WPGMPTR
··· 385 # supports calling _NSGetExecutablePath to retrieve the path of the running 386 # executable. 387 # 388 + # When using RUNTIME_PREFIX, define HAVE_ZOS_GET_EXECUTABLE_PATH if your platform 389 + # supports calling __getprogramdir and getprogname to retrieve the path of the 390 + # running executable. 391 + # 392 # When using RUNTIME_PREFIX, define HAVE_WPGMPTR if your platform offers 393 # the global variable _wpgmptr containing the absolute path of the current 394 # executable (this is the case on Windows). ··· 2157 2158 ifdef HAVE_NS_GET_EXECUTABLE_PATH 2159 BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH 2160 + endif 2161 + 2162 + ifdef HAVE_ZOS_GET_EXECUTABLE_PATH 2163 + BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH 2164 endif 2165 2166 ifdef HAVE_WPGMPTR
+1
config.mak.uname
··· 648 NO_GECOS_IN_PWENT = YesPlease 649 HAVE_STRINGS_H = YesPlease 650 NEEDS_MODE_TRANSLATION = YesPlease 651 endif 652 ifeq ($(uname_S),MINGW) 653 ifeq ($(shell expr "$(uname_R)" : '1\.'),2)
··· 648 NO_GECOS_IN_PWENT = YesPlease 649 HAVE_STRINGS_H = YesPlease 650 NEEDS_MODE_TRANSLATION = YesPlease 651 + HAVE_ZOS_GET_EXECUTABLE_PATH = YesPlease 652 endif 653 ifeq ($(uname_S),MINGW) 654 ifeq ($(shell expr "$(uname_R)" : '1\.'),2)
+23
exec-cmd.c
··· 150 } 151 #endif /* HAVE_NS_GET_EXECUTABLE_PATH */ 152 153 #ifdef HAVE_WPGMPTR 154 /* 155 * Resolves the executable path by using the global variable _wpgmptr. ··· 205 #ifdef HAVE_WPGMPTR 206 git_get_exec_path_wpgmptr(buf) && 207 #endif /* HAVE_WPGMPTR */ 208 209 git_get_exec_path_from_argv0(buf, argv0)) { 210 return -1;
··· 150 } 151 #endif /* HAVE_NS_GET_EXECUTABLE_PATH */ 152 153 + #ifdef HAVE_ZOS_GET_EXECUTABLE_PATH 154 + /* 155 + * Resolves the executable path from current program's directory and name. 156 + * 157 + * Returns 0 on success, -1 on failure. 158 + */ 159 + static int git_get_exec_path_zos(struct strbuf *buf) 160 + { 161 + char *dir = __getprogramdir(); 162 + char *exe = getprogname(); 163 + if (dir && exe) { 164 + strbuf_addf(buf, "%s/%s", dir, exe); 165 + return 0; 166 + } 167 + return -1; 168 + } 169 + 170 + #endif /* HAVE_ZOS_GET_EXECUTABLE_PATH */ 171 + 172 #ifdef HAVE_WPGMPTR 173 /* 174 * Resolves the executable path by using the global variable _wpgmptr. ··· 224 #ifdef HAVE_WPGMPTR 225 git_get_exec_path_wpgmptr(buf) && 226 #endif /* HAVE_WPGMPTR */ 227 + 228 + #ifdef HAVE_ZOS_GET_EXECUTABLE_PATH 229 + git_get_exec_path_zos(buf) && 230 + #endif /*HAVE_ZOS_GET_EXECUTABLE_PATH */ 231 232 git_get_exec_path_from_argv0(buf, argv0)) { 233 return -1;