summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/helper/test-hashmap.c19
-rw-r--r--t/lib-proto-disable.sh8
-rwxr-xr-xt/t0060-path-utils.sh2
-rwxr-xr-xt/t1300-repo-config.sh7
-rwxr-xr-xt/t5532-fetch-proxy.sh5
-rwxr-xr-xt/t5572-pull-submodule.sh58
-rwxr-xr-xt/t5810-proto-disable-local.sh23
-rwxr-xr-xt/t5813-proto-disable-ssh.sh23
-rwxr-xr-xt/t6500-gc.sh21
-rwxr-xr-xt/t9831-git-p4-triggers.sh103
-rw-r--r--t/test-lib-functions.sh1
-rw-r--r--t/test-lib.sh11
12 files changed, 269 insertions, 12 deletions
diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c
index 7aa9440e27..095d7395f3 100644
--- a/t/helper/test-hashmap.c
+++ b/t/helper/test-hashmap.c
@@ -13,14 +13,18 @@ static const char *get_value(const struct test_entry *e)
return e->key + strlen(e->key) + 1;
}
-static int test_entry_cmp(const struct test_entry *e1,
- const struct test_entry *e2, const char* key)
+static int test_entry_cmp(const void *unused_cmp_data,
+ const struct test_entry *e1,
+ const struct test_entry *e2,
+ const char* key)
{
return strcmp(e1->key, key ? key : e2->key);
}
-static int test_entry_cmp_icase(const struct test_entry *e1,
- const struct test_entry *e2, const char* key)
+static int test_entry_cmp_icase(const void *unused_cmp_data,
+ const struct test_entry *e1,
+ const struct test_entry *e2,
+ const char* key)
{
return strcasecmp(e1->key, key ? key : e2->key);
}
@@ -92,7 +96,8 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
if (method & TEST_ADD) {
/* test adding to the map */
for (j = 0; j < rounds; j++) {
- hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, 0);
+ hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp,
+ NULL, 0);
/* add entries */
for (i = 0; i < TEST_SIZE; i++) {
@@ -104,7 +109,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
}
} else {
/* test map lookups */
- hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, 0);
+ hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, NULL, 0);
/* fill the map (sparsely if specified) */
j = (method & TEST_SPARSE) ? TEST_SIZE / 10 : TEST_SIZE;
@@ -147,7 +152,7 @@ int cmd_main(int argc, const char **argv)
/* init hash map */
icase = argc > 1 && !strcmp("ignorecase", argv[1]);
hashmap_init(&map, (hashmap_cmp_fn) (icase ? test_entry_cmp_icase
- : test_entry_cmp), 0);
+ : test_entry_cmp), NULL, 0);
/* process commands from stdin */
while (fgets(line, sizeof(line), stdin)) {
diff --git a/t/lib-proto-disable.sh b/t/lib-proto-disable.sh
index 02f49cb409..83babe57d9 100644
--- a/t/lib-proto-disable.sh
+++ b/t/lib-proto-disable.sh
@@ -147,29 +147,33 @@ test_config () {
# Test clone/fetch/push with protocol.allow user defined default
test_expect_success "clone $desc (enabled)" '
rm -rf tmp.git &&
- git config --global protocol.allow always &&
+ test_config_global protocol.allow always &&
git clone --bare "$url" tmp.git
'
test_expect_success "fetch $desc (enabled)" '
+ test_config_global protocol.allow always &&
git -C tmp.git fetch
'
test_expect_success "push $desc (enabled)" '
+ test_config_global protocol.allow always &&
git -C tmp.git push origin HEAD:pushed
'
test_expect_success "push $desc (disabled)" '
- git config --global protocol.allow never &&
+ test_config_global protocol.allow never &&
test_must_fail git -C tmp.git push origin HEAD:pushed
'
test_expect_success "fetch $desc (disabled)" '
+ test_config_global protocol.allow never &&
test_must_fail git -C tmp.git fetch
'
test_expect_success "clone $desc (disabled)" '
rm -rf tmp.git &&
+ test_config_global protocol.allow never &&
test_must_fail git clone --bare "$url" tmp.git
'
}
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 444b5a4df8..7ea2bb515b 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -70,6 +70,8 @@ ancestor() {
case $(uname -s) in
*MINGW*)
;;
+*CYGWIN*)
+ ;;
*)
test_set_prereq POSIX
;;
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index a37ef04222..364a537000 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -1075,6 +1075,13 @@ test_expect_success 'git -c works with aliases of builtins' '
test_cmp expect actual
'
+test_expect_success 'aliases can be CamelCased' '
+ test_config alias.CamelCased "rev-parse HEAD" &&
+ git CamelCased >out &&
+ git rev-parse HEAD >expect &&
+ test_cmp expect out
+'
+
test_expect_success 'git -c does not split values on equals' '
echo "value with = in it" >expect &&
git -c core.foo="value with = in it" config core.foo >actual &&
diff --git a/t/t5532-fetch-proxy.sh b/t/t5532-fetch-proxy.sh
index 51c9669398..9c2798603b 100755
--- a/t/t5532-fetch-proxy.sh
+++ b/t/t5532-fetch-proxy.sh
@@ -43,4 +43,9 @@ test_expect_success 'fetch through proxy works' '
test_cmp expect actual
'
+test_expect_success 'funny hostnames are rejected before running proxy' '
+ test_must_fail git fetch git://-remote/repo.git 2>stderr &&
+ ! grep "proxying for" stderr
+'
+
test_done
diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh
index accfa5cc0c..077eb07e11 100755
--- a/t/t5572-pull-submodule.sh
+++ b/t/t5572-pull-submodule.sh
@@ -42,4 +42,62 @@ KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
test_submodule_switch "git_pull_noff"
+test_expect_success 'pull --recurse-submodule setup' '
+ test_create_repo child &&
+ test_commit -C child bar &&
+
+ test_create_repo parent &&
+ test_commit -C child foo &&
+
+ git -C parent submodule add ../child sub &&
+ git -C parent commit -m "add submodule" &&
+
+ git clone --recurse-submodules parent super
+'
+
+test_expect_success 'recursive pull updates working tree' '
+ test_commit -C child merge_strategy &&
+ git -C parent submodule update --remote &&
+ git -C parent add sub &&
+ git -C parent commit -m "update submodule" &&
+
+ git -C super pull --no-rebase --recurse-submodules &&
+ test_path_is_file super/sub/merge_strategy.t
+'
+
+test_expect_success 'recursive rebasing pull' '
+ # change upstream
+ test_commit -C child rebase_strategy &&
+ git -C parent submodule update --remote &&
+ git -C parent add sub &&
+ git -C parent commit -m "update submodule" &&
+
+ # also have local commits
+ test_commit -C super/sub local_stuff &&
+
+ git -C super pull --rebase --recurse-submodules &&
+ test_path_is_file super/sub/rebase_strategy.t &&
+ test_path_is_file super/sub/local_stuff.t
+'
+
+test_expect_success 'pull rebase recursing fails with conflicts' '
+
+ # local changes in submodule recorded in superproject:
+ test_commit -C super/sub local_stuff_2 &&
+ git -C super add sub &&
+ git -C super commit -m "local update submodule" &&
+
+ # and in the remote as well:
+ test_commit -C child important_upstream_work &&
+ git -C parent submodule update --remote &&
+ git -C parent add sub &&
+ git -C parent commit -m "remote update submodule" &&
+
+ # Unfortunately we fail here, despite no conflict in the
+ # submodule itself, but the merge strategy in submodules
+ # does not support rebase:
+ test_must_fail git -C super pull --rebase --recurse-submodules 2>err &&
+ test_i18ngrep "locally recorded submodule modifications" err
+'
+
test_done
diff --git a/t/t5810-proto-disable-local.sh b/t/t5810-proto-disable-local.sh
index 563592d8a8..c1ef99b85c 100755
--- a/t/t5810-proto-disable-local.sh
+++ b/t/t5810-proto-disable-local.sh
@@ -11,4 +11,27 @@ test_expect_success 'setup repository to clone' '
test_proto "file://" file "file://$PWD"
test_proto "path" file .
+test_expect_success 'setup repo with dash' '
+ git init --bare repo.git &&
+ git push repo.git HEAD &&
+ mv repo.git "$PWD/-repo.git"
+'
+
+# This will fail even without our rejection because upload-pack will
+# complain about the bogus option. So let's make sure that GIT_TRACE
+# doesn't show us even running upload-pack.
+#
+# We must also be sure to use "fetch" and not "clone" here, as the latter
+# actually canonicalizes our input into an absolute path (which is fine
+# to allow).
+test_expect_success 'repo names starting with dash are rejected' '
+ rm -f trace.out &&
+ test_must_fail env GIT_TRACE="$PWD/trace.out" git fetch -- -repo.git &&
+ ! grep upload-pack trace.out
+'
+
+test_expect_success 'full paths still work' '
+ git fetch "$PWD/-repo.git"
+'
+
test_done
diff --git a/t/t5813-proto-disable-ssh.sh b/t/t5813-proto-disable-ssh.sh
index a954ead8af..3f084ee306 100755
--- a/t/t5813-proto-disable-ssh.sh
+++ b/t/t5813-proto-disable-ssh.sh
@@ -17,4 +17,27 @@ 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"
+# Don't even bother setting up a "-remote" directory, as ssh would generally
+# complain about the bogus option rather than completing our request. Our
+# fake wrapper actually _can_ handle this case, but it's more robust to
+# simply confirm from its output that it did not run at all.
+test_expect_success 'hostnames starting with dash are rejected' '
+ test_must_fail git clone ssh://-remote/repo.git dash-host 2>stderr &&
+ ! grep ^ssh: stderr
+'
+
+test_expect_success 'setup repo with dash' '
+ git init --bare remote/-repo.git &&
+ git push remote/-repo.git HEAD
+'
+
+test_expect_success 'repo names starting with dash are rejected' '
+ test_must_fail git clone remote:-repo.git dash-path 2>stderr &&
+ ! grep ^ssh: stderr
+'
+
+test_expect_success 'full paths still work' '
+ git clone "remote:$PWD/remote/-repo.git" dash-path
+'
+
test_done
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index cc7acd101d..41b0be575d 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -95,6 +95,27 @@ test_expect_success 'background auto gc does not run if gc.log is present and re
test_line_count = 1 packs
'
+test_expect_success 'background auto gc respects lock for all operations' '
+ # make sure we run a background auto-gc
+ test_commit make-pack &&
+ git repack &&
+ test_config gc.autopacklimit 1 &&
+ test_config gc.autodetach true &&
+
+ # create a ref whose loose presence we can use to detect a pack-refs run
+ git update-ref refs/heads/should-be-loose HEAD &&
+ test_path_is_file .git/refs/heads/should-be-loose &&
+
+ # now fake a concurrent gc that holds the lock; we can use our
+ # shell pid so that it looks valid.
+ hostname=$(hostname || echo unknown) &&
+ printf "$$ %s" "$hostname" >.git/gc.pid &&
+
+ # our gc should exit zero without doing anything
+ run_and_wait_for_auto_gc &&
+ test_path_is_file .git/refs/heads/should-be-loose
+'
+
# DO NOT leave a detached auto gc process running near the end of the
# test script: it can run long enough in the background to racily
# interfere with the cleanup in 'test_done'.
diff --git a/t/t9831-git-p4-triggers.sh b/t/t9831-git-p4-triggers.sh
new file mode 100755
index 0000000000..bbcf14c664
--- /dev/null
+++ b/t/t9831-git-p4-triggers.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+test_description='git p4 with server triggers'
+
+. ./lib-git-p4.sh
+
+test_expect_success 'start p4d' '
+ start_p4d
+'
+
+test_expect_success 'init depot' '
+ (
+ cd "$cli" &&
+ echo file1 >file1 &&
+ p4 add file1 &&
+ p4 submit -d "change 1"
+ echo file2 >file2 &&
+ p4 add file2 &&
+ p4 submit -d "change 2"
+ )
+'
+
+test_expect_success 'clone with extra info lines from verbose p4 trigger' '
+ test_when_finished cleanup_git &&
+ (
+ p4 triggers -i <<-EOF
+ Triggers: p4triggertest-command command pre-user-change "echo verbose trigger"
+ EOF
+ ) &&
+ (
+ p4 change -o | grep -s "verbose trigger"
+ ) &&
+ git p4 clone --dest="$git" //depot/@all &&
+ (
+ p4 triggers -i <<-EOF
+ Triggers:
+ EOF
+ )
+'
+
+test_expect_success 'import with extra info lines from verbose p4 trigger' '
+ test_when_finished cleanup_git &&
+ (
+ cd "$cli" &&
+ echo file3 >file3 &&
+ p4 add file3 &&
+ p4 submit -d "change 3"
+ ) &&
+ (
+ p4 triggers -i <<-EOF
+ Triggers: p4triggertest-command command pre-user-describe "echo verbose trigger"
+ EOF
+ ) &&
+ (
+ p4 describe 1 | grep -s "verbose trigger"
+ ) &&
+ git p4 clone --dest="$git" //depot/@all &&
+ (
+ cd "$git" &&
+ git p4 sync
+ )&&
+ (
+ p4 triggers -i <<-EOF
+ Triggers:
+ EOF
+ )
+'
+
+test_expect_success 'submit description with extra info lines from verbose p4 change trigger' '
+ test_when_finished cleanup_git &&
+ (
+ p4 triggers -i <<-EOF
+ Triggers: p4triggertest-command command pre-user-change "echo verbose trigger"
+ EOF
+ ) &&
+ (
+ p4 change -o | grep -s "verbose trigger"
+ ) &&
+ git p4 clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ git config git-p4.skipSubmitEdit true &&
+ echo file4 >file4 &&
+ git add file4 &&
+ git commit -m file4 &&
+ git p4 submit
+ ) &&
+ (
+ p4 triggers -i <<-EOF
+ Triggers:
+ EOF
+ ) &&
+ (
+ cd "$cli" &&
+ test_path_is_file file4
+ )
+'
+
+test_expect_success 'kill p4d' '
+ kill_p4d
+'
+
+test_done
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index e09e93b38f..1701fe2a06 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1000,6 +1000,7 @@ test_copy_bytes () {
my $s;
my $nread = sysread(STDIN, $s, $len);
die "cannot read: $!" unless defined($nread);
+ last unless $nread;
print $s;
$len -= $nread;
}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 2306574dc9..1b6e53f78a 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -36,6 +36,14 @@ then
fi
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+# If we were built with ASAN, it may complain about leaks
+# of program-lifetime variables. Disable it by default to lower
+# the noise level. This needs to happen at the start of the script,
+# before we even do our "did we build git yet" check (since we don't
+# want that one to complain to stderr).
+: ${ASAN_OPTIONS=detect_leaks=0:abort_on_error=1}
+export ASAN_OPTIONS
+
################################################################
# It appears that people try to run tests without building...
"$GIT_BUILD_DIR/git" >/dev/null
@@ -148,9 +156,6 @@ else
}
fi
-: ${ASAN_OPTIONS=detect_leaks=0}
-export ASAN_OPTIONS
-
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
unset CDPATH