Skip to content

Commit 77d0df4

Browse files
dschoGit for Windows Build Agent
authored andcommitted
mingw: only use Bash-ism builtin pwd -W when available
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 <[email protected]>
1 parent 1d96fd7 commit 77d0df4

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

git-sh-setup.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,16 @@ case $(uname -s) in
306306
/usr/bin/find "$@"
307307
}
308308
fi
309-
# git sees Windows-style pwd
310-
pwd () {
311-
builtin pwd -W
312-
}
309+
# On Windows, Git wants Windows paths. But /usr/bin/pwd spits out
310+
# Unix-style paths. At least in Bash, we have a builtin pwd that
311+
# understands the -W option to force "mixed" paths, i.e. with drive
312+
# prefix but still with forward slashes. Let's use that, if available.
313+
if type builtin >/dev/null 2>&1
314+
then
315+
pwd () {
316+
builtin pwd -W
317+
}
318+
fi
313319
is_absolute_path () {
314320
case "$1" in
315321
[/\\]* | [A-Za-z]:*)

t/test-lib.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,10 +1672,16 @@ Darwin)
16721672
/usr/bin/find "$@"
16731673
}
16741674
fi
1675-
# git sees Windows-style pwd
1676-
pwd () {
1677-
builtin pwd -W
1678-
}
1675+
# On Windows, Git wants Windows paths. But /usr/bin/pwd spits out
1676+
# Unix-style paths. At least in Bash, we have a builtin pwd that
1677+
# understands the -W option to force "mixed" paths, i.e. with drive
1678+
# prefix but still with forward slashes. Let's use that, if available.
1679+
if type builtin >/dev/null 2>&1
1680+
then
1681+
pwd () {
1682+
builtin pwd -W
1683+
}
1684+
fi
16791685
# no POSIX permissions
16801686
# backslashes in pathspec are converted to '/'
16811687
# exec does not inherit the PID

0 commit comments

Comments
 (0)