summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/README13
-rw-r--r--t/helper/test-advise.c22
-rw-r--r--t/helper/test-dump-split-index.c2
-rw-r--r--t/helper/test-oid-array.c (renamed from t/helper/test-sha1-array.c)8
-rw-r--r--t/helper/test-path-utils.c5
-rw-r--r--t/helper/test-repository.c14
-rw-r--r--t/helper/test-tool.c4
-rw-r--r--t/helper/test-tool.h3
-rw-r--r--[-rwxr-xr-x]t/lib-credential.sh5
-rw-r--r--[-rwxr-xr-x]t/lib-gpg.sh110
-rw-r--r--[-rwxr-xr-x]t/lib-log-graph.sh0
-rw-r--r--[-rwxr-xr-x]t/lib-submodule-update.sh68
-rwxr-xr-xt/perf/p5310-pack-bitmaps.sh4
-rwxr-xr-xt/t0000-basic.sh13
-rwxr-xr-xt/t0007-git-var.sh2
-rwxr-xr-xt/t0018-advice.sh32
-rwxr-xr-xt/t0021-conversion.sh198
-rw-r--r--t/t0021/rot13-filter.pl6
-rwxr-xr-xt/t0064-sha1-array.sh16
-rwxr-xr-xt/t0212-trace2-event.sh37
-rwxr-xr-xt/t0300-credentials.sh151
-rwxr-xr-xt/t1450-fsck.sh24
-rwxr-xr-xt/t2402-worktree-list.sh2
-rwxr-xr-xt/t3403-rebase-skip.sh79
-rwxr-xr-xt/t3404-rebase-interactive.sh64
-rwxr-xr-xt/t3406-rebase-message.sh16
-rwxr-xr-xt/t3417-rebase-whitespace-fix.sh4
-rwxr-xr-xt/t3419-rebase-patch-id.sh114
-rwxr-xr-xt/t3431-rebase-fork-point.sh20
-rwxr-xr-xt/t3432-rebase-fast-forward.sh24
-rwxr-xr-xt/t3507-cherry-pick-conflict.sh23
-rwxr-xr-xt/t3510-cherry-pick-sequence.sh3
-rwxr-xr-xt/t3700-add.sh2
-rwxr-xr-xt/t3701-add-interactive.sh2
-rwxr-xr-xt/t3903-stash.sh14
-rwxr-xr-xt/t4057-diff-combined-paths.sh2
-rwxr-xr-xt/t4150-am.sh2
-rwxr-xr-xt/t4202-log.sh105
-rwxr-xr-xt/t5319-multi-pack-index.sh13
-rw-r--r--t/t5319/no-objects.midxbin0 -> 1116 bytes
-rwxr-xr-xt/t5322-pack-objects-sparse.sh4
-rwxr-xr-xt/t5512-ls-remote.sh80
-rwxr-xr-xt/t5521-pull-options.sh22
-rwxr-xr-xt/t5537-fetch-shallow.sh2
-rwxr-xr-xt/t5550-http-fetch-dumb.sh20
-rwxr-xr-xt/t5562-http-backend-content-length.sh19
-rwxr-xr-xt/t5604-clone-reference.sh2
-rwxr-xr-xt/t5607-clone-bundle.sh2
-rwxr-xr-xt/t5612-clone-refspec.sh26
-rwxr-xr-xt/t5616-partial-clone.sh8
-rwxr-xr-xt/t5704-protocol-violations.sh33
-rwxr-xr-xt/t5801-remote-helpers.sh10
-rwxr-xr-xt/t6120-describe.sh20
-rwxr-xr-xt/t6200-fmt-merge-msg.sh23
-rwxr-xr-xt/t6300-for-each-ref.sh27
-rwxr-xr-xt/t7004-tag.sh1
-rwxr-xr-xt/t7112-reset-submodule.sh1
-rwxr-xr-xt/t7400-submodule-basic.sh4
-rwxr-xr-xt/t7416-submodule-dash-url.sh143
-rwxr-xr-xt/t7510-signed-commit.sh16
-rwxr-xr-xt/t7601-merge-pull-config.sh38
-rwxr-xr-xt/t7609-merge-co-error-msgs.sh2
-rwxr-xr-xt/t9010-svn-fe.sh2
-rwxr-xr-xt/t9300-fast-import.sh109
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh70
-rwxr-xr-xt/t9831-git-p4-triggers.sh2
-rw-r--r--t/test-lib-functions.sh22
-rw-r--r--t/test-lib.sh97
68 files changed, 1598 insertions, 433 deletions
diff --git a/t/README b/t/README
index 9afd61e3ca..d12efcd3a4 100644
--- a/t/README
+++ b/t/README
@@ -69,7 +69,8 @@ You can also run each test individually from command line, like this:
You can pass --verbose (or -v), --debug (or -d), and --immediate
(or -i) command line argument to the test, or by setting GIT_TEST_OPTS
-appropriately before running "make".
+appropriately before running "make". Short options can be bundled, i.e.
+'-d -v' is the same as '-dv'.
-v::
--verbose::
@@ -386,17 +387,13 @@ GIT_TEST_INDEX_VERSION=<n> exercises the index read/write code path
for the index version specified. Can be set to any valid version
(currently 2, 3, or 4).
-GIT_TEST_PACK_SPARSE=<boolean> if enabled will default the pack-objects
-builtin to use the sparse object walk. This can still be overridden by
-the --no-sparse command-line argument.
+GIT_TEST_PACK_SPARSE=<boolean> if disabled will default the pack-objects
+builtin to use the non-sparse object walk. This can still be overridden by
+the --sparse command-line argument.
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
by overriding the minimum number of cache entries required per thread.
-GIT_TEST_STASH_USE_BUILTIN=<boolean>, when false, disables the
-built-in version of git-stash. See 'stash.useBuiltin' in
-git-config(1).
-
GIT_TEST_ADD_I_USE_BUILTIN=<boolean>, when true, enables the
built-in version of git add -i. See 'add.interactive.useBuiltin' in
git-config(1).
diff --git a/t/helper/test-advise.c b/t/helper/test-advise.c
new file mode 100644
index 0000000000..38cdc2884e
--- /dev/null
+++ b/t/helper/test-advise.c
@@ -0,0 +1,22 @@
+#include "test-tool.h"
+#include "cache.h"
+#include "advice.h"
+#include "config.h"
+
+int cmd__advise_if_enabled(int argc, const char **argv)
+{
+ if (!argv[1])
+ die("usage: %s <advice>", argv[0]);
+
+ setup_git_directory();
+ git_config(git_default_config, NULL);
+
+ /*
+ * Any advice type can be used for testing, but NESTED_TAG was
+ * selected here and in t0018 where this command is being
+ * executed.
+ */
+ advise_if_enabled(ADVICE_NESTED_TAG, argv[1]);
+
+ return 0;
+}
diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index 63c689d6ee..a209880eb3 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -13,6 +13,8 @@ int cmd__dump_split_index(int ac, const char **av)
struct split_index *si;
int i;
+ setup_git_directory();
+
do_read_index(&the_index, av[1], 1);
printf("own %s\n", oid_to_hex(&the_index.oid));
si = the_index.split_index;
diff --git a/t/helper/test-sha1-array.c b/t/helper/test-oid-array.c
index ad5e69f9d3..ce9fd5f091 100644
--- a/t/helper/test-sha1-array.c
+++ b/t/helper/test-oid-array.c
@@ -1,6 +1,6 @@
#include "test-tool.h"
#include "cache.h"
-#include "sha1-array.h"
+#include "oid-array.h"
static int print_oid(const struct object_id *oid, void *data)
{
@@ -8,7 +8,7 @@ static int print_oid(const struct object_id *oid, void *data)
return 0;
}
-int cmd__sha1_array(int argc, const char **argv)
+int cmd__oid_array(int argc, const char **argv)
{
struct oid_array array = OID_ARRAY_INIT;
struct strbuf line = STRBUF_INIT;
@@ -19,11 +19,11 @@ int cmd__sha1_array(int argc, const char **argv)
if (skip_prefix(line.buf, "append ", &arg)) {
if (get_oid_hex(arg, &oid))
- die("not a hexadecimal SHA1: %s", arg);
+ die("not a hexadecimal oid: %s", arg);
oid_array_append(&array, &oid);
} else if (skip_prefix(line.buf, "lookup ", &arg)) {
if (get_oid_hex(arg, &oid))
- die("not a hexadecimal SHA1: %s", arg);
+ die("not a hexadecimal oid: %s", arg);
printf("%d\n", oid_array_lookup(&array, &oid));
} else if (!strcmp(line.buf, "clear"))
oid_array_clear(&array);
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 409034cf4e..313a153209 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -290,11 +290,14 @@ int cmd__path_utils(int argc, const char **argv)
}
if (argc >= 2 && !strcmp(argv[1], "real_path")) {
+ struct strbuf realpath = STRBUF_INIT;
while (argc > 2) {
- puts(real_path(argv[2]));
+ strbuf_realpath(&realpath, argv[2], 1);
+ puts(realpath.buf);
argc--;
argv++;
}
+ strbuf_release(&realpath);
return 0;
}
diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c
index f7f8618445..56f0e3c1be 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
@@ -19,12 +19,11 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
memset(the_repository, 0, sizeof(*the_repository));
- /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
- repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
-
if (repo_init(&r, gitdir, worktree))
die("Couldn't init repo");
+ repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
+
c = lookup_commit(&r, commit_oid);
if (!parse_commit_in_graph(&r, c))
@@ -50,12 +49,11 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
memset(the_repository, 0, sizeof(*the_repository));
- /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
- repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
-
if (repo_init(&r, gitdir, worktree))
die("Couldn't init repo");
+ repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
+
c = lookup_commit(&r, commit_oid);
/*
@@ -75,6 +73,10 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
int cmd__repository(int argc, const char **argv)
{
+ int nongit_ok = 0;
+
+ setup_git_directory_gently(&nongit_ok);
+
if (argc < 2)
die("must have at least 2 arguments");
if (!strcmp(argv[1], "parse_commit_in_graph")) {
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index c9a232d238..2ece4d1ebf 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -14,6 +14,7 @@ struct test_cmd {
};
static struct test_cmd cmds[] = {
+ { "advise", cmd__advise_if_enabled },
{ "chmtime", cmd__chmtime },
{ "config", cmd__config },
{ "ctype", cmd__ctype },
@@ -36,6 +37,7 @@ static struct test_cmd cmds[] = {
{ "match-trees", cmd__match_trees },
{ "mergesort", cmd__mergesort },
{ "mktemp", cmd__mktemp },
+ { "oid-array", cmd__oid_array },
{ "oidmap", cmd__oidmap },
{ "online-cpus", cmd__online_cpus },
{ "parse-options", cmd__parse_options },
@@ -56,7 +58,6 @@ static struct test_cmd cmds[] = {
{ "scrap-cache-tree", cmd__scrap_cache_tree },
{ "serve-v2", cmd__serve_v2 },
{ "sha1", cmd__sha1 },
- { "sha1-array", cmd__sha1_array },
{ "sha256", cmd__sha256 },
{ "sigchain", cmd__sigchain },
{ "strcmp-offset", cmd__strcmp_offset },
@@ -111,6 +112,7 @@ int cmd_main(int argc, const char **argv)
argc--;
trace2_cmd_name(cmds[i].name);
trace2_cmd_list_config();
+ trace2_cmd_list_env_vars();
return cmds[i].fn(argc, argv);
}
}
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index c8549fd87f..1cbaec02f3 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -4,6 +4,7 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "git-compat-util.h"
+int cmd__advise_if_enabled(int argc, const char **argv);
int cmd__chmtime(int argc, const char **argv);
int cmd__config(int argc, const char **argv);
int cmd__ctype(int argc, const char **argv);
@@ -46,7 +47,7 @@ int cmd__run_command(int argc, const char **argv);
int cmd__scrap_cache_tree(int argc, const char **argv);
int cmd__serve_v2(int argc, const char **argv);
int cmd__sha1(int argc, const char **argv);
-int cmd__sha1_array(int argc, const char **argv);
+int cmd__oid_array(int argc, const char **argv);
int cmd__sha256(int argc, const char **argv);
int cmd__sigchain(int argc, const char **argv);
int cmd__strcmp_offset(int argc, const char **argv);
diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index 937b831ea6..dea2cbef51 100755..100644
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -1,4 +1,5 @@
-#!/bin/sh
+# Shell library for testing credential handling including helpers. See t0302
+# for an example of testing a specific helper.
# Try a set of credential helpers; the expected stdin,
# stdout and stderr should be provided on stdin,
@@ -19,7 +20,7 @@ check() {
false
fi &&
test_cmp expect-stdout stdout &&
- test_cmp expect-stderr stderr
+ test_i18ncmp expect-stderr stderr
}
read_chunk() {
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 8d28652b72..9fc5241228 100755..100644
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -1,14 +1,25 @@
-#!/bin/sh
+# We always set GNUPGHOME, even if no usable GPG was found, as
+#
+# - It does not hurt, and
+#
+# - we cannot set global environment variables in lazy prereqs because they are
+# executed in an eval'ed subshell that changes the working directory to a
+# temporary one.
+
+GNUPGHOME="$PWD/gpghome"
+export GNUPGHOME
+
+test_lazy_prereq GPG '
+ gpg_version=$(gpg --version 2>&1)
+ test $? != 127 || exit 1
-gpg_version=$(gpg --version 2>&1)
-if test $? != 127
-then
# As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
- # the gpg version 1.0.6 didn't parse trust packets correctly, so for
+ # the gpg version 1.0.6 did not parse trust packets correctly, so for
# that version, creation of signed tags using the generated key fails.
case "$gpg_version" in
- 'gpg (GnuPG) 1.0.6'*)
+ "gpg (GnuPG) 1.0.6"*)
say "Your version of gpg (1.0.6) is too buggy for testing"
+ exit 1
;;
*)
# Available key info:
@@ -27,55 +38,54 @@ then
# To export ownertrust:
# gpg --homedir /tmp/gpghome --export-ownertrust \
# > lib-gpg/ownertrust
- mkdir ./gpghome &&
- chmod 0700 ./gpghome &&
- GNUPGHOME="$(pwd)/gpghome" &&
- export GNUPGHOME &&
- (gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
- gpg --homedir "${GNUPGHOME}" 2>/dev/null --import \
+ mkdir "$GNUPGHOME" &&
+ chmod 0700 "$GNUPGHOME" &&
+ (gpgconf --kill gpg-agent || : ) &&
+ gpg --homedir "${GNUPGHOME}" --import \
"$TEST_DIRECTORY"/lib-gpg/keyring.gpg &&
- gpg --homedir "${GNUPGHOME}" 2>/dev/null --import-ownertrust \
+ gpg --homedir "${GNUPGHOME}" --import-ownertrust \
"$TEST_DIRECTORY"/lib-gpg/ownertrust &&
- gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null 2>&1 \
- --sign -u committer@example.com &&
- test_set_prereq GPG &&
- # Available key info:
- # * see t/lib-gpg/gpgsm-gen-key.in
- # To generate new certificate:
- # * no passphrase
- # gpgsm --homedir /tmp/gpghome/ \
- # -o /tmp/gpgsm.crt.user \
- # --generate-key \
- # --batch t/lib-gpg/gpgsm-gen-key.in
- # To import certificate:
- # gpgsm --homedir /tmp/gpghome/ \
- # --import /tmp/gpgsm.crt.user
- # To export into a .p12 we can later import:
- # gpgsm --homedir /tmp/gpghome/ \
- # -o t/lib-gpg/gpgsm_cert.p12 \
- # --export-secret-key-p12 "committer@example.com"
- echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
- --passphrase-fd 0 --pinentry-mode loopback \
- --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
-
- gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
- grep fingerprint: |
- cut -d" " -f4 |
- tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
-
- echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
- echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
- -u committer@example.com -o /dev/null --sign - 2>&1 &&
- test_set_prereq GPGSM
+ gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null \
+ --sign -u committer@example.com
;;
esac
-fi
+'
+
+test_lazy_prereq GPGSM '
+ test_have_prereq GPG &&
+ # Available key info:
+ # * see t/lib-gpg/gpgsm-gen-key.in
+ # To generate new certificate:
+ # * no passphrase
+ # gpgsm --homedir /tmp/gpghome/ \
+ # -o /tmp/gpgsm.crt.user \
+ # --generate-key \
+ # --batch t/lib-gpg/gpgsm-gen-key.in
+ # To import certificate:
+ # gpgsm --homedir /tmp/gpghome/ \
+ # --import /tmp/gpgsm.crt.user
+ # To export into a .p12 we can later import:
+ # gpgsm --homedir /tmp/gpghome/ \
+ # -o t/lib-gpg/gpgsm_cert.p12 \
+ # --export-secret-key-p12 "committer@example.com"
+ echo | gpgsm --homedir "${GNUPGHOME}" \
+ --passphrase-fd 0 --pinentry-mode loopback \
+ --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
+
+ gpgsm --homedir "${GNUPGHOME}" -K |
+ grep fingerprint: |
+ cut -d" " -f4 |
+ tr -d "\\n" >"${GNUPGHOME}/trustlist.txt" &&
+
+ echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
+ echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
+ -u committer@example.com -o /dev/null --sign -
+'
-if test_have_prereq GPG &&
- echo | gpg --homedir "${GNUPGHOME}" -b --rfc1991 >/dev/null 2>&1
-then
- test_set_prereq RFC1991
-fi
+test_lazy_prereq RFC1991 '
+ test_have_prereq GPG &&
+ echo | gpg --homedir "${GNUPGHOME}" -b --rfc1991 >/dev/null
+'
sanitize_pgp() {
perl -ne '
diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh
index 1184cceef2..1184cceef2 100755..100644
--- a/t/lib-log-graph.sh
+++ b/t/lib-log-graph.sh
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 1dd17fc03e..64fc6487dd 100755..100644
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -297,7 +297,7 @@ test_submodule_content () {
# - Directory containing tracked files replaced by submodule
# - Submodule replaced by tracked files in directory
# - Submodule replaced by tracked file with the same name
-# - tracked file replaced by submodule
+# - Tracked file replaced by submodule
#
# The default is that submodule contents aren't changed until "git submodule
# update" is run. And even then that command doesn't delete the work tree of
@@ -621,11 +621,13 @@ test_submodule_forced_switch () {
# - Directory containing tracked files replaced by submodule
# - Submodule replaced by tracked files in directory
# - Submodule replaced by tracked file with the same name
-# - tracked file replaced by submodule
+# - Tracked file replaced by submodule
#
# New test cases
# - Removing a submodule with a git directory absorbs the submodules
# git directory first into the superproject.
+# - Switching from no submodule to nested submodules
+# - Switching from nested submodules to no submodule
# Internal function; use test_submodule_switch_recursing_with_args() or
# test_submodule_forced_switch_recursing_with_args() instead.
@@ -658,22 +660,6 @@ test_submodule_recursing_with_args_common() {
test_submodule_content sub1 origin/add_sub1
)
'
- test_expect_success "$command: submodule branch is not changed, detach HEAD instead" '
- prolog &&
- reset_work_tree_to_interested add_sub1 &&
- (
- cd submodule_update &&
- git -C sub1 checkout -b keep_branch &&
- git -C sub1 rev-parse HEAD >expect &&
- git branch -t modify_sub1 origin/modify_sub1 &&
- $command modify_sub1 &&
- test_superproject_content origin/modify_sub1 &&
- test_submodule_content sub1 origin/modify_sub1 &&
- git -C sub1 rev-parse keep_branch >actual &&
- test_cmp expect actual &&
- test_must_fail git -C sub1 symbolic-ref HEAD
- )
- '
# Replacing a tracked file with a submodule produces a checked out submodule
test_expect_success "$command: replace tracked file with submodule checks out submodule" '
@@ -699,6 +685,19 @@ test_submodule_recursing_with_args_common() {
test_submodule_content sub1 origin/replace_directory_with_sub1
)
'
+ # Switching to a commit with nested submodules recursively checks them out
+ test_expect_success "$command: nested submodules are checked out" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t modify_sub1_recursively origin/modify_sub1_recursively &&
+ $command modify_sub1_recursively &&
+ test_superproject_content origin/modify_sub1_recursively &&
+ test_submodule_content sub1 origin/modify_sub1_recursively &&
+ test_submodule_content -C sub1 sub2 origin/modify_sub1_recursively
+ )
+ '
######################## Disappearing submodule #######################
# Removing a submodule removes its work tree ...
@@ -762,6 +761,21 @@ test_submodule_recursing_with_args_common() {
)
'
+ # Switching to a commit without nested submodules removes their worktrees
+ test_expect_success "$command: worktrees of nested submodules are removed" '
+ prolog &&
+ reset_work_tree_to_interested add_nested_sub &&
+ (
+ cd submodule_update &&
+ git branch -t no_submodule origin/no_submodule &&
+ $command no_submodule &&
+ test_superproject_content origin/no_submodule &&
+ ! test_path_is_dir sub1 &&
+ test_must_fail git config -f .git/modules/sub1/config core.worktree &&
+ test_must_fail git config -f .git/modules/sub1/modules/sub2/config core.worktree
+ )
+ '
+
########################## Modified submodule #########################
# Updating a submodule sha1 updates the submodule's work tree
test_expect_success "$command: modified submodule updates submodule work tree" '
@@ -789,6 +803,23 @@ test_submodule_recursing_with_args_common() {
test_submodule_content sub1 origin/add_sub1
)
'
+ # Updating a submodule does not touch the currently checked out branch in the submodule
+ test_expect_success "$command: submodule branch is not changed, detach HEAD instead" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git -C sub1 checkout -b keep_branch &&
+ git -C sub1 rev-parse HEAD >expect &&
+ git branch -t modify_sub1 origin/modify_sub1 &&
+ $command modify_sub1 &&
+ test_superproject_content origin/modify_sub1 &&
+ test_submodule_content sub1 origin/modify_sub1 &&
+ git -C sub1 rev-parse keep_branch >actual &&
+ test_cmp expect actual &&
+ test_must_fail git -C sub1 symbolic-ref HEAD
+ )
+ '
}
# Declares and invokes several tests that, in various situations, checks that
@@ -908,7 +939,6 @@ test_submodule_switch_recursing_with_args () {
)
'
- # recursing deeper than one level doesn't work yet.
test_expect_success "$command: modified submodule updates submodule recursively" '
prolog &&
reset_work_tree_to_interested add_nested_sub &&
diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh
index 7743f4f4c9..80c53edca7 100755
--- a/t/perf/p5310-pack-bitmaps.sh
+++ b/t/perf/p5310-pack-bitmaps.sh
@@ -31,10 +31,6 @@ test_perf 'simulated fetch' '
} | git pack-objects --revs --stdout >/dev/null
'
-test_perf 'pack to file' '
- git pack-objects --all pack1 </dev/null >/dev/null
-'
-
test_perf 'pack to file (bitmap)' '
git pack-objects --use-bitmap-index --all pack1b </dev/null >/dev/null
'
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 3e440c078d..b859721620 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -833,6 +833,19 @@ then
exit 1
fi
+test_expect_success 'lazy prereqs do not turn off tracing' "
+ run_sub_test_lib_test lazy-prereq-and-tracing \
+ 'lazy prereqs and -x' -v -x <<-\\EOF &&
+ test_lazy_prereq LAZY true
+
+ test_expect_success lazy 'test_have_prereq LAZY && echo trace'
+
+ test_done
+ EOF
+
+ grep 'echo trace' lazy-prereq-and-tracing/err
+"
+
test_expect_success 'tests clean up even on failures' "
run_sub_test_lib_test_err \
failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
diff --git a/t/t0007-git-var.sh b/t/t0007-git-var.sh
index 1f600e2cae..88b9ae8158 100755
--- a/t/t0007-git-var.sh
+++ b/t/t0007-git-var.sh
@@ -17,7 +17,7 @@ test_expect_success 'get GIT_COMMITTER_IDENT' '
test_cmp expect actual
'
-test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identites are strict' '
+test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identities are strict' '
(
sane_unset GIT_COMMITTER_NAME &&
sane_unset GIT_COMMITTER_EMAIL &&
diff --git a/t/t0018-advice.sh b/t/t0018-advice.sh
new file mode 100755
index 0000000000..e03554d2f3
--- /dev/null
+++ b/t/t0018-advice.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test_description='Test advise_if_enabled functionality'
+
+. ./test-lib.sh
+
+test_expect_success 'advice should be printed when config variable is unset' '
+ cat >expect <<-\EOF &&
+ hint: This is a piece of advice
+ hint: Disable this message with "git config advice.nestedTag false"
+ EOF
+ test-tool advise "This is a piece of advice" 2>actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'advice should be printed when config variable is set to true' '
+ cat >expect <<-\EOF &&
+ hint: This is a piece of advice
+ hint: Disable this message with "git config advice.nestedTag false"
+ EOF
+ test_config advice.nestedTag true &&
+ test-tool advise "This is a piece of advice" 2>actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'advice should not be printed when config variable is set to false' '
+ test_config advice.nestedTag false &&
+ test-tool advise "This is a piece of advice" 2>actual &&
+ test_must_be_empty actual
+'
+
+test_done
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index dc664da551..4bfffa9c31 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -364,6 +364,10 @@ test_expect_success PERL 'required process filter should filter data' '
S=$(file_size test.r) &&
S2=$(file_size test2.r) &&
S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
+ M=$(git hash-object test.r) &&
+ M2=$(git hash-object test2.r) &&
+ M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
+ EMPTY=$(git hash-object /dev/null) &&
filter_git add . &&
cat >expected.log <<-EOF &&
@@ -378,14 +382,16 @@ test_expect_success PERL 'required process filter should filter data' '
test_cmp_count expected.log debug.log &&
git commit -m "test commit 2" &&
+ MASTER=$(git rev-parse --verify master) &&
+ META="ref=refs/heads/master treeish=$MASTER" &&
rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
filter_git checkout --quiet --no-progress . &&
cat >expected.log <<-EOF &&
START
init handshake complete
- IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
- IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
+ IN: smudge test2.r blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log &&
@@ -406,10 +412,10 @@ test_expect_success PERL 'required process filter should filter data' '
cat >expected.log <<-EOF &&
START
init handshake complete
- IN: smudge test.r $S [OK] -- OUT: $S . [OK]
- IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
- IN: smudge test4-empty.r 0 [OK] -- OUT: 0 [OK]
- IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log &&
@@ -420,6 +426,117 @@ test_expect_success PERL 'required process filter should filter data' '
)
'
+test_expect_success PERL 'required process filter should filter data for various subcommands' '
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
+ test_config_global filter.protocol.required true &&
+ (
+ cd repo &&
+
+ S=$(file_size test.r) &&
+ S2=$(file_size test2.r) &&
+ S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
+ M=$(git hash-object test.r) &&
+ M2=$(git hash-object test2.r) &&
+ M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
+ EMPTY=$(git hash-object /dev/null) &&
+
+ MASTER=$(git rev-parse --verify master) &&
+
+ cp "$TEST_ROOT/test.o" test5.r &&
+ git add test5.r &&
+ git commit -m "test commit 3" &&
+ git checkout empty-branch &&
+ filter_git rebase --onto empty-branch master^^ master &&
+ MASTER2=$(git rev-parse --verify master) &&
+ META="ref=refs/heads/master treeish=$MASTER2" &&
+ cat >expected.log <<-EOF &&
+ START
+ init handshake complete
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge test5.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
+ STOP
+ EOF
+ test_cmp_exclude_clean expected.log debug.log &&
+
+ git reset --hard empty-branch &&
+ filter_git reset --hard $MASTER &&
+ META="treeish=$MASTER" &&
+ cat >expected.log <<-EOF &&
+ START
+ init handshake complete
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
+ STOP
+ EOF
+ test_cmp_exclude_clean expected.log debug.log &&
+
+ git branch old-master $MASTER &&
+ git reset --hard empty-branch &&
+ filter_git reset --hard old-master &&
+ META="ref=refs/heads/old-master treeish=$MASTER" &&
+ cat >expected.log <<-EOF &&
+ START
+ init handshake complete
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
+ STOP
+ EOF
+ test_cmp_exclude_clean expected.log debug.log &&
+
+ git checkout -b merge empty-branch &&
+ git branch -f master $MASTER2 &&
+ filter_git merge master &&
+ META="treeish=$MASTER2" &&
+ cat >expected.log <<-EOF &&
+ START
+ init handshake complete
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge test5.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
+ STOP
+ EOF
+ test_cmp_exclude_clean expected.log debug.log &&
+
+ filter_git archive master >/dev/null &&
+ META="ref=refs/heads/master treeish=$MASTER2" &&
+ cat >expected.log <<-EOF &&
+ START
+ init handshake complete
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge test5.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
+ STOP
+ EOF
+ test_cmp_exclude_clean expected.log debug.log &&
+
+ TREE="$(git rev-parse $MASTER2^{tree})" &&
+ filter_git archive $TREE >/dev/null &&
+ META="treeish=$TREE" &&
+ cat >expected.log <<-EOF &&
+ START
+ init handshake complete
+ IN: smudge test.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r $META blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test4-empty.r $META blob=$EMPTY 0 [OK] -- OUT: 0 [OK]
+ IN: smudge test5.r $META blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $META blob=$M3 $S3 [OK] -- OUT: $S3 . [OK]
+ STOP
+ EOF
+ test_cmp_exclude_clean expected.log debug.log
+ )
+'
+
test_expect_success PERL 'required process filter takes precedence' '
test_config_global filter.protocol.clean false &&
test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&
@@ -519,17 +636,22 @@ test_expect_success PERL 'required process filter should process multiple packet
EOF
test_cmp_count expected.log debug.log &&
- rm -f *.file &&
+ M1="blob=$(git hash-object 1pkt_1__.file)" &&
+ M2="blob=$(git hash-object 2pkt_1+1.file)" &&
+ M3="blob=$(git hash-object 2pkt_2-1.file)" &&
+ M4="blob=$(git hash-object 2pkt_2__.file)" &&
+ M5="blob=$(git hash-object 3pkt_2+1.file)" &&
+ rm -f *.file debug.log &&
filter_git checkout --quiet --no-progress -- *.file &&
cat >expected.log <<-EOF &&
START
init handshake complete
- IN: smudge 1pkt_1__.file $(($S )) [OK] -- OUT: $(($S )) . [OK]
- IN: smudge 2pkt_1+1.file $(($S +1)) [OK] -- OUT: $(($S +1)) .. [OK]
- IN: smudge 2pkt_2-1.file $(($S*2-1)) [OK] -- OUT: $(($S*2-1)) .. [OK]
- IN: smudge 2pkt_2__.file $(($S*2 )) [OK] -- OUT: $(($S*2 )) .. [OK]
- IN: smudge 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK]
+ IN: smudge 1pkt_1__.file $M1 $(($S )) [OK] -- OUT: $(($S )) . [OK]
+ IN: smudge 2pkt_1+1.file $M2 $(($S +1)) [OK] -- OUT: $(($S +1)) .. [OK]
+ IN: smudge 2pkt_2-1.file $M3 $(($S*2-1)) [OK] -- OUT: $(($S*2-1)) .. [OK]
+ IN: smudge 2pkt_2__.file $M4 $(($S*2 )) [OK] -- OUT: $(($S*2 )) .. [OK]
+ IN: smudge 3pkt_2+1.file $M5 $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log &&
@@ -578,6 +700,10 @@ test_expect_success PERL 'process filter should restart after unexpected write f
S=$(file_size test.r) &&
S2=$(file_size test2.r) &&
SF=$(file_size smudge-write-fail.r) &&
+ M=$(git hash-object test.r) &&
+ M2=$(git hash-object test2.r) &&
+ MF=$(git hash-object smudge-write-fail.r) &&
+ rm -f debug.log &&
git add . &&
rm -f *.r &&
@@ -591,11 +717,11 @@ test_expect_success PERL 'process filter should restart after unexpected write f
cat >expected.log <<-EOF &&
START
init handshake complete
- IN: smudge smudge-write-fail.r $SF [OK] -- [WRITE FAIL]
+ IN: smudge smudge-write-fail.r blob=$MF $SF [OK] -- [WRITE FAIL]
START
init handshake complete
- IN: smudge test.r $S [OK] -- OUT: $S . [OK]
- IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge test.r blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log &&
@@ -629,6 +755,10 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
S=$(file_size test.r) &&
S2=$(file_size test2.r) &&
SE=$(file_size error.r) &&
+ M=$(git hash-object test.r) &&
+ M2=$(git hash-object test2.r) &&
+ ME=$(git hash-object error.r) &&
+ rm -f debug.log &&
git add . &&
rm -f *.r &&
@@ -637,9 +767,9 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
cat >expected.log <<-EOF &&
START
init handshake complete
- IN: smudge error.r $SE [OK] -- [ERROR]
- IN: smudge test.r $S [OK] -- OUT: $S . [OK]
- IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
+ IN: smudge error.r blob=$ME $SE [OK] -- [ERROR]
+ IN: smudge test.r blob=$M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test2.r blob=$M2 $S2 [OK] -- OUT: $S2 . [OK]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log &&
@@ -665,18 +795,21 @@ test_expect_success PERL 'process filter abort stops processing of all further f
echo "error this blob and all future blobs" >abort.o &&
cp abort.o abort.r &&
+ M="blob=$(git hash-object abort.r)" &&
+ rm -f debug.log &&
SA=$(file_size abort.r) &&
git add . &&
rm -f *.r &&
+
# Note: This test assumes that Git filters files in alphabetical
# order ("abort.r" before "test.r").
filter_git checkout --quiet --no-progress . &&
cat >expected.log <<-EOF &&
START
init handshake complete
- IN: smudge abort.r $SA [OK] -- [ABORT]
+ IN: smudge abort.r $M $SA [OK] -- [ABORT]
STOP
EOF
test_cmp_exclude_clean expected.log debug.log &&
@@ -727,27 +860,29 @@ test_expect_success PERL 'delayed checkout in process filter' '
) &&
S=$(file_size "$TEST_ROOT/test.o") &&
+ PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " &&
+ M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" &&
cat >a.exp <<-EOF &&
START
init handshake complete
- IN: smudge test.a $S [OK] -- OUT: $S . [OK]
- IN: smudge test-delay10.a $S [OK] -- [DELAYED]
- IN: smudge test-delay11.a $S [OK] -- [DELAYED]
- IN: smudge test-delay20.a $S [OK] -- [DELAYED]
+ IN: smudge test.a $M $S [OK] -- OUT: $S . [OK]
+ IN: smudge test-delay10.a $M $S [OK] -- [DELAYED]
+ IN: smudge test-delay11.a $M $S [OK] -- [DELAYED]
+ IN: smudge test-delay20.a $M $S [OK] -- [DELAYED]
IN: list_available_blobs test-delay10.a test-delay11.a [OK]
- IN: smudge test-delay10.a 0 [OK] -- OUT: $S . [OK]
- IN: smudge test-delay11.a 0 [OK] -- OUT: $S . [OK]
+ IN: smudge test-delay10.a $M 0 [OK] -- OUT: $S . [OK]
+ IN: smudge test-delay11.a $M 0 [OK] -- OUT: $S . [OK]
IN: list_available_blobs test-delay20.a [OK]
- IN: smudge test-delay20.a 0 [OK] -- OUT: $S . [OK]
+ IN: smudge test-delay20.a $M 0 [OK] -- OUT: $S . [OK]
IN: list_available_blobs [OK]
STOP
EOF
cat >b.exp <<-EOF &&
START
init handshake complete
- IN: smudge test-delay10.b $S [OK] -- [DELAYED]
+ IN: smudge test-delay10.b $M $S [OK] -- [DELAYED]
IN: list_available_blobs test-delay10.b [OK]
- IN: smudge test-delay10.b 0 [OK] -- OUT: $S . [OK]
+ IN: smudge test-delay10.b $M 0 [OK] -- OUT: $S . [OK]
IN: list_available_blobs [OK]
STOP
EOF
@@ -767,8 +902,11 @@ test_expect_success PERL 'delayed checkout in process filter' '
rm *.a *.b &&
filter_git checkout . &&
- test_cmp_count ../a.exp a.log &&
- test_cmp_count ../b.exp b.log &&
+ # We are not checking out a ref here, so filter out ref metadata.
+ sed -e "s!$PM!!" ../a.exp >a.exp.filtered &&
+ sed -e "s!$PM!!" ../b.exp >b.exp.filtered &&
+ test_cmp_count a.exp.filtered a.log &&
+ test_cmp_count b.exp.filtered b.log &&
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.a &&
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test-delay10.a &&
diff --git a/t/t0021/rot13-filter.pl b/t/t0021/rot13-filter.pl
index 470107248e..cd32a82da5 100644
--- a/t/t0021/rot13-filter.pl
+++ b/t/t0021/rot13-filter.pl
@@ -135,7 +135,13 @@ while (1) {
if ( exists $DELAY{$pathname} and $DELAY{$pathname}{"requested"} == 0 ) {
$DELAY{$pathname}{"requested"} = 1;
}
+ } elsif ($buffer =~ /^(ref|treeish|blob)=/) {
+ print $debug " $buffer";
} else {
+ # In general, filters need to be graceful about
+ # new metadata, since it's documented that we
+ # can pass any key-value pairs, but for tests,
+ # let's be a little stricter.
die "Unknown message '$buffer'";
}
diff --git a/t/t0064-sha1-array.sh b/t/t0064-sha1-array.sh
index 5dda570b9a..45685af2fd 100755
--- a/t/t0064-sha1-array.sh
+++ b/t/t0064-sha1-array.sh
@@ -18,7 +18,7 @@ test_expect_success 'ordered enumeration' '
{
echoid append 88 44 aa 55 &&
echo for_each_unique
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
test_cmp expect actual
'
@@ -28,7 +28,7 @@ test_expect_success 'ordered enumeration with duplicate suppression' '
echoid append 88 44 aa 55 &&
echoid append 88 44 aa 55 &&
echo for_each_unique
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
test_cmp expect actual
'
@@ -36,7 +36,7 @@ test_expect_success 'lookup' '
{
echoid append 88 44 aa 55 &&
echoid lookup 55
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -eq 1
'
@@ -45,7 +45,7 @@ test_expect_success 'lookup non-existing entry' '
{
echoid append 88 44 aa 55 &&
echoid lookup 33
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -lt 0
'
@@ -55,7 +55,7 @@ test_expect_success 'lookup with duplicates' '
echoid append 88 44 aa 55 &&
echoid append 88 44 aa 55 &&
echoid lookup 55
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -ge 2 &&
test "$n" -le 3
@@ -66,7 +66,7 @@ test_expect_success 'lookup non-existing entry with duplicates' '
echoid append 88 44 aa 55 &&
echoid append 88 44 aa 55 &&
echoid lookup 66
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -lt 0
'
@@ -81,7 +81,7 @@ test_expect_success 'lookup with almost duplicate values' '
echo "append $id1" &&
echo "append $id2" &&
echoid lookup 55
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -eq 0
'
@@ -90,7 +90,7 @@ test_expect_success 'lookup with single duplicate value' '
{
echoid append 55 55 &&
echoid lookup 55
- } | test-tool sha1-array >actual &&
+ } | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -ge 0 &&
test "$n" -le 1
diff --git a/t/t0212-trace2-event.sh b/t/t0212-trace2-event.sh
index 7065a1b937..1529155cf0 100755
--- a/t/t0212-trace2-event.sh
+++ b/t/t0212-trace2-event.sh
@@ -199,6 +199,43 @@ test_expect_success JSON_PP 'event stream, list config' '
test_cmp expect actual
'
+# Test listing of all "interesting" environment variables.
+
+test_expect_success JSON_PP 'event stream, list env vars' '
+ test_when_finished "rm trace.event actual expect" &&
+ GIT_TRACE2_EVENT="$(pwd)/trace.event" \
+ GIT_TRACE2_ENV_VARS="A_VAR,OTHER_VAR,MISSING" \
+ A_VAR=1 OTHER_VAR="hello world" test-tool trace2 001return 0 &&
+ perl "$TEST_DIRECTORY/t0212/parse_events.perl" <trace.event >actual &&
+ sed -e "s/^|//" >expect <<-EOF &&
+ |VAR1 = {
+ | "_SID0_":{
+ | "argv":[
+ | "_EXE_",
+ | "trace2",
+ | "001return",
+ | "0"
+ | ],
+ | "exit_code":0,
+ | "hierarchy":"trace2",
+ | "name":"trace2",
+ | "params":[
+ | {
+ | "param":"A_VAR",
+ | "value":"1"
+ | },
+ | {
+ | "param":"OTHER_VAR",
+ | "value":"hello world"
+ | }
+ | ],
+ | "version":"$V"
+ | }
+ |};
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success JSON_PP 'basic trace2_data' '
test_when_finished "rm trace.event actual expect" &&
GIT_TRACE2_EVENT="$(pwd)/trace.event" test-tool trace2 006data test_category k1 v1 test_category k2 v2 &&
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index 39f097ea9e..5555a1524f 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -22,6 +22,11 @@ test_expect_success 'setup helper scripts' '
exit 0
EOF
+ write_script git-credential-quit <<-\EOF &&
+ . ./dump
+ echo quit=1
+ EOF
+
write_script git-credential-verbatim <<-\EOF &&
user=$1; shift
pass=$1; shift
@@ -35,43 +40,71 @@ test_expect_success 'setup helper scripts' '
test_expect_success 'credential_fill invokes helper' '
check fill "verbatim foo bar" <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=foo
password=bar
--
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
EOF
'
test_expect_success 'credential_fill invokes multiple helpers' '
check fill useless "verbatim foo bar" <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=foo
password=bar
--
useless: get
+ useless: protocol=http
+ useless: host=example.com
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
EOF
'
test_expect_success 'credential_fill stops when we get a full response' '
check fill "verbatim one two" "verbatim three four" <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=one
password=two
--
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
EOF
'
test_expect_success 'credential_fill continues through partial response' '
check fill "verbatim one \"\"" "verbatim two three" <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=two
password=three
--
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
verbatim: username=one
EOF
'
@@ -97,14 +130,20 @@ test_expect_success 'credential_fill passes along metadata' '
test_expect_success 'credential_approve calls all helpers' '
check approve useless "verbatim one two" <<-\EOF
+ protocol=http
+ host=example.com
username=foo
password=bar
--
--
useless: store
+ useless: protocol=http
+ useless: host=example.com
useless: username=foo
useless: password=bar
verbatim: store
+ verbatim: protocol=http
+ verbatim: host=example.com
verbatim: username=foo
verbatim: password=bar
EOF
@@ -112,6 +151,8 @@ test_expect_success 'credential_approve calls all helpers' '
test_expect_success 'do not bother storing password-less credential' '
check approve useless <<-\EOF
+ protocol=http
+ host=example.com
username=foo
--
--
@@ -121,14 +162,20 @@ test_expect_success 'do not bother storing password-less credential' '
test_expect_success 'credential_reject calls all helpers' '
check reject useless "verbatim one two" <<-\EOF
+ protocol=http
+ host=example.com
username=foo
password=bar
--
--
useless: erase
+ useless: protocol=http
+ useless: host=example.com
useless: username=foo
useless: password=bar
verbatim: erase
+ verbatim: protocol=http
+ verbatim: host=example.com
verbatim: username=foo
verbatim: password=bar
EOF
@@ -136,33 +183,49 @@ test_expect_success 'credential_reject calls all helpers' '
test_expect_success 'usernames can be preserved' '
check fill "verbatim \"\" three" <<-\EOF
+ protocol=http
+ host=example.com
username=one
--
+ protocol=http
+ host=example.com
username=one
password=three
--
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
verbatim: username=one
EOF
'
test_expect_success 'usernames can be overridden' '
check fill "verbatim two three" <<-\EOF
+ protocol=http
+ host=example.com
username=one
--
+ protocol=http
+ host=example.com
username=two
password=three
--
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
verbatim: username=one
EOF
'
test_expect_success 'do not bother completing already-full credential' '
check fill "verbatim three four" <<-\EOF
+ protocol=http
+ host=example.com
username=one
password=two
--
+ protocol=http
+ host=example.com
username=one
password=two
--
@@ -174,23 +237,31 @@ test_expect_success 'do not bother completing already-full credential' '
# askpass helper is run, we know the internal getpass is working.
test_expect_success 'empty helper list falls back to internal getpass' '
check fill <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=askpass-username
password=askpass-password
--
- askpass: Username:
- askpass: Password:
+ askpass: Username for '\''http://example.com'\'':
+ askpass: Password for '\''http://askpass-username@example.com'\'':
EOF
'
test_expect_success 'internal getpass does not ask for known username' '
check fill <<-\EOF
+ protocol=http
+ host=example.com
username=foo
--
+ protocol=http
+ host=example.com
username=foo
password=askpass-password
--
- askpass: Password:
+ askpass: Password for '\''http://foo@example.com'\'':
EOF
'
@@ -202,7 +273,11 @@ HELPER="!f() {
test_expect_success 'respect configured credentials' '
test_config credential.helper "$HELPER" &&
check fill <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=foo
password=bar
--
@@ -419,21 +494,85 @@ test_expect_success 'context uses urlmatch' '
test_expect_success 'helpers can abort the process' '
test_must_fail git \
- -c credential.helper="!f() { echo quit=1; }; f" \
+ -c credential.helper=quit \
-c credential.helper="verbatim foo bar" \
- credential fill >stdout &&
- test_must_be_empty stdout
+ credential fill >stdout 2>stderr <<-\EOF &&
+ protocol=http
+ host=example.com
+ EOF
+ test_must_be_empty stdout &&
+ cat >expect <<-\EOF &&
+ quit: get
+ quit: protocol=http
+ quit: host=example.com
+ fatal: credential helper '\''quit'\'' told us to quit
+ EOF
+ test_i18ncmp expect stderr
'
test_expect_success 'empty helper spec resets helper list' '
test_config credential.helper "verbatim file file" &&
check fill "" "verbatim cmdline cmdline" <<-\EOF
+ protocol=http
+ host=example.com
--
+ protocol=http
+ host=example.com
username=cmdline
password=cmdline
--
verbatim: get
+ verbatim: protocol=http
+ verbatim: host=example.com
+ EOF
+'
+
+test_expect_success 'url parser rejects embedded newlines' '
+ test_must_fail git credential fill 2>stderr <<-\EOF &&
+ url=https://one.example.com?%0ahost=two.example.com/
+ EOF
+ cat >expect <<-\EOF &&
+ warning: url contains a newline in its host component: https://one.example.com?%0ahost=two.example.com/
+ fatal: credential url cannot be parsed: https://one.example.com?%0ahost=two.example.com/
+ EOF
+ test_i18ncmp expect stderr
+'
+
+test_expect_success 'host-less URLs are parsed as empty host' '
+ check fill "verbatim foo bar" <<-\EOF
+ url=cert:///path/to/cert.pem
+ --
+ protocol=cert
+ host=
+ path=path/to/cert.pem
+ username=foo
+ password=bar
+ --
+ verbatim: get
+ verbatim: protocol=cert
+ verbatim: host=
+ verbatim: path=path/to/cert.pem
+ EOF
+'
+
+test_expect_success 'credential system refuses to work with missing host' '
+ test_must_fail git credential fill 2>stderr <<-\EOF &&
+ protocol=http
+ EOF
+ cat >expect <<-\EOF &&
+ fatal: refusing to work with credential missing host field
+ EOF
+ test_i18ncmp expect stderr
+'
+
+test_expect_success 'credential system refuses to work with missing protocol' '
+ test_must_fail git credential fill 2>stderr <<-\EOF &&
+ host=example.com
+ EOF
+ cat >expect <<-\EOF &&
+ fatal: refusing to work with credential missing protocol field
EOF
+ test_i18ncmp expect stderr
'
test_done
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index d09eff503c..449ebc5657 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -133,6 +133,30 @@ test_expect_success 'other worktree HEAD link pointing at a funny place' '
test_i18ngrep "worktrees/other/HEAD points to something strange" out
'
+test_expect_success 'commit with multiple signatures is okay' '
+ git cat-file commit HEAD >basis &&
+ cat >sigs <<-EOF &&
+ gpgsig -----BEGIN PGP SIGNATURE-----
+ VGhpcyBpcyBub3QgcmVhbGx5IGEgc2lnbmF0dXJlLg==
+ -----END PGP SIGNATURE-----
+ gpgsig-sha256 -----BEGIN PGP SIGNATURE-----
+ VGhpcyBpcyBub3QgcmVhbGx5IGEgc2lnbmF0dXJlLg==
+ -----END PGP SIGNATURE-----
+ EOF
+ sed -e "/^committer/q" basis >okay &&
+ cat sigs >>okay &&
+ echo >>okay &&
+ sed -e "1,/^$/d" basis >>okay &&
+ cat okay &&
+ new=$(git hash-object -t commit -w --stdin <okay) &&
+ test_when_finished "remove_object $new" &&
+ git update-ref refs/heads/bogus "$new" &&
+ test_when_finished "git update-ref -d refs/heads/bogus" &&
+ git fsck 2>out &&
+ cat out &&
+ ! grep "commit $new" out
+'
+
test_expect_success 'email without @ is okay' '
git cat-file commit HEAD >basis &&
sed "s/@/AT/" basis >okay &&
diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh
index 69ffe865b4..52585ec2aa 100755
--- a/t/t2402-worktree-list.sh
+++ b/t/t2402-worktree-list.sh
@@ -152,7 +152,7 @@ test_expect_success 'linked worktrees are sorted' '
'
test_expect_success 'worktree path when called in .git directory' '
- git worktree list >list1&&
+ git worktree list >list1 &&
git -C .git worktree list >list2 &&
test_cmp list1 list2
'
diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh
index ee8a8dba52..a927774910 100755
--- a/t/t3403-rebase-skip.sh
+++ b/t/t3403-rebase-skip.sh
@@ -29,6 +29,13 @@ test_expect_success setup '
test_tick &&
git commit -m reverted-goodbye &&
git tag reverted-goodbye &&
+ git checkout goodbye &&
+ test_tick &&
+ GIT_AUTHOR_NAME="Another Author" \
+ GIT_AUTHOR_EMAIL="another.author@example.com" \
+ git commit --amend --no-edit -m amended-goodbye &&
+ test_tick &&
+ git tag amended-goodbye &&
git checkout -f skip-reference &&
echo moo > hello &&
@@ -85,6 +92,78 @@ test_expect_success 'moved back to branch correctly' '
test_debug 'gitk --all & sleep 1'
+test_expect_success 'correct advice upon picking empty commit' '
+ test_when_finished "git rebase --abort" &&
+ test_must_fail git rebase -i --onto goodbye \
+ amended-goodbye^ amended-goodbye 2>err &&
+ test_i18ngrep "previous cherry-pick is now empty" err &&
+ test_i18ngrep "git rebase --skip" err &&
+ test_must_fail git commit &&
+ test_i18ngrep "git rebase --skip" err
+'
+
+test_expect_success 'correct authorship when committing empty pick' '
+ test_when_finished "git rebase --abort" &&
+ test_must_fail git rebase -i --onto goodbye \
+ amended-goodbye^ amended-goodbye &&
+ git commit --allow-empty &&
+ git log --pretty=format:"%an <%ae>%n%ad%B" -1 amended-goodbye >expect &&
+ git log --pretty=format:"%an <%ae>%n%ad%B" -1 HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'correct advice upon rewording empty commit' '
+ test_when_finished "git rebase --abort" &&
+ (
+ set_fake_editor &&
+ test_must_fail env FAKE_LINES="reword 1" git rebase -i \
+ --onto goodbye amended-goodbye^ amended-goodbye 2>err
+ ) &&
+ test_i18ngrep "previous cherry-pick is now empty" err &&
+ test_i18ngrep "git rebase --skip" err &&
+ test_must_fail git commit &&
+ test_i18ngrep "git rebase --skip" err
+'
+
+test_expect_success 'correct advice upon editing empty commit' '
+ test_when_finished "git rebase --abort" &&
+ (
+ set_fake_editor &&
+ test_must_fail env FAKE_LINES="edit 1" git rebase -i \
+ --onto goodbye amended-goodbye^ amended-goodbye 2>err
+ ) &&
+ test_i18ngrep "previous cherry-pick is now empty" err &&
+ test_i18ngrep "git rebase --skip" err &&
+ test_must_fail git commit &&
+ test_i18ngrep "git rebase --skip" err
+'
+
+test_expect_success 'correct advice upon cherry-picking an empty commit during a rebase' '
+ test_when_finished "git rebase --abort" &&
+ (
+ set_fake_editor &&
+ test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_amended-goodbye" \
+ git rebase -i goodbye^ goodbye 2>err
+ ) &&
+ test_i18ngrep "previous cherry-pick is now empty" err &&
+ test_i18ngrep "git cherry-pick --skip" err &&
+ test_must_fail git commit 2>err &&
+ test_i18ngrep "git cherry-pick --skip" err
+'
+
+test_expect_success 'correct advice upon multi cherry-pick picking an empty commit during a rebase' '
+ test_when_finished "git rebase --abort" &&
+ (
+ set_fake_editor &&
+ test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_goodbye_amended-goodbye" \
+ git rebase -i goodbye^^ goodbye 2>err
+ ) &&
+ test_i18ngrep "previous cherry-pick is now empty" err &&
+ test_i18ngrep "git cherry-pick --skip" err &&
+ test_must_fail git commit 2>err &&
+ test_i18ngrep "git cherry-pick --skip" err
+'
+
test_expect_success 'fixup that empties commit fails' '
test_when_finished "git rebase --abort" &&
(
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index c5ce3ab760..4a7d21f898 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -187,7 +187,7 @@ test_expect_success 'no changes are a nop' '
git checkout branch2 &&
git rebase -i F &&
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
- test $(git rev-parse I) = $(git rev-parse HEAD)
+ test_cmp_rev I HEAD
'
test_expect_success 'test the [branch] option' '
@@ -196,16 +196,16 @@ test_expect_success 'test the [branch] option' '
git commit -m "stop here" &&
git rebase -i F branch2 &&
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
- test $(git rev-parse I) = $(git rev-parse branch2) &&
- test $(git rev-parse I) = $(git rev-parse HEAD)
+ test_cmp_rev I branch2 &&
+ test_cmp_rev I HEAD
'
test_expect_success 'test --onto <branch>' '
git checkout -b test-onto branch2 &&
git rebase -i --onto branch1 F &&
test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
- test $(git rev-parse HEAD^) = $(git rev-parse branch1) &&
- test $(git rev-parse I) = $(git rev-parse branch2)
+ test_cmp_rev HEAD^ branch1 &&
+ test_cmp_rev I branch2
'
test_expect_success 'rebase on top of a non-conflicting commit' '
@@ -214,12 +214,12 @@ test_expect_success 'rebase on top of a non-conflicting commit' '
git rebase -i branch2 &&
test file6 = $(git diff --name-only original-branch1) &&
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
- test $(git rev-parse I) = $(git rev-parse branch2) &&
- test $(git rev-parse I) = $(git rev-parse HEAD~2)
+ test_cmp_rev I branch2 &&
+ test_cmp_rev I HEAD~2
'
test_expect_success 'reflog for the branch shows state before rebase' '
- test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
+ test_cmp_rev branch1@{1} original-branch1
'
test_expect_success 'reflog for the branch shows correct finish message' '
@@ -279,7 +279,7 @@ test_expect_success 'show conflicted patch' '
test_expect_success 'abort' '
git rebase --abort &&
- test $(git rev-parse new-branch1) = $(git rev-parse HEAD) &&
+ test_cmp_rev new-branch1 HEAD &&
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
test_path_is_missing .git/rebase-merge
'
@@ -322,7 +322,7 @@ test_expect_success 'retain authorship w/ conflicts' '
echo resolved >conflict &&
git add conflict &&
git rebase --continue &&
- test $(git rev-parse conflict-a^0) = $(git rev-parse HEAD^) &&
+ test_cmp_rev conflict-a^0 HEAD^ &&
git show >out &&
grep AttributeMe out
'
@@ -339,7 +339,7 @@ test_expect_success 'squash' '
git rebase -i --onto master HEAD~2
) &&
test B = $(cat file7) &&
- test $(git rev-parse HEAD^) = $(git rev-parse master)
+ test_cmp_rev HEAD^ master
'
test_expect_success 'retain authorship when squashing' '
@@ -398,9 +398,9 @@ test_expect_success REBASE_P 'preserve merges with -p' '
git update-index --refresh &&
git diff-files --quiet &&
git diff-index --quiet --cached HEAD -- &&
- test $(git rev-parse HEAD~6) = $(git rev-parse branch1) &&
- test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) &&
- test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) &&
+ test_cmp_rev HEAD~6 branch1 &&
+ test_cmp_rev HEAD~4^2 to-be-preserved &&
+ test_cmp_rev HEAD^^2^ HEAD^^^ &&
test $(git show HEAD~5:file1) = B &&
test $(git show HEAD~3:file1) = C &&
test $(git show HEAD:file1) = E &&
@@ -432,7 +432,7 @@ test_expect_success '--continue tries to commit' '
git add file1 &&
FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue
) &&
- test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) &&
+ test_cmp_rev HEAD^ new-branch1 &&
git show HEAD | grep chouette
'
@@ -739,7 +739,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' '
--author="Somebody else <somebody@else.com>" &&
test $(git rev-parse branch3) != $(git rev-parse branch4) &&
git rebase -i branch3 &&
- test $(git rev-parse branch3) = $(git rev-parse branch4)
+ test_cmp_rev branch3 branch4
'
@@ -798,7 +798,7 @@ test_expect_success 'rebase -i continue with unstaged submodule' '
test_must_fail git rebase -i submodule-base &&
git reset &&
git rebase --continue &&
- test $(git rev-parse submodule-base) = $(git rev-parse HEAD)
+ test_cmp_rev submodule-base HEAD
'
test_expect_success 'avoid unnecessary reset' '
@@ -821,7 +821,7 @@ test_expect_success 'reword' '
git rebase -i A &&
git show HEAD | grep "E changed" &&
test $(git rev-parse master) != $(git rev-parse HEAD) &&
- test $(git rev-parse master^) = $(git rev-parse HEAD^) &&
+ test_cmp_rev master^ HEAD^ &&
FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
git rebase -i A &&
git show HEAD^ | grep "D changed" &&
@@ -885,7 +885,7 @@ test_expect_success 'always cherry-pick with --no-ff' '
git diff HEAD~$p original-no-ff-branch~$p > out &&
test_must_be_empty out
done &&
- test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) &&
+ test_cmp_rev HEAD~3 original-no-ff-branch~3 &&
git diff HEAD~3 original-no-ff-branch~3 > out &&
test_must_be_empty out
'
@@ -1734,6 +1734,32 @@ test_expect_success 'post-commit hook is called' '
test_cmp expect actual
'
+test_expect_success 'correct error message for partial commit after empty pick' '
+ test_when_finished "git rebase --abort" &&
+ (
+ set_fake_editor &&
+ FAKE_LINES="2 1 1" &&
+ export FAKE_LINES &&
+ test_must_fail git rebase -i A D
+ ) &&
+ echo x >file1 &&
+ test_must_fail git commit file1 2>err &&
+ test_i18ngrep "cannot do a partial commit during a rebase." err
+'
+
+test_expect_success 'correct error message for commit --amend after empty pick' '
+ test_when_finished "git rebase --abort" &&
+ (
+ set_fake_editor &&
+ FAKE_LINES="1 1" &&
+ export FAKE_LINES &&
+ test_must_fail git rebase -i A D
+ ) &&
+ echo x>file1 &&
+ test_must_fail git commit -a --amend 2>err &&
+ test_i18ngrep "middle of a rebase -- cannot amend." err
+'
+
# This must be the last test in this file
test_expect_success '$EDITOR and friends are unchanged' '
test_editor_unchanged
diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh
index 61b76f3301..927a4f4a4e 100755
--- a/t/t3406-rebase-message.sh
+++ b/t/t3406-rebase-message.sh
@@ -89,22 +89,22 @@ test_expect_success 'GIT_REFLOG_ACTION' '
git checkout -b reflog-topic start &&
test_commit reflog-to-rebase &&
- git rebase --apply reflog-onto &&
+ git rebase reflog-onto &&
git log -g --format=%gs -3 >actual &&
cat >expect <<-\EOF &&
- rebase finished: returning to refs/heads/reflog-topic
- rebase: reflog-to-rebase
- rebase: checkout reflog-onto
+ rebase (finish): returning to refs/heads/reflog-topic
+ rebase (pick): reflog-to-rebase
+ rebase (start): checkout reflog-onto
EOF
test_cmp expect actual &&
git checkout -b reflog-prefix reflog-to-rebase &&
- GIT_REFLOG_ACTION=change-the-reflog git rebase --apply reflog-onto &&
+ GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto &&
git log -g --format=%gs -3 >actual &&
cat >expect <<-\EOF &&
- rebase finished: returning to refs/heads/reflog-prefix
- change-the-reflog: reflog-to-rebase
- change-the-reflog: checkout reflog-onto
+ change-the-reflog (finish): returning to refs/heads/reflog-prefix
+ change-the-reflog (pick): reflog-to-rebase
+ change-the-reflog (start): checkout reflog-onto
EOF
test_cmp expect actual
'
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index e85cdc7037..946e92f8da 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -52,7 +52,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
git commit --allow-empty -m "Initial empty commit" &&
git add file && git commit -m first &&
mv second file &&
- git add file && git commit -m second &&
+ git add file && git commit -m second &&
git rebase --whitespace=fix HEAD^^ &&
git diff --exit-code HEAD^:file expect-first &&
test_cmp expect-second file
@@ -118,7 +118,7 @@ test_expect_success 'at beginning of file' '
for i in 1 2 3 4 5; do
echo $i
done >> file &&
- git commit -m more file &&
+ git commit -m more file &&
git rebase --whitespace=fix HEAD^^ &&
test_cmp expect-beginning file
'
diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh
index d934583776..1f32faa4a4 100755
--- a/t/t3419-rebase-patch-id.sh
+++ b/t/t3419-rebase-patch-id.sh
@@ -4,15 +4,6 @@ test_description='git rebase - test patch id computation'
. ./test-lib.sh
-count () {
- i=0
- while test $i -lt $1
- do
- echo "$i"
- i=$(($i+1))
- done
-}
-
scramble () {
i=0
while read x
@@ -26,76 +17,55 @@ scramble () {
mv -f "$1.new" "$1"
}
-run () {
- echo \$ "$@"
- /usr/bin/time "$@" >/dev/null
-}
-
test_expect_success 'setup' '
git commit --allow-empty -m initial &&
git tag root
'
-do_tests () {
- nlines=$1 pr=${2-}
-
- test_expect_success $pr "setup: $nlines lines" "
- rm -f .gitattributes &&
- git checkout -q -f master &&
- git reset --hard root &&
- count $nlines >file &&
- git add file &&
- git commit -q -m initial &&
- git branch -f other &&
-
- scramble file &&
- git add file &&
- git commit -q -m 'change big file' &&
-
- git checkout -q other &&
- : >newfile &&
- git add newfile &&
- git commit -q -m 'add small file' &&
-
- git cherry-pick master >/dev/null 2>&1
- "
-
- test_debug "
- run git diff master^\!
- "
-
- test_expect_success $pr 'setup attributes' "
- echo 'file binary' >.gitattributes
- "
-
- test_debug "
- run git format-patch --stdout master &&
- run git format-patch --stdout --ignore-if-in-upstream master
- "
+test_expect_success 'setup: 500 lines' '
+ rm -f .gitattributes &&
+ git checkout -q -f master &&
+ git reset --hard root &&
+ test_seq 500 >file &&
+ git add file &&
+ git commit -q -m initial &&
+ git branch -f other &&
+
+ scramble file &&
+ git add file &&
+ git commit -q -m "change big file" &&
+
+ git checkout -q other &&
+ : >newfile &&
+ git add newfile &&
+ git commit -q -m "add small file" &&
+
+ git cherry-pick master >/dev/null 2>&1
+'
- test_expect_success $pr 'detect upstream patch' '
- git checkout -q master &&
- scramble file &&
- git add file &&
- git commit -q -m "change big file again" &&
- git checkout -q other^{} &&
- git rebase master &&
- git rev-list master...HEAD~ >revs &&
- test_must_be_empty revs
- '
+test_expect_success 'setup attributes' '
+ echo "file binary" >.gitattributes
+'
- test_expect_success $pr 'do not drop patch' '
- git branch -f squashed master &&
- git checkout -q -f squashed &&
- git reset -q --soft HEAD~2 &&
- git commit -q -m squashed &&
- git checkout -q other^{} &&
- test_must_fail git rebase squashed &&
- git rebase --quit
- '
-}
+test_expect_success 'detect upstream patch' '
+ git checkout -q master &&
+ scramble file &&
+ git add file &&
+ git commit -q -m "change big file again" &&
+ git checkout -q other^{} &&
+ git rebase master &&
+ git rev-list master...HEAD~ >revs &&
+ test_must_be_empty revs
+'
-do_tests 500
-do_tests 50000 EXPENSIVE
+test_expect_success 'do not drop patch' '
+ git branch -f squashed master &&
+ git checkout -q -f squashed &&
+ git reset -q --soft HEAD~2 &&
+ git commit -q -m squashed &&
+ git checkout -q other^{} &&
+ test_must_fail git rebase squashed &&
+ git rebase --quit
+'
test_done
diff --git a/t/t3431-rebase-fork-point.sh b/t/t3431-rebase-fork-point.sh
index 78851b9a2a..172562789e 100755
--- a/t/t3431-rebase-fork-point.sh
+++ b/t/t3431-rebase-fork-point.sh
@@ -47,11 +47,31 @@ test_rebase 'G F B A' --keep-base
test_rebase 'G F C E D B A' --no-fork-point
test_rebase 'G F C D B A' --no-fork-point --onto D
test_rebase 'G F C B A' --no-fork-point --keep-base
+
test_rebase 'G F E D B A' --fork-point refs/heads/master
+test_rebase 'G F E D B A' --fork-point master
+
test_rebase 'G F D B A' --fork-point --onto D refs/heads/master
+test_rebase 'G F D B A' --fork-point --onto D master
+
test_rebase 'G F B A' --fork-point --keep-base refs/heads/master
+test_rebase 'G F B A' --fork-point --keep-base master
+
test_rebase 'G F C E D B A' refs/heads/master
+test_rebase 'G F C E D B A' master
+
test_rebase 'G F C D B A' --onto D refs/heads/master
+test_rebase 'G F C D B A' --onto D master
+
test_rebase 'G F C B A' --keep-base refs/heads/master
+test_rebase 'G F C B A' --keep-base master
+
+test_expect_success 'git rebase --fork-point with ambigous refname' '
+ git checkout master &&
+ git checkout -b one &&
+ git checkout side &&
+ git tag one &&
+ test_must_fail git rebase --fork-point --onto D one
+'
test_done
diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh
index 6c9d4a1375..6f0452c0ea 100755
--- a/t/t3432-rebase-fast-forward.sh
+++ b/t/t3432-rebase-fast-forward.sh
@@ -28,10 +28,12 @@ test_rebase_same_head () {
shift &&
cmp_f="$1" &&
shift &&
- test_rebase_same_head_ $status_n $what_n $cmp_n " --apply" "$*" &&
- test_rebase_same_head_ $status_f $what_f $cmp_f " --apply --no-ff" "$*"
- test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" &&
- test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*"
+ test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --apply" "$*" &&
+ test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --apply --no-ff" "$*"
+ test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --merge" "$*" &&
+ test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --merge --no-ff" "$*"
+ test_rebase_same_head_ $status_n $what_n $cmp_n 1 " --merge" "$*" &&
+ test_rebase_same_head_ $status_f $what_f $cmp_f 1 " --merge --no-ff" "$*"
}
test_rebase_same_head_ () {
@@ -41,9 +43,21 @@ test_rebase_same_head_ () {
shift &&
cmp="$1" &&
shift &&
+ abbreviate="$1" &&
+ shift &&
flag="$1"
shift &&
- test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
+ if test $abbreviate -eq 1
+ then
+ msg="git rebase$flag $* (rebase.abbreviateCommands = true) with $changes is $what with $cmp HEAD"
+ else
+ msg="git rebase$flag $* with $changes is $what with $cmp HEAD"
+ fi &&
+ test_expect_$status "$msg" "
+ if test $abbreviate -eq 1
+ then
+ test_config rebase.abbreviateCommands true
+ fi &&
oldhead=\$(git rev-parse HEAD) &&
test_when_finished 'git reset --hard \$oldhead' &&
cp .git/logs/HEAD expect &&
diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index 9bd482ce3b..752bc43487 100755
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -161,6 +161,29 @@ test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
'
+
+test_expect_success 'partial commit of cherry-pick fails' '
+ pristine_detach initial &&
+
+ test_must_fail git cherry-pick picked &&
+ echo resolved >foo &&
+ git add foo &&
+ test_must_fail git commit foo 2>err &&
+
+ test_i18ngrep "cannot do a partial commit during a cherry-pick." err
+'
+
+test_expect_success 'commit --amend of cherry-pick fails' '
+ pristine_detach initial &&
+
+ test_must_fail git cherry-pick picked &&
+ echo resolved >foo &&
+ git add foo &&
+ test_must_fail git commit --amend 2>err &&
+
+ test_i18ngrep "in the middle of a cherry-pick -- cannot amend." err
+'
+
test_expect_success 'successful final commit clears cherry-pick state' '
pristine_detach initial &&
diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
index 793bcc7fe3..5b94fdaa67 100755
--- a/t/t3510-cherry-pick-sequence.sh
+++ b/t/t3510-cherry-pick-sequence.sh
@@ -123,7 +123,8 @@ test_expect_success 'revert --skip to skip commit' '
test_expect_success 'skip "empty" commit' '
pristine_detach picked &&
test_commit dummy foo d &&
- test_must_fail git cherry-pick anotherpick &&
+ test_must_fail git cherry-pick anotherpick 2>err &&
+ test_i18ngrep "git cherry-pick --skip" err &&
git cherry-pick --skip &&
test_cmp_rev dummy HEAD
'
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 88bc799807..b7d4ba608c 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -192,7 +192,7 @@ test_expect_success 'git add --refresh with pathspec' '
test_must_be_empty actual &&
git diff-files --name-only >actual &&
- ! grep bar actual&&
+ ! grep bar actual &&
grep baz actual
'
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 5bae6e50f1..b3d8bb7577 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -780,7 +780,7 @@ test_expect_success 'add -p patch editing works with pathological context lines'
test_expect_success 'checkout -p works with pathological context lines' '
test_write_lines a a a a a a >a &&
git add a &&
- test_write_lines a b a b a b a b a b a > a&&
+ test_write_lines a b a b a b a b a b a >a &&
test_write_lines s n n y q | git checkout -p &&
test_write_lines a b a b a a b a b a >expect &&
test_cmp expect a
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 3ad23e2502..9f7ca98967 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -1290,4 +1290,18 @@ test_expect_success 'stash handles skip-worktree entries nicely' '
git rev-parse --verify refs/stash:A.t
'
+test_expect_success 'stash -c stash.useBuiltin=false warning ' '
+ expected="stash.useBuiltin support has been removed" &&
+
+ git -c stash.useBuiltin=false stash 2>err &&
+ test_i18ngrep "$expected" err &&
+ env GIT_TEST_STASH_USE_BUILTIN=false git stash 2>err &&
+ test_i18ngrep "$expected" err &&
+
+ git -c stash.useBuiltin=true stash 2>err &&
+ test_must_be_empty err &&
+ env GIT_TEST_STASH_USE_BUILTIN=true git stash 2>err &&
+ test_must_be_empty err
+'
+
test_done
diff --git a/t/t4057-diff-combined-paths.sh b/t/t4057-diff-combined-paths.sh
index 4f4b541658..0b78573733 100755
--- a/t/t4057-diff-combined-paths.sh
+++ b/t/t4057-diff-combined-paths.sh
@@ -14,7 +14,7 @@ diffc_verify () {
test_expect_success 'trivial merge - combine-diff empty' '
for i in $(test_seq 1 9)
do
- echo $i >$i.txt &&
+ echo $i >$i.txt &&
git add $i.txt
done &&
git commit -m "init" &&
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index cb45271457..bda4586a79 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -166,7 +166,7 @@ test_expect_success setup '
test_tick &&
git commit -m third &&
- git format-patch --stdout first >patch2 &&
+ git format-patch --stdout first >patch2 &&
git checkout -b lorem &&
sed -n -e "11,\$p" msg >file &&
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 0f766ba65f..5eeb739f3e 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -1627,6 +1627,66 @@ test_expect_success GPG 'log --graph --show-signature for merged tag in shallow
grep "tag signed_tag_shallow names a non-parent $hash" actual
'
+test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
+ test_when_finished "git reset --hard && git checkout master" &&
+ git checkout -b plain-nokey master &&
+ echo aaa >bar &&
+ git add bar &&
+ git commit -m bar_commit &&
+ git checkout -b tagged-nokey master &&
+ echo bbb >baz &&
+ git add baz &&
+ git commit -m baz_commit &&
+ git tag -s -m signed_tag_msg signed_tag_nokey &&
+ git checkout plain-nokey &&
+ git merge --no-ff -m msg signed_tag_nokey &&
+ GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
+ grep "^|\\\ merged tag" actual &&
+ grep "^| | gpg: Signature made" actual &&
+ grep "^| | gpg: Can'"'"'t check signature: \(public key not found\|No public key\)" actual
+'
+
+test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
+ test_when_finished "git reset --hard && git checkout master" &&
+ git checkout -b plain-bad master &&
+ echo aaa >bar &&
+ git add bar &&
+ git commit -m bar_commit &&
+ git checkout -b tagged-bad master &&
+ echo bbb >baz &&
+ git add baz &&
+ git commit -m baz_commit &&
+ git tag -s -m signed_tag_msg signed_tag_bad &&
+ git cat-file tag signed_tag_bad >raw &&
+ sed -e "s/signed_tag_msg/forged/" raw >forged &&
+ git hash-object -w -t tag forged >forged.tag &&
+ git checkout plain-bad &&
+ git merge --no-ff -m msg "$(cat forged.tag)" &&
+ git log --graph --show-signature -n1 plain-bad >actual &&
+ grep "^|\\\ merged tag" actual &&
+ grep "^| | gpg: Signature made" actual &&
+ grep "^| | gpg: BAD signature from" actual
+'
+
+test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
+ test_when_finished "git reset --hard && git checkout master" &&
+ git checkout -b plain-fail master &&
+ echo aaa >bar &&
+ git add bar &&
+ git commit -m bar_commit &&
+ git checkout -b tagged-fail master &&
+ echo bbb >baz &&
+ git add baz &&
+ git commit -m baz_commit &&
+ git tag -s -m signed_tag_msg signed_tag_fail &&
+ git checkout plain-fail &&
+ git merge --no-ff -m msg signed_tag_fail &&
+ TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
+ grep "^merged tag" actual &&
+ grep "^No signature" actual &&
+ ! grep "^gpg: Signature made" actual
+'
+
test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
test_when_finished "git reset --hard && git checkout master" &&
test_config gpg.format x509 &&
@@ -1648,6 +1708,51 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
grep "^| | gpgsm: Good signature" actual
'
+test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
+ test_when_finished "git reset --hard && git checkout master" &&
+ test_config gpg.format x509 &&
+ test_config user.signingkey $GIT_COMMITTER_EMAIL &&
+ git checkout -b plain-x509-nokey master &&
+ echo aaa >bar &&
+ git add bar &&
+ git commit -m bar_commit &&
+ git checkout -b tagged-x509-nokey master &&
+ echo bbb >baz &&
+ git add baz &&
+ git commit -m baz_commit &&
+ git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
+ git checkout plain-x509-nokey &&
+ git merge --no-ff -m msg signed_tag_x509_nokey &&
+ GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
+ grep "^|\\\ merged tag" actual &&
+ grep "^| | gpgsm: certificate not found" actual
+'
+
+test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
+ test_when_finished "git reset --hard && git checkout master" &&
+ test_config gpg.format x509 &&
+ test_config user.signingkey $GIT_COMMITTER_EMAIL &&
+ git checkout -b plain-x509-bad master &&
+ echo aaa >bar &&
+ git add bar &&
+ git commit -m bar_commit &&
+ git checkout -b tagged-x509-bad master &&
+ echo bbb >baz &&
+ git add baz &&
+ git commit -m baz_commit &&
+ git tag -s -m signed_tag_msg signed_tag_x509_bad &&
+ git cat-file tag signed_tag_x509_bad >raw &&
+ sed -e "s/signed_tag_msg/forged/" raw >forged &&
+ git hash-object -w -t tag forged >forged.tag &&
+ git checkout plain-x509-bad &&
+ git merge --no-ff -m msg "$(cat forged.tag)" &&
+ git log --graph --show-signature -n1 plain-x509-bad >actual &&
+ grep "^|\\\ merged tag" actual &&
+ grep "^| | gpgsm: Signature made" actual &&
+ grep "^| | gpgsm: invalid signature" actual
+'
+
+
test_expect_success GPG '--no-show-signature overrides --show-signature' '
git log -1 --show-signature --no-show-signature signed >actual &&
! grep "^gpg:" actual
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index 43a7a66c9d..22240fd30b 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -42,10 +42,15 @@ test_expect_success 'setup' '
EOF
'
-test_expect_success 'write midx with no packs' '
- test_when_finished rm -f pack/multi-pack-index &&
- git multi-pack-index --object-dir=. write &&
- midx_read_expect 0 0 4 .
+test_expect_success "don't write midx with no packs" '
+ test_must_fail git multi-pack-index --object-dir=. write &&
+ test_path_is_missing pack/multi-pack-index
+'
+
+test_expect_success "Warn if a midx contains no oid" '
+ cp "$TEST_DIRECTORY"/t5319/no-objects.midx $objdir/pack/multi-pack-index &&
+ test_must_fail git multi-pack-index verify &&
+ rm $objdir/pack/multi-pack-index
'
generate_objects () {
diff --git a/t/t5319/no-objects.midx b/t/t5319/no-objects.midx
new file mode 100644
index 0000000000..e466b8e086
--- /dev/null
+++ b/t/t5319/no-objects.midx
Binary files differ
diff --git a/t/t5322-pack-objects-sparse.sh b/t/t5322-pack-objects-sparse.sh
index 7124b5581a..a581eaf529 100755
--- a/t/t5322-pack-objects-sparse.sh
+++ b/t/t5322-pack-objects-sparse.sh
@@ -105,14 +105,16 @@ test_expect_success 'non-sparse pack-objects' '
test_cmp required_objects.txt nonsparse_required_objects.txt
'
+# --sparse is enabled by default by pack.useSparse
test_expect_success 'sparse pack-objects' '
+ GIT_TEST_PACK_SPARSE=-1 &&
git rev-parse \
topic1 \
topic1^{tree} \
topic1:f3 \
topic1:f3/f4 \
topic1:f3/f4/data.txt | sort >expect_sparse_objects.txt &&
- git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
+ git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
git index-pack -o sparse.idx sparse.pack &&
git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
test_cmp expect_sparse_objects.txt sparse_objects.txt
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 04b35402c7..e98c3a0174 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -4,6 +4,14 @@ test_description='git ls-remote'
. ./test-lib.sh
+generate_references () {
+ for ref
+ do
+ oid=$(git rev-parse "$ref") &&
+ printf '%s\t%s\n' "$oid" "$ref" || return 1
+ done
+}
+
test_expect_success setup '
>file &&
git add file &&
@@ -13,11 +21,11 @@ test_expect_success setup '
git tag mark1.1 &&
git tag mark1.2 &&
git tag mark1.10 &&
- git show-ref --tags -d | sed -e "s/ / /" >expected.tag &&
- (
- echo "$(git rev-parse HEAD) HEAD" &&
- git show-ref -d | sed -e "s/ / /"
- ) >expected.all &&
+ git show-ref --tags -d >expected.tag.raw &&
+ sed -e "s/ / /" expected.tag.raw >expected.tag &&
+ generate_references HEAD >expected.all &&
+ git show-ref -d >refs &&
+ sed -e "s/ / /" refs >>expected.all &&
git remote add self "$(pwd)/.git"
'
@@ -43,34 +51,31 @@ test_expect_success 'ls-remote self' '
'
test_expect_success 'ls-remote --sort="version:refname" --tags self' '
- cat >expect <<-EOF &&
- $(git rev-parse mark) refs/tags/mark
- $(git rev-parse mark1.1) refs/tags/mark1.1
- $(git rev-parse mark1.2) refs/tags/mark1.2
- $(git rev-parse mark1.10) refs/tags/mark1.10
- EOF
+ generate_references \
+ refs/tags/mark \
+ refs/tags/mark1.1 \
+ refs/tags/mark1.2 \
+ refs/tags/mark1.10 >expect &&
git ls-remote --sort="version:refname" --tags self >actual &&
test_cmp expect actual
'
test_expect_success 'ls-remote --sort="-version:refname" --tags self' '
- cat >expect <<-EOF &&
- $(git rev-parse mark1.10) refs/tags/mark1.10
- $(git rev-parse mark1.2) refs/tags/mark1.2
- $(git rev-parse mark1.1) refs/tags/mark1.1
- $(git rev-parse mark) refs/tags/mark
- EOF
+ generate_references \
+ refs/tags/mark1.10 \
+ refs/tags/mark1.2 \
+ refs/tags/mark1.1 \
+ refs/tags/mark >expect &&
git ls-remote --sort="-version:refname" --tags self >actual &&
test_cmp expect actual
'
test_expect_success 'ls-remote --sort="-refname" --tags self' '
- cat >expect <<-EOF &&
- $(git rev-parse mark1.2) refs/tags/mark1.2
- $(git rev-parse mark1.10) refs/tags/mark1.10
- $(git rev-parse mark1.1) refs/tags/mark1.1
- $(git rev-parse mark) refs/tags/mark
- EOF
+ generate_references \
+ refs/tags/mark1.2 \
+ refs/tags/mark1.10 \
+ refs/tags/mark1.1 \
+ refs/tags/mark >expect &&
git ls-remote --sort="-refname" --tags self >actual &&
test_cmp expect actual
'
@@ -92,7 +97,7 @@ test_expect_success 'use "origin" when no remote specified' '
test_expect_success 'suppress "From <url>" with -q' '
git ls-remote -q 2>actual_err &&
- test_must_fail test_cmp exp_err actual_err
+ ! test_cmp exp_err actual_err
'
test_expect_success 'use branch.<name>.remote if possible' '
@@ -180,8 +185,8 @@ do
test_config $configsection.hiderefs refs/tags &&
git ls-remote . >actual &&
test_unconfig $configsection.hiderefs &&
- git ls-remote . |
- sed -e "/ refs\/tags\//d" >expect &&
+ git ls-remote . >expect.raw &&
+ sed -e "/ refs\/tags\//d" expect.raw >expect &&
test_cmp expect actual
'
@@ -212,17 +217,18 @@ test_expect_success 'protocol v2 supports hiderefs' '
test_expect_success 'ls-remote --symref' '
git fetch origin &&
- cat >expect <<-EOF &&
- ref: refs/heads/master HEAD
- $(git rev-parse HEAD) HEAD
- $(git rev-parse refs/heads/master) refs/heads/master
- $(git rev-parse HEAD) refs/remotes/origin/HEAD
- $(git rev-parse refs/remotes/origin/master) refs/remotes/origin/master
- $(git rev-parse refs/tags/mark) refs/tags/mark
- $(git rev-parse refs/tags/mark1.1) refs/tags/mark1.1
- $(git rev-parse refs/tags/mark1.10) refs/tags/mark1.10
- $(git rev-parse refs/tags/mark1.2) refs/tags/mark1.2
- EOF
+ echo "ref: refs/heads/master HEAD" >expect &&
+ generate_references \
+ HEAD \
+ refs/heads/master >>expect &&
+ oid=$(git rev-parse HEAD) &&
+ echo "$oid refs/remotes/origin/HEAD" >>expect &&
+ generate_references \
+ refs/remotes/origin/master \
+ refs/tags/mark \
+ refs/tags/mark1.1 \
+ refs/tags/mark1.10 \
+ refs/tags/mark1.2 >>expect &&
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# protocol v0 here.
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index ccde8ba491..159afa7ac8 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -11,10 +11,10 @@ test_expect_success 'setup' '
git commit -m one)
'
-test_expect_success 'git pull -q' '
+test_expect_success 'git pull -q --no-rebase' '
mkdir clonedq &&
(cd clonedq && git init &&
- git pull -q "../parent" >out 2>err &&
+ git pull -q --no-rebase "../parent" >out 2>err &&
test_must_be_empty err &&
test_must_be_empty out)
'
@@ -30,10 +30,10 @@ test_expect_success 'git pull -q --rebase' '
test_must_be_empty out)
'
-test_expect_success 'git pull' '
+test_expect_success 'git pull --no-rebase' '
mkdir cloned &&
(cd cloned && git init &&
- git pull "../parent" >out 2>err &&
+ git pull --no-rebase "../parent" >out 2>err &&
test -s err &&
test_must_be_empty out)
'
@@ -46,10 +46,10 @@ test_expect_success 'git pull --rebase' '
test_must_be_empty out)
'
-test_expect_success 'git pull -v' '
+test_expect_success 'git pull -v --no-rebase' '
mkdir clonedv &&
(cd clonedv && git init &&
- git pull -v "../parent" >out 2>err &&
+ git pull -v --no-rebase "../parent" >out 2>err &&
test -s err &&
test_must_be_empty out)
'
@@ -62,25 +62,25 @@ test_expect_success 'git pull -v --rebase' '
test_must_be_empty out)
'
-test_expect_success 'git pull -v -q' '
+test_expect_success 'git pull -v -q --no-rebase' '
mkdir clonedvq &&
(cd clonedvq && git init &&
- git pull -v -q "../parent" >out 2>err &&
+ git pull -v -q --no-rebase "../parent" >out 2>err &&
test_must_be_empty out &&
test_must_be_empty err)
'
-test_expect_success 'git pull -q -v' '
+test_expect_success 'git pull -q -v --no-rebase' '
mkdir clonedqv &&
(cd clonedqv && git init &&
- git pull -q -v "../parent" >out 2>err &&
+ git pull -q -v --no-rebase "../parent" >out 2>err &&
test_must_be_empty out &&
test -s err)
'
test_expect_success 'git pull --cleanup errors early on invalid argument' '
mkdir clonedcleanup &&
(cd clonedcleanup && git init &&
- test_must_fail git pull --cleanup invalid "../parent" >out 2>err &&
+ test_must_fail git pull --no-rebase --cleanup invalid "../parent" >out 2>err &&
test_must_be_empty out &&
test -s err)
'
diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index 4f681dbbe1..b57209c84f 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -131,7 +131,7 @@ test_expect_success 'fetch that requires changes in .git/shallow is filtered' '
git init notshallow &&
(
cd notshallow &&
- git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/*&&
+ git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
git for-each-ref --format="%(refname)" >actual.refs &&
cat <<EOF >expect.refs &&
refs/remotes/shallow/no-shallow
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index b811d89cfd..50485300eb 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -248,9 +248,7 @@ test_expect_success 'fetch can handle previously-fetched .idx files' '
'
test_expect_success 'did not use upload-pack service' '
- test_might_fail grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act &&
- : >exp &&
- test_cmp exp act
+ ! grep "/git-upload-pack" "$HTTPD_ROOT_PATH/access.log"
'
test_expect_success 'git client shows text/plain errors' '
@@ -321,11 +319,17 @@ test_expect_success 'git client does not send an empty Accept-Language' '
'
test_expect_success 'remote-http complains cleanly about malformed urls' '
- # do not actually issue "list" or other commands, as we do not
- # want to rely on what curl would actually do with such a broken
- # URL. This is just about making sure we do not segfault during
- # initialization.
- test_must_fail git remote-http http::/example.com/repo.git
+ test_must_fail git remote-http http::/example.com/repo.git 2>stderr &&
+ test_i18ngrep "url has no scheme" stderr
+'
+
+# NEEDSWORK: Writing commands to git-remote-curl can race against the latter
+# erroring out, producing SIGPIPE. Remove "ok=sigpipe" once transport-helper has
+# learned to handle early remote helper failures more cleanly.
+test_expect_success 'remote-http complains cleanly about empty scheme' '
+ test_must_fail ok=sigpipe git ls-remote \
+ http::${HTTPD_URL#http}/dumb/repo.git 2>stderr &&
+ test_i18ngrep "url has no scheme" stderr
'
test_expect_success 'redirects can be forbidden/allowed' '
diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh
index 4a110b307e..3f4ac71f83 100755
--- a/t/t5562-http-backend-content-length.sh
+++ b/t/t5562-http-backend-content-length.sh
@@ -53,15 +53,20 @@ test_expect_success 'setup' '
test_commit c1 &&
hash_head=$(git rev-parse HEAD) &&
hash_prev=$(git rev-parse HEAD~1) &&
- printf "want %s" "$hash_head" | packetize >fetch_body &&
- printf 0000 >>fetch_body &&
- printf "have %s" "$hash_prev" | packetize >>fetch_body &&
- printf done | packetize >>fetch_body &&
+ {
+ packetize "want $hash_head" &&
+ printf 0000 &&
+ packetize "have $hash_prev" &&
+ packetize "done"
+ } >fetch_body &&
test_copy_bytes 10 <fetch_body >fetch_body.trunc &&
hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) &&
- printf "%s %s refs/heads/newbranch\\0report-status\\n" "$ZERO_OID" "$hash_next" | packetize >push_body &&
- printf 0000 >>push_body &&
- echo "$hash_next" | git pack-objects --stdout >>push_body &&
+ {
+ printf "%s %s refs/heads/newbranch\\0report-status\\n" \
+ "$ZERO_OID" "$hash_next" | packetize &&
+ printf 0000 &&
+ echo "$hash_next" | git pack-objects --stdout
+ } >push_body &&
test_copy_bytes 10 <push_body >push_body.trunc &&
: >empty_body
'
diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh
index 0c74b4e21a..2f7be23044 100755
--- a/t/t5604-clone-reference.sh
+++ b/t/t5604-clone-reference.sh
@@ -175,7 +175,7 @@ test_expect_success 'clone using repo pointed at by gitfile as reference' '
test_expect_success 'clone and dissociate from reference' '
git init P &&
(
- cd P && test_commit one
+ cd P && test_commit one
) &&
git clone P Q &&
(
diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh
index 9108ff6fbd..6d5a977fcb 100755
--- a/t/t5607-clone-bundle.sh
+++ b/t/t5607-clone-bundle.sh
@@ -16,7 +16,7 @@ test_expect_success 'setup' '
test_expect_success '"verify" needs a worktree' '
git bundle create tip.bundle -1 master &&
- test_must_fail nongit git bundle verify ../tip.bundle 2>err &&
+ nongit test_must_fail git bundle verify ../tip.bundle 2>err &&
test_i18ngrep "need a repository" err
'
diff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh
index e36ac01661..e3b436d8ae 100755
--- a/t/t5612-clone-refspec.sh
+++ b/t/t5612-clone-refspec.sh
@@ -71,9 +71,9 @@ test_expect_success 'by default all branches will be kept updated' '
(
cd dir_all &&
git fetch &&
- git for-each-ref refs/remotes/origin |
+ git for-each-ref refs/remotes/origin >refs &&
sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
+ -e "s|/remotes/origin/|/heads/|" refs >../actual
) &&
# follow both master and side
git for-each-ref refs/heads >expect &&
@@ -87,7 +87,7 @@ test_expect_success 'by default no tags will be kept updated' '
git for-each-ref refs/tags >../actual
) &&
git for-each-ref refs/tags >expect &&
- test_must_fail test_cmp expect actual &&
+ ! test_cmp expect actual &&
test_line_count = 2 actual
'
@@ -104,9 +104,9 @@ test_expect_success '--single-branch while HEAD pointing at master' '
(
cd dir_master &&
git fetch --force &&
- git for-each-ref refs/remotes/origin |
+ git for-each-ref refs/remotes/origin >refs &&
sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
+ -e "s|/remotes/origin/|/heads/|" refs >../actual
) &&
# only follow master
git for-each-ref refs/heads/master >expect &&
@@ -126,9 +126,9 @@ test_expect_success '--single-branch while HEAD pointing at master and --no-tags
(
cd dir_master_no_tags &&
git fetch &&
- git for-each-ref refs/remotes/origin |
+ git for-each-ref refs/remotes/origin >refs &&
sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
+ -e "s|/remotes/origin/|/heads/|" refs >../actual
) &&
# only follow master
git for-each-ref refs/heads/master >expect &&
@@ -156,9 +156,9 @@ test_expect_success '--single-branch while HEAD pointing at side' '
(
cd dir_side &&
git fetch &&
- git for-each-ref refs/remotes/origin |
+ git for-each-ref refs/remotes/origin >refs &&
sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
+ -e "s|/remotes/origin/|/heads/|" refs >../actual
) &&
# only follow side
git for-each-ref refs/heads/side >expect &&
@@ -169,9 +169,9 @@ test_expect_success '--single-branch with explicit --branch side' '
(
cd dir_side2 &&
git fetch &&
- git for-each-ref refs/remotes/origin |
+ git for-each-ref refs/remotes/origin >refs &&
sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
+ -e "s|/remotes/origin/|/heads/|" refs >../actual
) &&
# only follow side
git for-each-ref refs/heads/side >expect &&
@@ -223,9 +223,9 @@ test_expect_success '--single-branch with detached' '
(
cd dir_detached &&
git fetch &&
- git for-each-ref refs/remotes/origin |
+ git for-each-ref refs/remotes/origin >refs &&
sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
+ -e "s|/remotes/origin/|/heads/|" refs >../actual
) &&
# nothing
test_must_be_empty actual
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 77bb91e976..8f0d81a27e 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -415,6 +415,14 @@ test_expect_success 'verify fetch downloads only one pack when updating refs' '
test_line_count = 3 pack-list
'
+test_expect_success 'single-branch tag following respects partial clone' '
+ git clone --single-branch -b B --filter=blob:none \
+ "file://$(pwd)/srv.bare" single &&
+ git -C single rev-parse --verify refs/tags/B &&
+ git -C single rev-parse --verify refs/tags/A &&
+ test_must_fail git -C single rev-parse --verify refs/tags/C
+'
+
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
diff --git a/t/t5704-protocol-violations.sh b/t/t5704-protocol-violations.sh
new file mode 100755
index 0000000000..950cfb21fe
--- /dev/null
+++ b/t/t5704-protocol-violations.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+test_description='Test responses to violations of the network protocol. In most
+of these cases it will generally be acceptable for one side to break off
+communications if the other side says something unexpected. We are mostly
+making sure that we do not segfault or otherwise behave badly.'
+. ./test-lib.sh
+
+test_expect_success 'extra delim packet in v2 ls-refs args' '
+ {
+ packetize command=ls-refs &&
+ printf 0001 &&
+ # protocol expects 0000 flush here
+ printf 0001
+ } >input &&
+ test_must_fail env GIT_PROTOCOL=version=2 \
+ git upload-pack . <input 2>err &&
+ test_i18ngrep "expected flush after ls-refs arguments" err
+'
+
+test_expect_success 'extra delim packet in v2 fetch args' '
+ {
+ packetize command=fetch &&
+ printf 0001 &&
+ # protocol expects 0000 flush here
+ printf 0001
+ } >input &&
+ test_must_fail env GIT_PROTOCOL=version=2 \
+ git upload-pack . <input 2>err &&
+ test_i18ngrep "expected flush after fetch arguments" err
+'
+
+test_done
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 121e5c6edb..0f04b6cddb 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -11,9 +11,15 @@ test_description='Test remote-helper import and export commands'
PATH="$TEST_DIRECTORY/t5801:$PATH"
compare_refs() {
+ fail= &&
+ if test "x$1" = 'x!'
+ then
+ fail='!' &&
+ shift
+ fi &&
git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
- test_cmp expect actual
+ eval $fail test_cmp expect actual
}
test_expect_success 'setup repository' '
@@ -189,7 +195,7 @@ test_expect_success GPG 'push signed tag' '
git push origin signed-tag
) &&
compare_refs local signed-tag^{} server signed-tag^{} &&
- test_must_fail compare_refs local signed-tag server signed-tag
+ compare_refs ! local signed-tag server signed-tag
'
test_expect_success GPG 'push signed tag with signed-tags capability' '
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 34502e3a50..f822d5d328 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -129,12 +129,30 @@ test_expect_success 'rename tag A to Q locally' '
mv .git/refs/tags/A .git/refs/tags/Q
'
cat - >err.expect <<EOF
-warning: tag 'A' is really 'Q' here
+warning: tag 'Q' is externally known as 'A'
EOF
check_describe A-* HEAD
test_expect_success 'warning was displayed for Q' '
test_i18ncmp err.expect err.actual
'
+test_expect_success 'misnamed annotated tag forces long output' '
+ description=$(git describe --no-long Q^0) &&
+ expr "$description" : "A-0-g[0-9a-f]*$" &&
+ git rev-parse --verify "$description" >actual &&
+ git rev-parse --verify Q^0 >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'abbrev=0 will not break misplaced tag (1)' '
+ description=$(git describe --abbrev=0 Q^0) &&
+ expr "$description" : "A-0-g[0-9a-f]*$"
+'
+
+test_expect_success 'abbrev=0 will not break misplaced tag (2)' '
+ description=$(git describe --abbrev=0 c^0) &&
+ expr "$description" : "A-1-g[0-9a-f]*$"
+'
+
test_expect_success 'rename tag Q back to A' '
mv .git/refs/tags/Q .git/refs/tags/A
'
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 8a72b4c43a..b15582a7a2 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -6,6 +6,7 @@
test_description='fmt-merge-msg test'
. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-gpg.sh"
test_expect_success setup '
echo one >one &&
@@ -73,6 +74,10 @@ test_expect_success setup '
apos="'\''"
'
+test_expect_success GPG 'set up a signed tag' '
+ git tag -s -m signed-tag-msg signed-good-tag left
+'
+
test_expect_success 'message for merging local branch' '
echo "Merge branch ${apos}left${apos}" >expected &&
@@ -83,6 +88,24 @@ test_expect_success 'message for merging local branch' '
test_cmp expected actual
'
+test_expect_success GPG 'message for merging local tag signed by good key' '
+ git checkout master &&
+ git fetch . signed-good-tag &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual 2>&1 &&
+ grep "^Merge tag ${apos}signed-good-tag${apos}" actual &&
+ grep "^# gpg: Signature made" actual &&
+ grep "^# gpg: Good signature from" actual
+'
+
+test_expect_success GPG 'message for merging local tag signed by unknown key' '
+ git checkout master &&
+ git fetch . signed-good-tag &&
+ GNUPGHOME=. git fmt-merge-msg <.git/FETCH_HEAD >actual 2>&1 &&
+ grep "^Merge tag ${apos}signed-good-tag${apos}" actual &&
+ grep "^# gpg: Signature made" actual &&
+ grep "^# gpg: Can${apos}t check signature: \(public key not found\|No public key\)" actual
+'
+
test_expect_success 'message for merging external branch' '
echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 9c910ce746..b3c1092338 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -20,6 +20,10 @@ setdate_and_increment () {
}
test_expect_success setup '
+ test_oid_cache <<-EOF &&
+ disklen sha1:138
+ disklen sha256:154
+ EOF
setdate_and_increment &&
echo "Using $datestamp" > one &&
git add one &&
@@ -50,6 +54,9 @@ test_atom() {
"
}
+hexlen=$(test_oid hexsz)
+disklen=$(test_oid disklen)
+
test_atom head refname refs/heads/master
test_atom head refname: refs/heads/master
test_atom head refname:short master
@@ -82,9 +89,9 @@ test_atom head push:rstrip=-1 refs
test_atom head push:strip=1 remotes/myfork/master
test_atom head push:strip=-1 master
test_atom head objecttype commit
-test_atom head objectsize 171
-test_atom head objectsize:disk 138
-test_atom head deltabase 0000000000000000000000000000000000000000
+test_atom head objectsize $((131 + hexlen))
+test_atom head objectsize:disk $disklen
+test_atom head deltabase $ZERO_OID
test_atom head objectname $(git rev-parse refs/heads/master)
test_atom head objectname:short $(git rev-parse --short refs/heads/master)
test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
@@ -125,11 +132,11 @@ test_atom tag refname:short testtag
test_atom tag upstream ''
test_atom tag push ''
test_atom tag objecttype tag
-test_atom tag objectsize 154
-test_atom tag objectsize:disk 138
-test_atom tag '*objectsize:disk' 138
-test_atom tag deltabase 0000000000000000000000000000000000000000
-test_atom tag '*deltabase' 0000000000000000000000000000000000000000
+test_atom tag objectsize $((114 + hexlen))
+test_atom tag objectsize:disk $disklen
+test_atom tag '*objectsize:disk' $disklen
+test_atom tag deltabase $ZERO_OID
+test_atom tag '*deltabase' $ZERO_OID
test_atom tag objectname $(git rev-parse refs/tags/testtag)
test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
@@ -139,7 +146,7 @@ test_atom tag parent ''
test_atom tag numparent ''
test_atom tag object $(git rev-parse refs/tags/testtag^0)
test_atom tag type 'commit'
-test_atom tag '*objectname' 'ea122842f48be4afb2d1fc6a4b96c05885ab7463'
+test_atom tag '*objectname' $(git rev-parse refs/tags/testtag^{})
test_atom tag '*objecttype' 'commit'
test_atom tag author ''
test_atom tag authorname ''
@@ -643,7 +650,7 @@ test_atom refs/tags/signed-long contents "subject line
body contents
$sig"
-cat >expected <<EOF
+sort >expected <<EOF
$(git rev-parse refs/tags/bogo) <committer@example.com> refs/tags/bogo
$(git rev-parse refs/tags/master) <committer@example.com> refs/tags/master
EOF
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 6db92bd3ba..74b637deb2 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1726,6 +1726,7 @@ test_expect_success 'recursive tagging should give advice' '
hint: already a tag. If you meant to tag the object that it points to, use:
hint: |
hint: git tag -f nested annotated-v4.0^{}
+ hint: Disable this message with "git config advice.nestedTag false"
EOF
git tag -m nested nested annotated-v4.0 2>actual &&
test_i18ncmp expect actual
diff --git a/t/t7112-reset-submodule.sh b/t/t7112-reset-submodule.sh
index a1cb9ff858..67346424a5 100755
--- a/t/t7112-reset-submodule.sh
+++ b/t/t7112-reset-submodule.sh
@@ -5,7 +5,6 @@ test_description='reset can handle submodules'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-submodule-update.sh
-KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index e3e2aab3b0..956e17abb3 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -938,7 +938,7 @@ test_expect_success 'submodule add --name allows to replace a submodule with ano
echo "repo" >expect &&
test_must_fail git config -f .gitmodules submodule.repo.path &&
git config -f .gitmodules submodule.repo_new.path >actual &&
- test_cmp expect actual&&
+ test_cmp expect actual &&
echo "$submodurl/repo" >expect &&
test_must_fail git config -f .gitmodules submodule.repo.url &&
echo "$submodurl/bare.git" >expect &&
@@ -1010,7 +1010,7 @@ test_expect_success 'submodule add with an existing name fails unless forced' '
test -d repo &&
echo "repo" >expect &&
git config -f .gitmodules submodule.repo_new.path >actual &&
- test_cmp expect actual&&
+ test_cmp expect actual &&
echo "$submodurl/repo.git" >expect &&
git config -f .gitmodules submodule.repo_new.url >actual &&
test_cmp expect actual &&
diff --git a/t/t7416-submodule-dash-url.sh b/t/t7416-submodule-dash-url.sh
index 5ba041f537..eec96e0ba9 100755
--- a/t/t7416-submodule-dash-url.sh
+++ b/t/t7416-submodule-dash-url.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='check handling of .gitmodule url with dash'
+test_description='check handling of disallowed .gitmodule urls'
. ./test-lib.sh
test_expect_success 'create submodule with protected dash in url' '
@@ -60,4 +60,145 @@ test_expect_success 'trailing backslash is handled correctly' '
test_i18ngrep ! "unknown option" err
'
+test_expect_success 'fsck rejects missing URL scheme' '
+ git checkout --orphan missing-scheme &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = http::one.example.com/foo.git
+ EOF
+ git add .gitmodules &&
+ test_tick &&
+ git commit -m "gitmodules with missing URL scheme" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck rejects relative URL resolving to missing scheme' '
+ git checkout --orphan relative-missing-scheme &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = "..\\../.\\../:one.example.com/foo.git"
+ EOF
+ git add .gitmodules &&
+ test_tick &&
+ git commit -m "gitmodules with relative URL that strips off scheme" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck rejects empty URL scheme' '
+ git checkout --orphan empty-scheme &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = http::://one.example.com/foo.git
+ EOF
+ git add .gitmodules &&
+ test_tick &&
+ git commit -m "gitmodules with empty URL scheme" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck rejects relative URL resolving to empty scheme' '
+ git checkout --orphan relative-empty-scheme &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = ../../../:://one.example.com/foo.git
+ EOF
+ git add .gitmodules &&
+ test_tick &&
+ git commit -m "relative gitmodules URL resolving to empty scheme" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck rejects empty hostname' '
+ git checkout --orphan empty-host &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = http:///one.example.com/foo.git
+ EOF
+ git add .gitmodules &&
+ test_tick &&
+ git commit -m "gitmodules with extra slashes" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck rejects relative url that produced empty hostname' '
+ git checkout --orphan messy-relative &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = ../../..//one.example.com/foo.git
+ EOF
+ git add .gitmodules &&
+ test_tick &&
+ git commit -m "gitmodules abusing relative_path" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck permits embedded newline with unrecognized scheme' '
+ git checkout --orphan newscheme &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = "data://acjbkd%0akajfdickajkd"
+ EOF
+ git add .gitmodules &&
+ git commit -m "gitmodules with unrecognized scheme" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ git push dst HEAD
+'
+
+test_expect_success 'fsck rejects embedded newline in url' '
+ # create an orphan branch to avoid existing .gitmodules objects
+ git checkout --orphan newline &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = "https://one.example.com?%0ahost=two.example.com/foo.git"
+ EOF
+ git add .gitmodules &&
+ git commit -m "gitmodules with newline" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
+test_expect_success 'fsck rejects embedded newline in relative url' '
+ git checkout --orphan relative-newline &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = "./%0ahost=two.example.com/foo.git"
+ EOF
+ git add .gitmodules &&
+ git commit -m "relative url with newline" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
test_done
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 0c06d22a00..6baaa1ad91 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -6,6 +6,11 @@ GNUPGHOME_NOT_USED=$GNUPGHOME
. "$TEST_DIRECTORY/lib-gpg.sh"
test_expect_success GPG 'create signed commits' '
+ test_oid_cache <<-\EOF &&
+ header sha1:gpgsig
+ header sha256:gpgsig-sha256
+ EOF
+
test_when_finished "test_unconfig commit.gpgsign" &&
echo 1 >file && git add file &&
@@ -155,6 +160,11 @@ test_expect_success GPG 'verify signatures with --raw' '
)
'
+test_expect_success GPG 'proper header is used for hash algorithm' '
+ git cat-file commit fourth-signed >output &&
+ grep "^$(test_oid header) -----BEGIN PGP SIGNATURE-----" output
+'
+
test_expect_success GPG 'show signed commit with signature' '
git show -s initial >commit &&
git show -s --show-signature initial >show &&
@@ -162,7 +172,7 @@ test_expect_success GPG 'show signed commit with signature' '
git cat-file commit initial >cat &&
grep -v -e "gpg: " -e "Warning: " show >show.commit &&
grep -e "gpg: " -e "Warning: " show >show.gpg &&
- grep -v "^ " cat | grep -v "^gpgsig " >cat.commit &&
+ grep -v "^ " cat | grep -v "^$(test_oid header) " >cat.commit &&
test_cmp show.commit commit &&
test_cmp show.gpg verify.2 &&
test_cmp cat.commit verify.1
@@ -299,10 +309,10 @@ test_expect_success GPG 'check config gpg.format values' '
test_expect_success GPG 'detect fudged commit with double signature' '
sed -e "/gpgsig/,/END PGP/d" forged1 >double-base &&
sed -n -e "/gpgsig/,/END PGP/p" forged1 | \
- sed -e "s/^gpgsig//;s/^ //" | gpg --dearmor >double-sig1.sig &&
+ sed -e "s/^$(test_oid header)//;s/^ //" | gpg --dearmor >double-sig1.sig &&
gpg -o double-sig2.sig -u 29472784 --detach-sign double-base &&
cat double-sig1.sig double-sig2.sig | gpg --enarmor >double-combined.asc &&
- sed -e "s/^\(-.*\)ARMORED FILE/\1SIGNATURE/;1s/^/gpgsig /;2,\$s/^/ /" \
+ sed -e "s/^\(-.*\)ARMORED FILE/\1SIGNATURE/;1s/^/$(test_oid header) /;2,\$s/^/ /" \
double-combined.asc > double-gpgsig &&
sed -e "/committer/r double-gpgsig" double-base >double-commit &&
git hash-object -w -t commit double-commit >double-commit.commit &&
diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
index c6c44ec570..0f97828cd0 100755
--- a/t/t7601-merge-pull-config.sh
+++ b/t/t7601-merge-pull-config.sh
@@ -27,6 +27,44 @@ test_expect_success 'setup' '
git tag c3
'
+test_expect_success 'pull.rebase not set' '
+ git reset --hard c0 &&
+ git pull . c1 2>err &&
+ test_i18ngrep "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and pull.ff=false' '
+ git reset --hard c0 &&
+ test_config pull.ff false &&
+ git pull . c1 2>err &&
+ test_i18ngrep "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and pull.ff=only' '
+ git reset --hard c0 &&
+ test_config pull.ff only &&
+ git pull . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --rebase given' '
+ git reset --hard c0 &&
+ git pull --rebase . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --no-rebase given' '
+ git reset --hard c0 &&
+ git pull --no-rebase . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --ff-only given' '
+ git reset --hard c0 &&
+ git pull --ff-only . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
test_expect_success 'merge c1 with c2' '
git reset --hard c1 &&
test -f c0.c &&
diff --git a/t/t7609-merge-co-error-msgs.sh b/t/t7609-merge-co-error-msgs.sh
index e90413204e..5c8894d94f 100755
--- a/t/t7609-merge-co-error-msgs.sh
+++ b/t/t7609-merge-co-error-msgs.sh
@@ -126,7 +126,7 @@ test_expect_success 'not_uptodate_dir porcelain checkout error' '
git rm rep2 -r &&
>rep &&
>rep2 &&
- git add rep rep2&&
+ git add rep rep2 &&
git commit -m "added test as a file" &&
git checkout master &&
>rep/untracked-file &&
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
index c90fdc5c89..83f8f5cacb 100755
--- a/t/t9010-svn-fe.sh
+++ b/t/t9010-svn-fe.sh
@@ -486,7 +486,7 @@ test_expect_success 'NUL in property value' '
{
properties \
unimportant "something with a NUL (Q)" \
- svn:log "commit message"&&
+ svn:log "commit message" &&
echo PROPS-END
} |
q_to_nul >props &&
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 3e41c58a13..768257b29e 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3381,4 +3381,113 @@ test_expect_success 'X: handling encoding' '
git log -1 --format=%B encoding | grep $(printf "\317\200")
'
+###
+### series Y (submodules and hash algorithms)
+###
+
+cat >Y-sub-input <<\Y_INPUT_END
+blob
+mark :1
+data 4
+foo
+
+reset refs/heads/master
+commit refs/heads/master
+mark :2
+author Full Name <user@company.tld> 1000000000 +0100
+committer Full Name <user@company.tld> 1000000000 +0100
+data 24
+Test submodule commit 1
+M 100644 :1 file
+
+blob
+mark :3
+data 8
+foo
+bar
+
+commit refs/heads/master
+mark :4
+author Full Name <user@company.tld> 1000000001 +0100
+committer Full Name <user@company.tld> 1000000001 +0100
+data 24
+Test submodule commit 2
+from :2
+M 100644 :3 file
+Y_INPUT_END
+
+# Note that the submodule object IDs are intentionally not translated.
+cat >Y-main-input <<\Y_INPUT_END
+blob
+mark :1
+data 4
+foo
+
+reset refs/heads/master
+commit refs/heads/master
+mark :2
+author Full Name <user@company.tld> 2000000000 +0100
+committer Full Name <user@company.tld> 2000000000 +0100
+data 14
+Test commit 1
+M 100644 :1 file
+
+blob
+mark :3
+data 73
+[submodule "sub1"]
+ path = sub1
+ url = https://void.example.com/main.git
+
+commit refs/heads/master
+mark :4
+author Full Name <user@company.tld> 2000000001 +0100
+committer Full Name <user@company.tld> 2000000001 +0100
+data 14
+Test commit 2
+from :2
+M 100644 :3 .gitmodules
+M 160000 0712c5be7cf681388e355ef47525aaf23aee1a6d sub1
+
+blob
+mark :5
+data 8
+foo
+bar
+
+commit refs/heads/master
+mark :6
+author Full Name <user@company.tld> 2000000002 +0100
+committer Full Name <user@company.tld> 2000000002 +0100
+data 14
+Test commit 3
+from :4
+M 100644 :5 file
+M 160000 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 sub1
+Y_INPUT_END
+
+cat >Y-marks <<\Y_INPUT_END
+:2 0712c5be7cf681388e355ef47525aaf23aee1a6d
+:4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7
+Y_INPUT_END
+
+test_expect_success 'Y: setup' '
+ test_oid_cache <<-EOF
+ Ymaster sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
+ Ymaster sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3
+ EOF
+'
+
+test_expect_success 'Y: rewrite submodules' '
+ git init main1 &&
+ (
+ cd main1 &&
+ git init sub2 &&
+ git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
+ git fast-import --rewrite-submodules-from=sub:../Y-marks \
+ --rewrite-submodules-to=sub:sub2-marks <../Y-main-input &&
+ test "$(git rev-parse master)" = "$(test_oid Ymaster)"
+ )
+'
+
test_done
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index cc8d463e01..267ddc997d 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -53,7 +53,7 @@ test_expect_success \
test_expect_success \
'Make initial commit' \
- 'echo "Not an empty file." > file &&
+ 'echo "Not an empty file." >file &&
git add file &&
git commit -a -m "Initial commit." &&
git branch b'
@@ -139,7 +139,7 @@ test_expect_success \
test_expect_success \
'commitdiff(0): file added' \
- 'echo "New file" > new_file &&
+ 'echo "New file" >new_file &&
git add new_file &&
git commit -a -m "File added." &&
gitweb_run "p=.git;a=commitdiff"'
@@ -179,7 +179,7 @@ test_expect_success \
test_expect_success \
'commitdiff(0): mode change and modified' \
- 'echo "New line" >> file2 &&
+ 'echo "New line" >>file2 &&
test_chmod +x file2 &&
git commit -a -m "Mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"'
@@ -197,14 +197,14 @@ propter nomen suum.
EOF
git commit -a -m "File added." &&
git mv file2 file3 &&
- echo "Propter nomen suum." >> file3 &&
+ echo "Propter nomen suum." >>file3 &&
git commit -a -m "File rename and modification." &&
gitweb_run "p=.git;a=commitdiff"'
test_expect_success \
'commitdiff(0): renamed, mode change and modified' \
'git mv file3 file2 &&
- echo "Propter nomen suum." >> file2 &&
+ echo "Propter nomen suum." >>file2 &&
test_chmod +x file2 &&
git commit -a -m "File rename, mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"'
@@ -213,8 +213,8 @@ test_expect_success \
# commitdiff testing (taken from t4114-apply-typechange.sh)
test_expect_success 'setup typechange commits' '
- echo "hello world" > foo &&
- echo "hi planet" > bar &&
+ echo "hello world" >foo &&
+ echo "hi planet" >bar &&
git update-index --add foo bar &&
git commit -m initial &&
git branch initial &&
@@ -223,18 +223,18 @@ test_expect_success 'setup typechange commits' '
git commit -m "foo symlinked to bar" &&
git branch foo-symlinked-to-bar &&
rm -f foo &&
- echo "how far is the sun?" > foo &&
+ echo "how far is the sun?" >foo &&
git update-index foo &&
git commit -m "foo back to file" &&
git branch foo-back-to-file &&
rm -f foo &&
git update-index --remove foo &&
mkdir foo &&
- echo "if only I knew" > foo/baz &&
+ echo "if only I knew" >foo/baz &&
git update-index --add foo/baz &&
git commit -m "foo becomes a directory" &&
git branch "foo-becomes-a-directory" &&
- echo "hello world" > foo/baz &&
+ echo "hello world" >foo/baz &&
git update-index foo/baz &&
git commit -m "foo/baz is the original foo" &&
git branch foo-baz-renamed-from-foo
@@ -324,7 +324,7 @@ test_expect_success 'commitdiff(1): removal of incomplete line' '
test_expect_success \
'Create a merge' \
'git checkout b &&
- echo "Branch" >> b &&
+ echo "Branch" >>b &&
git add b &&
git commit -a -m "On branch" &&
git checkout master &&
@@ -342,26 +342,26 @@ test_expect_success \
test_expect_success \
'Prepare large commit' \
'git checkout b &&
- echo "To be changed" > 01-change &&
- echo "To be renamed" > 02-pure-rename-from &&
- echo "To be deleted" > 03-delete &&
- echo "To be renamed and changed" > 04-rename-from &&
- echo "To have mode changed" > 05-mode-change &&
- echo "File to symlink" > 06-file-or-symlink &&
- echo "To be changed and have mode changed" > 07-change-mode-change &&
+ echo "To be changed" >01-change &&
+ echo "To be renamed" >02-pure-rename-from &&
+ echo "To be deleted" >03-delete &&
+ echo "To be renamed and changed" >04-rename-from &&
+ echo "To have mode changed" >05-mode-change &&
+ echo "File to symlink" >06-file-or-symlink &&
+ echo "To be changed and have mode changed" >07-change-mode-change &&
git add 0* &&
git commit -a -m "Prepare large commit" &&
- echo "Changed" > 01-change &&
+ echo "Changed" >01-change &&
git mv 02-pure-rename-from 02-pure-rename-to &&
git rm 03-delete && rm -f 03-delete &&
- echo "A new file" > 03-new &&
+ echo "A new file" >03-new &&
git add 03-new &&
git mv 04-rename-from 04-rename-to &&
- echo "Changed" >> 04-rename-to &&
+ echo "Changed" >>04-rename-to &&
test_chmod +x 05-mode-change &&
rm -f 06-file-or-symlink &&
test_ln_s_add 01-change 06-file-or-symlink &&
- echo "Changed and have mode changed" > 07-change-mode-change &&
+ echo "Changed and have mode changed" >07-change-mode-change &&
test_chmod +x 07-change-mode-change &&
git commit -a -m "Large commit" &&
git checkout master'
@@ -444,7 +444,7 @@ test_expect_success \
test_expect_success \
'logs: history (implicit HEAD, deleted file)' \
'git checkout master &&
- echo "to be deleted" > deleted_file &&
+ echo "to be deleted" >deleted_file &&
git add deleted_file &&
git commit -m "Add file to be deleted" &&
git rm deleted_file &&
@@ -522,7 +522,7 @@ test_expect_success \
'. "$TEST_DIRECTORY"/t3901/utf8.txt &&
test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
- echo "UTF-8" >> file &&
+ echo "UTF-8" >>file &&
git add file &&
git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
gitweb_run "p=.git;a=commit"'
@@ -532,7 +532,7 @@ test_expect_success \
'. "$TEST_DIRECTORY"/t3901/8859-1.txt &&
test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
- echo "ISO-8859-1" >> file &&
+ echo "ISO-8859-1" >>file &&
git add file &&
test_config i18n.commitencoding ISO-8859-1 &&
git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
@@ -675,8 +675,8 @@ test_expect_success \
test_expect_success \
'README.html with non-ASCII characters (utf-8)' \
- 'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
- cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
+ 'echo "<b>UTF-8 example:</b><br />" >.git/README.html &&
+ cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >>.git/README.html &&
gitweb_run "p=.git;a=summary"'
# ----------------------------------------------------------------------
@@ -704,7 +704,7 @@ test_expect_success HIGHLIGHT \
test_expect_success HIGHLIGHT \
'syntax highlighting (highlighted, shell script)' \
'git config gitweb.highlight yes &&
- echo "#!/usr/bin/sh" > test.sh &&
+ echo "#!/usr/bin/sh" >test.sh &&
git add test.sh &&
git commit -m "Add test.sh" &&
gitweb_run "p=.git;a=blob;f=test.sh"'
@@ -712,7 +712,7 @@ test_expect_success HIGHLIGHT \
test_expect_success HIGHLIGHT \
'syntax highlighting (highlighter language autodetection)' \
'git config gitweb.highlight yes &&
- echo "#!/usr/bin/perl" > test &&
+ echo "#!/usr/bin/perl" >test &&
git add test &&
git commit -m "Add test" &&
gitweb_run "p=.git;a=blob;f=test"'
@@ -729,11 +729,11 @@ test_expect_success \
'git init --bare foo.git &&
git --git-dir=foo.git --work-tree=. add file &&
git --git-dir=foo.git --work-tree=. commit -m "Initial commit" &&
- echo "foo" > foo.git/description &&
+ echo "foo" >foo.git/description &&
mkdir -p foo &&
(cd foo &&
git clone --shared --bare ../foo.git foo-forked.git &&
- echo "fork of foo" > foo-forked.git/description)'
+ echo "fork of foo" >foo-forked.git/description)'
test_expect_success \
'forks: projects list' \
@@ -754,8 +754,8 @@ EOF
test_expect_success \
'ctags: tag cloud in projects list' \
'mkdir .git/ctags &&
- echo "2" > .git/ctags/foo &&
- echo "1" > .git/ctags/bar &&
+ echo "2" >.git/ctags/foo &&
+ echo "1" >.git/ctags/bar &&
gitweb_run'
test_expect_success \
@@ -769,8 +769,8 @@ test_expect_success \
test_expect_success \
'ctags: malformed tag weights' \
'mkdir -p .git/ctags &&
- echo "not-a-number" > .git/ctags/nan &&
- echo "not-a-number-2" > .git/ctags/nan2 &&
+ echo "not-a-number" >.git/ctags/nan &&
+ echo "not-a-number-2" >.git/ctags/nan2 &&
echo "0.1" >.git/ctags/floating-point &&
gitweb_run'
diff --git a/t/t9831-git-p4-triggers.sh b/t/t9831-git-p4-triggers.sh
index d743ca33ee..ff6c0352e6 100755
--- a/t/t9831-git-p4-triggers.sh
+++ b/t/t9831-git-p4-triggers.sh
@@ -58,7 +58,7 @@ test_expect_success 'import with extra info lines from verbose p4 trigger' '
(
cd "$git" &&
git p4 sync
- )&&
+ ) &&
(
p4 triggers -i <<-EOF
Triggers:
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 352c213d52..88b7dbd69a 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1362,14 +1362,22 @@ nongit () {
)
} 7>&2 2>&4
-# convert stdin to pktline representation; note that empty input becomes an
-# empty packet, not a flush packet (for that you can just print 0000 yourself).
+# convert function arguments or stdin (if not arguments given) to pktline
+# representation. If multiple arguments are given, they are separated by
+# whitespace and put in a single packet. Note that data containing NULs must be
+# given on stdin, and that empty input becomes an empty packet, not a flush
+# packet (for that you can just print 0000 yourself).
packetize() {
- cat >packetize.tmp &&
- len=$(wc -c <packetize.tmp) &&
- printf '%04x%s' "$(($len + 4))" &&
- cat packetize.tmp &&
- rm -f packetize.tmp
+ if test $# -gt 0
+ then
+ packet="$*"
+ printf '%04x%s' "$((4 + ${#packet}))" "$packet"
+ else
+ perl -e '
+ my $packet = do { local $/; <STDIN> };
+ printf "%04x%s", 4 + length($packet), $packet;
+ '
+ fi
}
# Parse the input as a series of pktlines, writing the result to stdout.
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0ea1e5a05e..0bb1105ec3 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -78,20 +78,23 @@ then
exit 1
fi
-# Parse options while taking care to leave $@ intact, so we will still
-# have all the original command line options when executing the test
-# script again for '--tee' and '--verbose-log' below.
store_arg_to=
-prev_opt=
-for opt
-do
- if test -n "$store_arg_to"
+opt_required_arg=
+# $1: option string
+# $2: name of the var where the arg will be stored
+mark_option_requires_arg () {
+ if test -n "$opt_required_arg"
then
- eval $store_arg_to=\$opt
- store_arg_to=
- prev_opt=
- continue
+ echo "error: options that require args cannot be bundled" \
+ "together: '$opt_required_arg' and '$1'" >&2
+ exit 1
fi
+ opt_required_arg=$1
+ store_arg_to=$2
+}
+
+parse_option () {
+ local opt="$1"
case "$opt" in
-d|--d|--de|--deb|--debu|--debug)
@@ -101,7 +104,7 @@ do
-l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)
GIT_TEST_LONG=t; export GIT_TEST_LONG ;;
-r)
- store_arg_to=run_list
+ mark_option_requires_arg "$opt" run_list
;;
--run=*)
run_list=${opt#--*=} ;;
@@ -185,12 +188,42 @@ do
*)
echo "error: unknown test option '$opt'" >&2; exit 1 ;;
esac
+}
- prev_opt=$opt
+# Parse options while taking care to leave $@ intact, so we will still
+# have all the original command line options when executing the test
+# script again for '--tee' and '--verbose-log' later.
+for opt
+do
+ if test -n "$store_arg_to"
+ then
+ eval $store_arg_to=\$opt
+ store_arg_to=
+ opt_required_arg=
+ continue
+ fi
+
+ case "$opt" in
+ --*|-?)
+ parse_option "$opt" ;;
+ -?*)
+ # bundled short options must be fed separately to parse_option
+ opt=${opt#-}
+ while test -n "$opt"
+ do
+ extra=${opt#?}
+ this=${opt%$extra}
+ opt=$extra
+ parse_option "-$this"
+ done
+ ;;
+ *)
+ echo "error: unknown test option '$opt'" >&2; exit 1 ;;
+ esac
done
if test -n "$store_arg_to"
then
- echo "error: $prev_opt requires an argument" >&2
+ echo "error: $opt_required_arg requires an argument" >&2
exit 1
fi
@@ -494,21 +527,6 @@ case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
;;
esac
-# Convenience
-#
-# A regexp to match 5, 35 and 40 hexdigits
-_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
-_x40="$_x35$_x05"
-
-# Zero SHA-1
-_z40=0000000000000000000000000000000000000000
-
-OID_REGEX="$_x40"
-ZERO_OID=$_z40
-EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
-EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
-
# Line feed
LF='
'
@@ -882,6 +900,7 @@ maybe_setup_valgrind () {
fi
}
+trace_level_=0
want_trace () {
test "$trace" = t && {
test "$verbose" = t || test "$verbose_log" = t
@@ -895,7 +914,7 @@ want_trace () {
test_eval_inner_ () {
# Do not add anything extra (including LF) after '$*'
eval "
- want_trace && set -x
+ want_trace && trace_level_=$(($trace_level_+1)) && set -x
$*"
}
@@ -926,7 +945,8 @@ test_eval_ () {
test_eval_ret_=$?
if want_trace
then
- set +x
+ test 1 = $trace_level_ && set +x
+ trace_level_=$(($trace_level_-1))
fi
} 2>/dev/null 4>&2
@@ -1085,6 +1105,7 @@ finalize_junit_xml () {
junit_time=$(test-tool date getnanos $junit_suite_start)
sed -e "s/\(<testsuite.*\) time=\"[^\"]*\"/\1/" \
-e "s/<testsuite [^>]*/& time=\"$junit_time\"/" \
+ -e '/^ *<\/testsuite/d' \
<"$junit_xml_path" >"$junit_xml_path.new"
mv "$junit_xml_path.new" "$junit_xml_path"
@@ -1383,6 +1404,20 @@ then
fi
fi
+# Convenience
+# A regexp to match 5, 35 and 40 hexdigits
+_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
+_x40="$_x35$_x05"
+
+test_oid_init
+
+ZERO_OID=$(test_oid zero)
+OID_REGEX=$(echo $ZERO_OID | sed -e 's/0/[0-9a-f]/g')
+EMPTY_TREE=$(test_oid empty_tree)
+EMPTY_BLOB=$(test_oid empty_blob)
+_z40=$ZERO_OID
+
# Provide an implementation of the 'yes' utility; the upper bound
# limit is there to help Windows that cannot stop this loop from
# wasting cycles when the downstream stops reading, so do not be