git/compat
Johannes Schindelin c34949e229 mingw: when path_lookup() failed, try BusyBox
BusyBox comes with a ton of applets ("applet" being the identical
concept to Git's "builtins"). And similar to Git's builtins, the applets
can be called via `busybox <command>`, or the BusyBox executable can be
copied/hard-linked to the command name.

The similarities do not end here. Just as with Git's builtins, it is
problematic that BusyBox' hard-linked applets cannot easily be put into
a .zip file: .zip archives have no concept of hard-links and therefore
would store identical copies (and also extract identical copies,
"inflating" the archive unnecessarily).

To counteract that issue, MinGit already ships without hard-linked
copies of the builtins, and the plan is to do the same with BusyBox'
applets: simply ship busybox.exe as single executable, without
hard-linked applets.

To accommodate that, Git is being taught by this commit a very special
trick, exploiting the fact that it is possible to call an executable
with a command-line whose argv[0] is different from the executable's
name: when `sh` is to be spawned, and no `sh` is found in the PATH, but
busybox.exe is, use that executable (with unchanged argv).

Likewise, if any executable to be spawned is not on the PATH, but
busybox.exe is found, parse the output of `busybox.exe --help` to find
out what applets are included, and if the command matches an included
applet name, use busybox.exe to execute it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-06-01 10:14:41 -06:00
..
fsmonitor fsmonitor: reduce includes of cache.h 2023-04-24 12:47:33 -07:00
linux treewide: remove unnecessary cache.h inclusion from several sources 2023-03-21 10:56:51 -07:00
mimalloc mimalloc: use "weak" random seed when statically linked 2023-06-01 10:14:06 -06:00
nedmalloc nedmalloc: avoid new compile error 2022-05-24 15:58:31 -07:00
poll mingw: workaround for hangs when sending STDIN 2020-02-27 14:23:29 -08:00
regex compat/regex: move stdlib.h up in inclusion chain 2020-04-27 11:21:16 -07:00
simple-ipc treewide: remove unnecessary cache.h inclusion 2023-04-11 08:52:09 -07:00
stub tr2: make process info collection platform-generic 2021-07-22 13:35:20 -07:00
vcbuild Merge pull request #3220 from dscho/there-is-no-vs/master-anymore 2023-06-01 10:14:22 -06:00
win32 mingw: lstat: compute correct size for symlinks 2023-06-01 10:14:40 -06:00
.gitattributes Provide zlib's uncompress2 from compat/zlib-compat.c 2021-10-08 10:45:48 -07:00
access.c git-compat-util: work around for access(X_OK) under root 2019-04-25 17:49:44 +09:00
apple-common-crypto.h imap-send: use HMAC() function provided by OpenSSL 2016-04-08 11:45:47 -07:00
basename.c compat/basename.c: provide a dirname() compatibility function 2016-01-12 10:40:54 -08:00
bswap.h bswap.h: add support for built-in bswap functions 2023-06-01 10:14:15 -06:00
compiler.h bugreport: add compiler info 2020-04-16 15:23:42 -07:00
disk.h abspath.h: move absolute path functions from cache.h 2023-03-21 10:56:52 -07:00
fileno.c git-compat-util: work around for access(X_OK) under root 2019-04-25 17:49:44 +09:00
fopen.c git_fopen: fix a sparse 'not declared' warning 2017-05-26 12:33:55 +09:00
hstrerror.c compat/hstrerror: convert sprintf to snprintf 2015-09-25 10:18:18 -07:00
inet_ntop.c compat/inet_ntop: fix off-by-one in inet_ntop4 2015-09-25 10:18:18 -07:00
inet_pton.c Drop system includes from inet_pton/inet_ntop compatibility wrappers 2012-02-05 16:32:33 -08:00
lazyload-curl.c http: when loading libcurl lazily, allow for multiple SSL backends 2023-06-01 10:14:16 -06:00
memmem.c
mingw.c mingw: when path_lookup() failed, try BusyBox 2023-06-01 10:14:41 -06:00
mingw.h Introduce helper to create symlinks that knows about index_state 2023-06-01 10:14:41 -06:00
mkdir.c tree-wide: apply equals-null.cocci 2022-05-02 09:50:37 -07:00
mkdtemp.c
mmap.c tree-wide: apply equals-null.cocci 2022-05-02 09:50:37 -07:00
msvc.c
msvc.h msvc: add pragmas for common warnings 2019-06-25 10:46:57 -07:00
nonblock.c mark unused parameters in trivial compat functions 2022-10-17 21:24:03 -07:00
nonblock.h compat: add function to enable nonblocking pipes 2022-08-17 09:21:40 -07:00
obstack.c compat/obstack: fix -Wcast-function-type warnings 2019-01-17 11:13:38 -08:00
obstack.h obstack: avoid computing offsets from NULL pointer 2020-01-28 23:13:25 -08:00
open.c Makefile: add OPEN_RETURNS_EINTR knob 2021-02-26 14:15:51 -08:00
pread.c treewide: remove double forward declaration of read_in_full 2023-04-11 08:52:11 -07:00
precompose_utf8.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
precompose_utf8.h precompose_utf8: make precompose_string_if_needed() public 2021-04-05 17:30:04 -07:00
qsort_s.c compat/qsort_s.c: avoid using potentially unaligned access 2022-01-07 14:20:58 -08:00
regcomp_enhanced.c use enhanced basic regular expressions on macOS 2023-01-08 10:06:34 +09:00
setenv.c use st_add and st_mult for allocation size computation 2016-02-22 14:51:09 -08:00
sha1-chunked.c sha1: allow limiting the size of the data passed to SHA1_Update() 2015-11-05 10:35:11 -08:00
sha1-chunked.h sha1: allow limiting the size of the data passed to SHA1_Update() 2015-11-05 10:35:11 -08:00
snprintf.c MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more 2016-03-30 11:13:01 -07:00
stat.c compat: convert modes to use portable file type values 2014-12-04 11:58:36 -08:00
strcasestr.c
strdup.c compat: move strdup(3) replacement to its own file 2016-09-07 10:41:45 -07:00
strlcpy.c
strtoimax.c Add strtoimax() compatibility function. 2011-11-02 13:06:30 -07:00
strtoumax.c
terminal.c mingw (git_terminal_prompt): do fall back to CONIN$/CONOUT$ method 2023-06-01 10:14:38 -06:00
terminal.h terminal: don't assume stdin is /dev/tty 2022-03-16 12:24:43 -07:00
unsetenv.c unsetenv(3) returns int, not void 2021-10-29 15:00:58 -07:00
win32.h mingw: teach fscache and dirent about symlinks 2023-06-01 10:14:39 -06:00
win32mmap.c mmap(win32): avoid expensive fstat() call 2016-04-22 15:01:16 -07:00
winansi.c winansi: check result and Buffer before using Name 2023-06-01 10:14:13 -06:00
zlib-uncompress2.c compat: auto-detect if zlib has uncompress2() 2022-01-26 09:05:55 -08:00