Merge branch 'busybox-w32'

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2019-02-07 14:35:33 +01:00
commit b6adf7fbee
41 changed files with 300 additions and 103 deletions

1
.gitattributes vendored
View File

@ -6,6 +6,7 @@
*.pm text eol=lf diff=perl
*.py text eol=lf diff=python
*.bat text eol=crlf
*.png binary
CODE_OF_CONDUCT.md -whitespace
/Documentation/**/*.adoc text eol=lf whitespace=trail,space,incomplete
/command-list.txt text eol=lf

View File

@ -834,6 +834,7 @@ TEST_BUILTINS_OBJS += test-hash-speed.o
TEST_BUILTINS_OBJS += test-hash.o
TEST_BUILTINS_OBJS += test-hashmap.o
TEST_BUILTINS_OBJS += test-hexdump.o
TEST_BUILTINS_OBJS += test-iconv.o
TEST_BUILTINS_OBJS += test-json-writer.o
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
TEST_BUILTINS_OBJS += test-match-trees.o

View File

@ -12,6 +12,7 @@
#include "repository.h"
#include "run-command.h"
#include "strbuf.h"
#include "string-list.h"
#include "symlinks.h"
#include "trace2.h"
#include "win32.h"
@ -1842,6 +1843,65 @@ static char *lookup_prog(const char *dir, int dirlen, const char *cmd,
return NULL;
}
static char *path_lookup(const char *cmd, int exe_only);
static char *is_busybox_applet(const char *cmd)
{
static struct string_list applets = STRING_LIST_INIT_DUP;
static char *busybox_path;
static int busybox_path_initialized;
/* Avoid infinite loop */
if (!strncasecmp(cmd, "busybox", 7) &&
(!cmd[7] || !strcasecmp(cmd + 7, ".exe")))
return NULL;
if (!busybox_path_initialized) {
busybox_path = path_lookup("busybox.exe", 1);
busybox_path_initialized = 1;
}
/* Assume that sh is compiled in... */
if (!busybox_path || !strcasecmp(cmd, "sh"))
return xstrdup_or_null(busybox_path);
if (!applets.nr) {
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf buf = STRBUF_INIT;
char *p;
strvec_pushl(&cp.args, busybox_path, "--help", NULL);
if (capture_command(&cp, &buf, 2048)) {
string_list_append(&applets, "");
return NULL;
}
/* parse output */
p = strstr(buf.buf, "Currently defined functions:\n");
if (!p) {
warning("Could not parse output of busybox --help");
string_list_append(&applets, "");
return NULL;
}
p = strchrnul(p, '\n');
for (;;) {
size_t len;
p += strspn(p, "\n\t ,");
len = strcspn(p, "\n\t ,");
if (!len)
break;
p[len] = '\0';
string_list_insert(&applets, p);
p = p + len + 1;
}
}
return string_list_has_string(&applets, cmd) ?
xstrdup(busybox_path) : NULL;
}
/*
* Determines the absolute path of cmd using the split path in path.
* If cmd contains a slash or backslash, no lookup is performed.
@ -1870,6 +1930,9 @@ static char *path_lookup(const char *cmd, int exe_only)
path = sep + 1;
}
if (!prog && !isexe)
prog = is_busybox_applet(cmd);
return prog;
}
@ -2073,8 +2136,8 @@ static int is_msys2_sh(const char *cmd)
}
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaenv,
const char *dir,
int prepend_cmd, int fhin, int fhout, int fherr)
const char *dir, const char *prepend_cmd,
int fhin, int fhout, int fherr)
{
STARTUPINFOEXW si;
PROCESS_INFORMATION pi;
@ -2154,9 +2217,9 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
/* concatenate argv, quoting args as we go */
strbuf_init(&args, 0);
if (prepend_cmd) {
char *quoted = (char *)quote_arg(cmd);
char *quoted = (char *)quote_arg(prepend_cmd);
strbuf_addstr(&args, quoted);
if (quoted != cmd)
if (quoted != prepend_cmd)
free(quoted);
}
for (; *argv; argv++) {
@ -2276,7 +2339,8 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
return (pid_t)pi.dwProcessId;
}
static pid_t mingw_spawnv(const char *cmd, const char **argv, int prepend_cmd)
static pid_t mingw_spawnv(const char *cmd, const char **argv,
const char *prepend_cmd)
{
return mingw_spawnve_fd(cmd, argv, NULL, NULL, prepend_cmd, 0, 1, 2);
}
@ -2304,14 +2368,14 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **deltaenv,
pid = -1;
}
else {
pid = mingw_spawnve_fd(iprog, argv, deltaenv, dir, 1,
pid = mingw_spawnve_fd(iprog, argv, deltaenv, dir, interpr,
fhin, fhout, fherr);
free(iprog);
}
argv[0] = argv0;
}
else
pid = mingw_spawnve_fd(prog, argv, deltaenv, dir, 0,
pid = mingw_spawnve_fd(prog, argv, deltaenv, dir, NULL,
fhin, fhout, fherr);
free(prog);
}
@ -2336,7 +2400,7 @@ static int try_shell_exec(const char *cmd, char *const *argv)
argv2[0] = (char *)cmd; /* full path to the script file */
COPY_ARRAY(&argv2[1], &argv[1], argc);
exec_id = trace2_exec(prog, (const char **)argv2);
pid = mingw_spawnv(prog, (const char **)argv2, 1);
pid = mingw_spawnv(prog, (const char **)argv2, interpr);
if (pid >= 0) {
int status;
if (waitpid(pid, &status, 0) < 0)
@ -2360,7 +2424,7 @@ int mingw_execv(const char *cmd, char *const *argv)
int exec_id;
exec_id = trace2_exec(cmd, (const char **)argv);
pid = mingw_spawnv(cmd, (const char **)argv, 0);
pid = mingw_spawnv(cmd, (const char **)argv, NULL);
if (pid < 0) {
trace2_exec_result(exec_id, -1);
return -1;

View File

@ -292,17 +292,30 @@ create_virtual_base() {
# Platform specific tweaks to work around some commands
case $(uname -s) in
*MINGW*)
# Windows has its own (incompatible) sort and find
sort () {
/usr/bin/sort "$@"
}
find () {
/usr/bin/find "$@"
}
# git sees Windows-style pwd
pwd () {
builtin pwd -W
}
if test -x /usr/bin/sort
then
# Windows has its own (incompatible) sort; override
sort () {
/usr/bin/sort "$@"
}
fi
if test -x /usr/bin/find
then
# Windows has its own (incompatible) find; override
find () {
/usr/bin/find "$@"
}
fi
# 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]:*)

View File

@ -29,6 +29,7 @@ test_tool_sources = [
'test-hash.c',
'test-hashmap.c',
'test-hexdump.c',
'test-iconv.c',
'test-json-writer.c',
'test-lazy-init-name-hash.c',
'test-match-trees.c',

47
t/helper/test-iconv.c Normal file
View File

@ -0,0 +1,47 @@
#include "test-tool.h"
#include "git-compat-util.h"
#include "strbuf.h"
#include "gettext.h"
#include "parse-options.h"
#include "utf8.h"
int cmd__iconv(int argc, const char **argv)
{
struct strbuf buf = STRBUF_INIT;
char *from = NULL, *to = NULL, *p;
size_t len;
int ret = 0;
const char * const iconv_usage[] = {
N_("test-helper --iconv [<options>]"),
NULL
};
struct option options[] = {
OPT_STRING('f', "from-code", &from, "encoding", "from"),
OPT_STRING('t', "to-code", &to, "encoding", "to"),
OPT_END()
};
argc = parse_options(argc, argv, NULL, options,
iconv_usage, 0);
if (argc > 1 || !from || !to)
usage_with_options(iconv_usage, options);
if (!argc) {
if (strbuf_read(&buf, 0, 2048) < 0)
die_errno("Could not read from stdin");
} else if (strbuf_read_file(&buf, argv[0], 2048) < 0)
die_errno("Could not read from '%s'", argv[0]);
p = reencode_string_len(buf.buf, buf.len, to, from, &len);
if (!p)
die_errno("Could not reencode");
if (write(1, p, len) < 0)
ret = !!error_errno("Could not write %"PRIuMAX" bytes",
(uintmax_t)len);
strbuf_release(&buf);
free(p);
return ret;
}

View File

@ -39,6 +39,7 @@ static struct test_cmd cmds[] = {
{ "hashmap", cmd__hashmap },
{ "hash-speed", cmd__hash_speed },
{ "hexdump", cmd__hexdump },
{ "iconv", cmd__iconv },
{ "json-writer", cmd__json_writer },
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
{ "match-trees", cmd__match_trees },

View File

@ -32,6 +32,7 @@ int cmd__getcwd(int argc, const char **argv);
int cmd__hashmap(int argc, const char **argv);
int cmd__hash_speed(int argc, const char **argv);
int cmd__hexdump(int argc, const char **argv);
int cmd__iconv(int argc, const char **argv);
int cmd__json_writer(int argc, const char **argv);
int cmd__lazy_init_name_hash(int argc, const char **argv);
int cmd__match_trees(int argc, const char **argv);

View File

@ -4,6 +4,10 @@
. ../../GIT-BUILD-OPTIONS
INTEROP_ROOT=$(pwd)
BUILD_ROOT=$INTEROP_ROOT/build
case "$PATH" in
*\;*) PATH_SEP=\; ;;
*) PATH_SEP=: ;;
esac
build_version () {
if test -z "$1"
@ -57,7 +61,7 @@ wrap_git () {
write_script "$1" <<-EOF
GIT_EXEC_PATH="$2"
export GIT_EXEC_PATH
PATH="$2:\$PATH"
PATH="$2$PATH_SEP\$PATH"
export GIT_EXEC_PATH
exec git "\$@"
EOF
@ -71,7 +75,7 @@ generate_wrappers () {
echo >&2 fatal: test tried to run generic git: $*
exit 1
EOF
PATH=$(pwd)/.bin:$PATH
PATH=$(pwd)/.bin$PATH_SEP$PATH
}
VERSION_A=${GIT_TEST_VERSION_A:-$VERSION_A}

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 275 B

After

Width:  |  Height:  |  Size: 275 B

View File

@ -214,7 +214,7 @@ setup_ext_wrapper () {
cd "$TRASH_DIRECTORY/remote" &&
eval "$*"
EOF
PATH=$TRASH_DIRECTORY:$PATH &&
PATH=$TRASH_DIRECTORY$PATH_SEP$PATH &&
export TRASH_DIRECTORY
'
}

View File

@ -53,7 +53,7 @@ test_expect_success 'looping aliases - deprecated builtins' '
test_expect_success 'run-command formats empty args properly' '
test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw &&
sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual &&
sed -ne "/run_command: git-frotz/s/.*trace: run_command: //p" actual.raw >actual &&
echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
test_cmp expect actual
'

View File

@ -8,7 +8,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh
PATH=$PWD:$PATH
PATH=$PWD$PATH_SEP$PATH
TEST_ROOT="$(pwd)"
write_script <<\EOF "$TEST_ROOT/rot13.sh"

View File

@ -147,25 +147,25 @@ ancestor /foo /fo -1
ancestor /foo /foo -1
ancestor /foo /bar -1
ancestor /foo /foo/bar -1
ancestor /foo /foo:/bar -1
ancestor /foo /:/foo:/bar 0
ancestor /foo /foo:/:/bar 0
ancestor /foo /:/bar:/foo 0
ancestor /foo "/foo$PATH_SEP/bar" -1
ancestor /foo "/$PATH_SEP/foo$PATH_SEP/bar" 0
ancestor /foo "/foo$PATH_SEP/$PATH_SEP/bar" 0
ancestor /foo "/$PATH_SEP/bar$PATH_SEP/foo" 0
ancestor /foo/bar / 0
ancestor /foo/bar /fo -1
ancestor /foo/bar /foo 4
ancestor /foo/bar /foo/ba -1
ancestor /foo/bar /:/fo 0
ancestor /foo/bar /foo:/foo/ba 4
ancestor /foo/bar "/$PATH_SEP/fo" 0
ancestor /foo/bar "/foo$PATH_SEP/foo/ba" 4
ancestor /foo/bar /bar -1
ancestor /foo/bar /fo -1
ancestor /foo/bar /foo:/bar 4
ancestor /foo/bar /:/foo:/bar 4
ancestor /foo/bar /foo:/:/bar 4
ancestor /foo/bar /:/bar:/fo 0
ancestor /foo/bar /:/bar 0
ancestor /foo/bar "/foo$PATH_SEP/bar" 4
ancestor /foo/bar "/$PATH_SEP/foo$PATH_SEP/bar" 4
ancestor /foo/bar "/foo$PATH_SEP/$PATH_SEP/bar" 4
ancestor /foo/bar "/$PATH_SEP/bar$PATH_SEP/fo" 0
ancestor /foo/bar "/$PATH_SEP/bar" 0
ancestor /foo/bar /foo 4
ancestor /foo/bar /foo:/bar 4
ancestor /foo/bar "/foo$PATH_SEP/bar" 4
ancestor /foo/bar /bar -1
# Windows-specific: DOS drives, network shares

View File

@ -69,7 +69,7 @@ test_expect_success 'run_command does not try to execute a directory' '
cat bin2/greet
EOF
PATH=$PWD/bin1:$PWD/bin2:$PATH \
PATH=$PWD/bin1$PATH_SEP$PWD/bin2$PATH_SEP$PATH \
test-tool run-command run-command greet >actual 2>err &&
test_cmp bin2/greet actual &&
test_must_be_empty err
@ -86,7 +86,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' '
cat bin2/greet
EOF
PATH=$PWD/bin1:$PWD/bin2:$PATH \
PATH=$PWD/bin1$PATH_SEP$PWD/bin2$PATH_SEP$PATH \
test-tool run-command run-command greet >actual 2>err &&
test_cmp bin2/greet actual &&
test_must_be_empty err
@ -106,7 +106,7 @@ test_expect_success POSIXPERM,SANITY 'unreadable directory in PATH' '
git config alias.nitfol "!echo frotz" &&
chmod a-rx local-command &&
(
PATH=./local-command:$PATH &&
PATH=./local-command$PATH_SEP$PATH &&
git nitfol >actual
) &&
echo frotz >expect &&

View File

@ -80,7 +80,7 @@ test_expect_success 'setup helper scripts' '
printf "username=\\007latrix Lestrange\\n"
EOF
PATH="$PWD:$PATH"
PATH="$PWD$PATH_SEP$PATH"
'
test_expect_success 'credential_fill invokes helper' '

View File

@ -84,9 +84,9 @@ then
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
test_fail subdir_ceil_at_top_slash
GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
GIT_CEILING_DIRECTORIES="$PATH_SEP$TRASH_ROOT/top"
test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
GIT_CEILING_DIRECTORIES="$PATH_SEP$TRASH_ROOT/top/"
test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
fi
@ -116,13 +116,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
GIT_CEILING_DIRECTORIES="/foo$PATH_SEP$TRASH_ROOT/sub"
test_fail second_of_two
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub$PATH_SEP/bar"
test_fail first_of_two
GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
GIT_CEILING_DIRECTORIES="/foo$PATH_SEP$TRASH_ROOT/sub$PATH_SEP/bar"
test_fail second_of_three

View File

@ -16,7 +16,7 @@ test_cd_to_toplevel () {
test_expect_success $3 "$2" '
(
cd '"'$1'"' &&
PATH="$EXEC_PATH:$PATH" &&
PATH="$EXEC_PATH$PATH_SEP$PATH" &&
. git-sh-setup &&
cd_to_toplevel &&
[ "$(pwd -P)" = "$TOPLEVEL" ]

View File

@ -26,7 +26,7 @@ test_expect_success 'example 1: notes to add an Acked-by line' '
'
test_expect_success 'example 2: binary notes' '
cp "$TEST_DIRECTORY"/test-binary-1.png . &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png . &&
git checkout B &&
blob=$(git hash-object -w test-binary-1.png) &&
git notes --ref=logo add -C "$blob" &&

View File

@ -82,7 +82,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
rm -f actual &&
(
PATH=./test-bin:$PATH &&
PATH=./test-bin$PATH_SEP$PATH &&
test_must_fail git rebase -s funny -X"option=arg with space" \
-Xop\"tion\\ -X"new${LF}line " main topic
) &&
@ -91,7 +91,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
echo "Resolved" >F2 &&
git add F2 &&
(
PATH=./test-bin:$PATH &&
PATH=./test-bin$PATH_SEP$PATH &&
git rebase --continue
) &&
test_cmp expect actual

View File

@ -1377,7 +1377,7 @@ test_expect_success 'stash -- <subdir> works with binary files' '
mkdir -p subdir &&
>subdir/untracked &&
>subdir/tracked &&
cp "$TEST_DIRECTORY"/test-binary-1.png subdir/tracked-binary &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png subdir/tracked-binary &&
git add subdir/tracked* &&
git stash -- subdir/ &&
test_path_is_missing subdir/tracked &&

View File

@ -19,7 +19,7 @@ test_expect_success 'prepare repository' '
echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d &&
git update-index --add a b c d &&
echo git >a &&
cat "$TEST_DIRECTORY"/test-binary-1.png >b &&
cat "$TEST_DIRECTORY"/lib-diff/test-binary-1.png >b &&
echo git >c &&
cat b b >d
'

View File

@ -33,7 +33,7 @@ test_expect_success 'binary changes do not count in lines' '
git reset --hard &&
echo a >a &&
echo c >c &&
cat "$TEST_DIRECTORY"/test-binary-1.png >d &&
cat "$TEST_DIRECTORY"/lib-diff/test-binary-1.png >d &&
cat >expect <<-\EOF &&
a | 1 +
c | 1 +

View File

@ -272,11 +272,11 @@ test_expect_success 'apply with --3way --cached and conflicts' '
test_expect_success 'apply binary file patch' '
git reset --hard main &&
cp "$TEST_DIRECTORY/test-binary-1.png" bin.png &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-1.png" bin.png &&
git add bin.png &&
git commit -m "add binary file" &&
cp "$TEST_DIRECTORY/test-binary-2.png" bin.png &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-2.png" bin.png &&
git diff --binary >bin.diff &&
git reset --hard &&
@ -287,11 +287,11 @@ test_expect_success 'apply binary file patch' '
test_expect_success 'apply binary file patch with 3way' '
git reset --hard main &&
cp "$TEST_DIRECTORY/test-binary-1.png" bin.png &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-1.png" bin.png &&
git add bin.png &&
git commit -m "add binary file" &&
cp "$TEST_DIRECTORY/test-binary-2.png" bin.png &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-2.png" bin.png &&
git diff --binary >bin.diff &&
git reset --hard &&
@ -302,11 +302,11 @@ test_expect_success 'apply binary file patch with 3way' '
test_expect_success 'apply full-index patch with 3way' '
git reset --hard main &&
cp "$TEST_DIRECTORY/test-binary-1.png" bin.png &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-1.png" bin.png &&
git add bin.png &&
git commit -m "add binary file" &&
cp "$TEST_DIRECTORY/test-binary-2.png" bin.png &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-2.png" bin.png &&
git diff --full-index >bin.diff &&
git reset --hard &&

View File

@ -88,7 +88,7 @@ test_expect_success \
'mkdir a &&
echo simple textfile >a/a &&
mkdir a/bin &&
cp /bin/sh a/bin &&
cp "$TEST_DIRECTORY/lib-diff/test-binary-1.png" a/bin &&
printf "text\r" >a/text.cr &&
printf "text\r\n" >a/text.crlf &&
printf "text\n" >a/text.lf &&

View File

@ -32,7 +32,7 @@ test_expect_success 'setup proxy script' '
write_script proxy <<-\EOF
echo >&2 "proxying for $*"
cmd=$(./proxy-get-cmd)
cmd=$("$PERL_PATH" ./proxy-get-cmd)
echo >&2 "Running $cmd"
exec $cmd
EOF

View File

@ -11,6 +11,21 @@ repo_is_hardlinked() {
test_line_count = 0 output
}
if test_have_prereq MINGW,BUSYBOX
then
# BusyBox' `find` does not support `-links`. Besides, BusyBox-w32's
# lstat() does not report hard links, just like Git's mingw_lstat()
# (from where BusyBox-w32 got its initial implementation).
repo_is_hardlinked() {
for f in $(find "$1/objects" -type f)
do
"$SYSTEMROOT"/system32/fsutil.exe \
hardlink list $f >links &&
test_line_count -gt 1 links || return 1
done
}
fi
test_expect_success 'preparing origin repository' '
: >file && git add . && git commit -m1 &&
git clone --bare . a.git &&

View File

@ -39,7 +39,7 @@ test_expect_success 'access alternate via absolute path' '
'
test_expect_success 'access multiple alternates' '
check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF
check_obj "$PWD/one.git/objects$PATH_SEP$PWD/two.git/objects" <<-EOF
$one blob
$two blob
EOF
@ -75,7 +75,7 @@ test_expect_success 'access alternate via relative path (subdir)' '
quoted='"one.git\057objects"'
unquoted='two.git/objects'
test_expect_success 'mix of quoted and unquoted alternates' '
check_obj "$quoted:$unquoted" <<-EOF
check_obj "$quoted$PATH_SEP$unquoted" <<-EOF
$one blob
$two blob
EOF

View File

@ -86,7 +86,7 @@ test_expect_success 'set up fake git-daemon' '
"$TRASH_DIRECTORY/remote"
EOF
export TRASH_DIRECTORY &&
PATH=$TRASH_DIRECTORY:$PATH
PATH=$TRASH_DIRECTORY$PATH_SEP$PATH
'
test_expect_success 'ext command can connect to git daemon (no vhost)' '

View File

@ -15,8 +15,23 @@ test_expect_success 'setup repository to clone' '
'
test_proto "host:path" ssh "remote:repo.git"
test_proto "ssh://" ssh "ssh://remote$PWD/remote/repo.git"
test_proto "git+ssh://" ssh "git+ssh://remote$PWD/remote/repo.git"
hostdir="$PWD"
if test_have_prereq MINGW && test "/${PWD#/}" != "$PWD"
then
case "$PWD" in
[A-Za-z]:/*)
hostdir="${PWD#?:}"
;;
*)
skip_all="Unhandled PWD '$PWD'; skipping rest"
test_done
;;
esac
fi
test_proto "ssh://" ssh "ssh://remote$hostdir/remote/repo.git"
test_proto "git+ssh://" ssh "git+ssh://remote$hostdir/remote/repo.git"
# Don't even bother setting up a "-remote" directory, as ssh would generally
# complain about the bogus option rather than completing our request. Our

View File

@ -355,12 +355,12 @@ test_expect_success "expected conflict markers" '
test_expect_success 'binary files cannot be merged' '
test_must_fail git merge-file -p \
orig.txt "$TEST_DIRECTORY"/test-binary-1.png new1.txt 2> merge.err &&
orig.txt "$TEST_DIRECTORY"/lib-diff/test-binary-1.png new1.txt 2> merge.err &&
grep "Cannot merge binary files" merge.err
'
test_expect_success 'binary files cannot be merged with --object-id' '
cp "$TEST_DIRECTORY"/test-binary-1.png . &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png . &&
git add orig.txt new1.txt test-binary-1.png &&
test_must_fail git merge-file --object-id \
:orig.txt :test-binary-1.png :new1.txt 2> merge.err &&

View File

@ -9,7 +9,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
test_expect_success setup '
cat "$TEST_DIRECTORY"/test-binary-1.png >m &&
cat "$TEST_DIRECTORY"/lib-diff/test-binary-1.png >m &&
git add m &&
git ls-files -s | sed -e "s/ 0 / 1 /" >E1 &&
test_tick &&

View File

@ -54,7 +54,7 @@ test_expect_success !MINGW,TTY 'LESS and LV envvars set by git-sh-setup' '
sane_unset LESS LV &&
PAGER="env >pager-env.out; wc" &&
export PAGER &&
PATH="$(git --exec-path):$PATH" &&
PATH="$(git --exec-path)$PATH_SEP$PATH" &&
export PATH &&
test_terminal sh -c ". git-sh-setup && git_pager"
) &&
@ -388,7 +388,7 @@ test_default_pager() {
EOF
chmod +x \$less &&
(
PATH=.:\$PATH &&
PATH=.$PATH_SEP\$PATH &&
export PATH &&
$full_command
) &&

View File

@ -23,7 +23,7 @@ test_expect_success 'set up custom strategy' '
EOF
chmod +x git-merge-theirs &&
PATH=.:$PATH &&
PATH=.$PATH_SEP$PATH &&
export PATH
'

View File

@ -52,7 +52,7 @@ test_expect_success SIMPLEPAGER 'git grep -O' '
EOF
echo grep.h >expect.notless &&
PATH=.:$PATH git grep -O GREP_PATTERN >out &&
PATH=.$PATH_SEP$PATH git grep -O GREP_PATTERN >out &&
{
test_cmp expect.less pager-args ||
test_cmp expect.notless pager-args

View File

@ -13,7 +13,7 @@ test_expect_success 'setup' '
echo distimdistim was called
EOF
PATH="$PATH:." &&
PATH="$PATH$PATH_SEP." &&
export PATH &&
git commit --allow-empty -m "a single log entry" &&

View File

@ -11,6 +11,13 @@ if ! test_have_prereq PERL; then
test_done
fi
case "$PWD" in
*:*)
skip_all='cvs would get confused by the colon in `pwd`; skipping tests'
test_done
;;
esac
cvs >/dev/null 2>&1
if test $? -ne 1
then
@ -54,8 +61,8 @@ test_expect_success 'New file' '
mkdir A B C D E F &&
echo hello1 >A/newfile1.txt &&
echo hello2 >B/newfile2.txt &&
cp "$TEST_DIRECTORY"/test-binary-1.png C/newfile3.png &&
cp "$TEST_DIRECTORY"/test-binary-1.png D/newfile4.png &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png C/newfile3.png &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png D/newfile4.png &&
git add A/newfile1.txt &&
git add B/newfile2.txt &&
git add C/newfile3.png &&
@ -80,8 +87,8 @@ test_expect_success 'Remove two files, add two and update two' '
rm -f B/newfile2.txt &&
rm -f C/newfile3.png &&
echo Hello5 >E/newfile5.txt &&
cp "$TEST_DIRECTORY"/test-binary-2.png D/newfile4.png &&
cp "$TEST_DIRECTORY"/test-binary-1.png F/newfile6.png &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-2.png D/newfile4.png &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png F/newfile6.png &&
git add E/newfile5.txt &&
git add F/newfile6.png &&
git commit -a -m "Test: Remove, add and update" &&
@ -169,7 +176,7 @@ test_expect_success 'New file with spaces in file name' '
mkdir "G g" &&
echo ok then >"G g/with spaces.txt" &&
git add "G g/with spaces.txt" && \
cp "$TEST_DIRECTORY"/test-binary-1.png "G g/with spaces.png" && \
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png "G g/with spaces.png" && \
git add "G g/with spaces.png" &&
git commit -a -m "With spaces" &&
id=$(git rev-list --max-count=1 HEAD) &&
@ -181,7 +188,7 @@ test_expect_success 'New file with spaces in file name' '
test_expect_success 'Update file with spaces in file name' '
echo Ok then >>"G g/with spaces.txt" &&
cat "$TEST_DIRECTORY"/test-binary-1.png >>"G g/with spaces.png" && \
cat "$TEST_DIRECTORY"/lib-diff/test-binary-1.png >>"G g/with spaces.png" && \
git add "G g/with spaces.png" &&
git commit -a -m "Update with spaces" &&
id=$(git rev-list --max-count=1 HEAD) &&
@ -206,7 +213,7 @@ test_expect_success !MINGW 'File with non-ascii file name' '
mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
cp "$TEST_DIRECTORY"/test-binary-1.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
cp "$TEST_DIRECTORY"/lib-diff/test-binary-1.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
git commit -a -m "Går det så går det" && \
id=$(git rev-list --max-count=1 HEAD) &&

View File

@ -286,7 +286,7 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '
EOF
chmod 755 badp4dir/p4 &&
(
PATH="$TRASH_DIRECTORY/badp4dir:$PATH" &&
PATH="$TRASH_DIRECTORY/badp4dir$PATH_SEP$PATH" &&
export PATH &&
test_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1
) &&

View File

@ -139,12 +139,7 @@ invalid_variable_name='${foo.bar}'
actual="$TRASH_DIRECTORY/actual"
if test_have_prereq MINGW
then
ROOT="$(pwd -W)"
else
ROOT="$(pwd)"
fi
ROOT="$(pwd)"
test_expect_success 'setup for __git_find_repo_path/__gitdir tests' '
mkdir -p subdir/subsubdir &&

View File

@ -15,6 +15,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/ .
# On Unix/Linux, the path separator is the colon, on other systems it
# may be different, though. On Windows, for example, it is a semicolon.
# If the PATH variable contains semicolons, it is pretty safe to assume
# that the path separator is a semicolon.
case "$PATH" in
*\;*) PATH_SEP=\; ;;
*) PATH_SEP=: ;;
esac
# Test the binaries we have just built. The tests are kept in
# t/ subdirectory and are run in 'trash directory' subdirectory.
if test -z "$TEST_DIRECTORY"
@ -1392,7 +1401,7 @@ then
done
done
IFS=$OLDIFS
PATH=$GIT_VALGRIND/bin:$PATH
PATH=$GIT_VALGRIND/bin$PATH_SEP$PATH
GIT_EXEC_PATH=$GIT_VALGRIND/bin
export GIT_VALGRIND
GIT_VALGRIND_MODE="$valgrind"
@ -1404,7 +1413,7 @@ elif test -n "$GIT_TEST_INSTALLED"
then
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
error "Cannot run git from $GIT_TEST_INSTALLED."
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR/t/helper:$PATH
PATH=$GIT_TEST_INSTALLED$PATH_SEP$GIT_BUILD_DIR/t/helper$PATH_SEP$PATH
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
else # normal case, use ../bin-wrappers only unless $with_dashes:
if test -n "$no_bin_wrappers"
@ -1420,12 +1429,12 @@ else # normal case, use ../bin-wrappers only unless $with_dashes:
fi
with_dashes=t
fi
PATH="$git_bin_dir:$PATH"
PATH="$git_bin_dir$PATH_SEP$PATH"
fi
GIT_EXEC_PATH=$GIT_BUILD_DIR
if test -n "$with_dashes"
then
PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH"
PATH="$GIT_BUILD_DIR$PATH_SEP$GIT_BUILD_DIR/t/helper$PATH_SEP$PATH"
fi
fi
GIT_TEMPLATE_DIR="$GIT_TEST_TEMPLATE_DIR"
@ -1662,17 +1671,30 @@ Darwin)
test_set_prereq EXECKEEPSPID
;;
*MINGW*)
# Windows has its own (incompatible) sort and find
sort () {
/usr/bin/sort "$@"
}
find () {
/usr/bin/find "$@"
}
# git sees Windows-style pwd
pwd () {
builtin pwd -W
}
if test -x /usr/bin/sort
then
# Windows has its own (incompatible) sort; override
sort () {
/usr/bin/sort "$@"
}
fi
if test -x /usr/bin/find
then
# Windows has its own (incompatible) find; override
find () {
/usr/bin/find "$@"
}
fi
# 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
@ -1682,6 +1704,12 @@ Darwin)
test_set_prereq GREP_STRIPS_CR
test_set_prereq WINDOWS
GIT_TEST_CMP="GIT_DIR=/dev/null git diff --no-index --ignore-cr-at-eol --"
if ! type iconv >/dev/null 2>&1
then
iconv () {
test-tool iconv "$@"
}
fi
;;
*CYGWIN*)
test_set_prereq POSIXPERM
@ -1851,6 +1879,10 @@ test_lazy_prereq UNZIP '
test $? -ne 127
'
test_lazy_prereq BUSYBOX '
case "$($SHELL --help 2>&1)" in *BusyBox*) true;; *) false;; esac
'
run_with_limited_cmdline () {
(ulimit -s 128 && "$@")
}