Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mingw: only use Bash-ism builtin pwd -W when available
Browse files Browse the repository at this point in the history
Traditionally, Git for Windows' SDK uses Bash as its default shell.
However, other Unix shells are available, too. Most notably, the Win32
port of BusyBox comes with `ash` whose `pwd` command already prints
Windows paths as Git for Windows wants them, while there is not even a
`builtin` command.

Therefore, let's be careful not to override `pwd` unless we know that
the `builtin` command is available.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho committed Oct 3, 2024
1 parent 747d1af commit 54f6687
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions git-sh-setup.sh
Original file line number Diff line number Diff line change
@@ -306,10 +306,16 @@ case $(uname -s) in
/usr/bin/find "$@"
}
fi
# git sees Windows-style pwd
pwd () {
builtin pwd -W
}
# On Windows, Git wants Windows paths. But /usr/bin/pwd spits out
# Unix-style paths. At least in Bash, we have a builtin pwd that
# understands the -W option to force "mixed" paths, i.e. with drive
# prefix but still with forward slashes. Let's use that, if available.
if type builtin >/dev/null 2>&1
then
pwd () {
builtin pwd -W
}
fi
is_absolute_path () {
case "$1" in
[/\\]* | [A-Za-z]:*)
14 changes: 10 additions & 4 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
@@ -1733,10 +1733,16 @@ case $uname_s in
/usr/bin/find "$@"
}
fi
# git sees Windows-style pwd
pwd () {
builtin pwd -W
}
# On Windows, Git wants Windows paths. But /usr/bin/pwd spits out
# Unix-style paths. At least in Bash, we have a builtin pwd that
# understands the -W option to force "mixed" paths, i.e. with drive
# prefix but still with forward slashes. Let's use that, if available.
if type builtin >/dev/null 2>&1
then
pwd () {
builtin pwd -W
}
fi
# no POSIX permissions
# backslashes in pathspec are converted to '/'
# exec does not inherit the PID

0 comments on commit 54f6687

Please sign in to comment.