summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/check-non-portable-shell.pl2
-rw-r--r--t/helper/test-parse-pathspec-file.c33
-rw-r--r--t/helper/test-run-command.c44
-rw-r--r--t/helper/test-tool.c1
-rw-r--r--t/helper/test-tool.h1
-rw-r--r--t/lib-bash.sh6
-rw-r--r--t/lib-git-p4.sh2
-rw-r--r--t/lib-httpd/apply-one-time-sed.sh8
-rwxr-xr-xt/perf/aggregate.perl9
-rwxr-xr-xt/perf/p5303-many-packs.sh18
-rwxr-xr-xt/t0000-basic.sh14
-rwxr-xr-xt/t0003-attributes.sh47
-rwxr-xr-xt/t0014-alias.sh4
-rwxr-xr-xt/t0020-crlf.sh18
-rwxr-xr-xt/t0060-path-utils.sh13
-rwxr-xr-xt/t0061-run-command.sh4
-rwxr-xr-xt/t0067-parse_pathspec_file.sh108
-rwxr-xr-xt/t0090-cache-tree.sh5
-rwxr-xr-xt/t1091-sparse-checkout-builtin.sh371
-rwxr-xr-xt/t1306-xdg-files.sh8
-rwxr-xr-xt/t1307-config-blob.sh2
-rwxr-xr-xt/t1409-avoid-packing-refs.sh16
-rwxr-xr-xt/t1501-work-tree.sh2
-rwxr-xr-xt/t1507-rev-parse-upstream.sh104
-rwxr-xr-xt/t2024-checkout-dwim.sh28
-rwxr-xr-xt/t2026-checkout-pathspec-file.sh163
-rwxr-xr-xt/t2070-restore.sh17
-rwxr-xr-xt/t2072-restore-pathspec-file.sh164
-rwxr-xr-xt/t3008-ls-files-lazy-init-name-hash.sh2
-rwxr-xr-xt/t3011-common-prefixes-and-directory-traversal.sh209
-rwxr-xr-xt/t3206-range-diff.sh2
-rwxr-xr-xt/t3301-notes.sh230
-rwxr-xr-xt/t3400-rebase.sh6
-rwxr-xr-xt/t3404-rebase-interactive.sh10
-rwxr-xr-xt/t3434-rebase-i18n.sh2
-rwxr-xr-xt/t3501-revert-cherry-pick.sh2
-rwxr-xr-xt/t3600-rm.sh14
-rwxr-xr-xt/t3701-add-interactive.sh143
-rwxr-xr-xt/t3704-add-pathspec-file.sh159
-rwxr-xr-xt/t4014-format-patch.sh46
-rwxr-xr-xt/t4015-diff-whitespace.sh152
-rwxr-xr-xt/t4018-diff-funcname.sh1
-rwxr-xr-xt/t4138-apply-ws-expansion.sh16
-rwxr-xr-xt/t4205-log-pretty-formats.sh79
-rwxr-xr-xt/t4210-log-i18n.sh4
-rwxr-xr-xt/t4215-log-skewed-merges.sh133
-rwxr-xr-xt/t4256-am-format-flowed.sh2
-rwxr-xr-xt/t5150-request-pull.sh6
-rwxr-xr-xt/t5314-pack-cycle-detection.sh2
-rwxr-xr-xt/t5317-pack-objects-filter-objects.sh34
-rwxr-xr-xt/t5318-commit-graph.sh4
-rwxr-xr-xt/t5510-fetch.sh24
-rwxr-xr-xt/t5552-skipping-fetch-negotiator.sh18
-rwxr-xr-xt/t5573-pull-verify-signatures.sh64
-rwxr-xr-xt/t5580-clone-push-unc.sh2
-rwxr-xr-xt/t5702-protocol-v2.sh12
-rwxr-xr-xt/t5703-upload-pack-ref-in-want.sh53
-rwxr-xr-xt/t6025-merge-symlinks.sh95
-rwxr-xr-xt/t6030-bisect-porcelain.sh2
-rwxr-xr-xt/t6120-describe.sh72
-rwxr-xr-xt/t6500-gc.sh6
-rwxr-xr-xt/t7004-tag.sh1
-rwxr-xr-xt/t7030-verify-tag.sh24
-rwxr-xr-xt/t7061-wtstatus-ignore.sh9
-rwxr-xr-xt/t7107-reset-pathspec-file.sh42
-rwxr-xr-xt/t7400-submodule-basic.sh15
-rwxr-xr-xt/t7415-submodule-names.sh7
-rwxr-xr-xt/t7420-submodule-set-url.sh55
-rwxr-xr-xt/t7500-commit-template-squash-signoff.sh9
-rwxr-xr-xt/t7501-commit-basic-functionality.sh83
-rwxr-xr-xt/t7510-signed-commit.sh39
-rwxr-xr-xt/t7526-commit-pathspec-file.sh38
-rwxr-xr-xt/t7612-merge-verify-signatures.sh22
-rwxr-xr-xt/t7700-repack.sh172
-rwxr-xr-xt/t7800-difftool.sh5
-rwxr-xr-xt/t7812-grep-icase-non-ascii.sh11
-rwxr-xr-xt/t9001-send-email.sh2
-rwxr-xr-xt/t9300-fast-import.sh20
-rwxr-xr-xt/t9902-completion.sh59
-rw-r--r--t/test-lib-functions.sh2
-rw-r--r--t/test-lib.sh8
81 files changed, 2869 insertions, 572 deletions
diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl
index 38bfeebd88..fd3303552b 100755
--- a/t/check-non-portable-shell.pl
+++ b/t/check-non-portable-shell.pl
@@ -46,7 +46,7 @@ while (<>) {
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
/\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)';
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
- /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
+ /^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
$line = '';
# this resets our $. for each file
diff --git a/t/helper/test-parse-pathspec-file.c b/t/helper/test-parse-pathspec-file.c
new file mode 100644
index 0000000000..02f4ccfd2a
--- /dev/null
+++ b/t/helper/test-parse-pathspec-file.c
@@ -0,0 +1,33 @@
+#include "test-tool.h"
+#include "parse-options.h"
+#include "pathspec.h"
+#include "gettext.h"
+
+int cmd__parse_pathspec_file(int argc, const char **argv)
+{
+ struct pathspec pathspec;
+ const char *pathspec_from_file = 0;
+ int pathspec_file_nul = 0, i;
+
+ static const char *const usage[] = {
+ "test-tool parse-pathspec-file --pathspec-from-file [--pathspec-file-nul]",
+ NULL
+ };
+
+ struct option options[] = {
+ OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
+ OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
+ OPT_END()
+ };
+
+ parse_options(argc, argv, 0, options, usage, 0);
+
+ parse_pathspec_file(&pathspec, 0, 0, 0, pathspec_from_file,
+ pathspec_file_nul);
+
+ for (i = 0; i < pathspec.nr; i++)
+ printf("%s\n", pathspec.items[i].original);
+
+ clear_pathspec(&pathspec);
+ return 0;
+}
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 724328975a..1646aa25d8 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -328,6 +328,46 @@ static int quote_echo(int argc, const char **argv)
return 0;
}
+static int inherit_handle(const char *argv0)
+{
+ struct child_process cp = CHILD_PROCESS_INIT;
+ char path[PATH_MAX];
+ int tmp;
+
+ /* First, open an inheritable handle */
+ xsnprintf(path, sizeof(path), "out-XXXXXX");
+ tmp = xmkstemp(path);
+
+ argv_array_pushl(&cp.args,
+ "test-tool", argv0, "inherited-handle-child", NULL);
+ cp.in = -1;
+ cp.no_stdout = cp.no_stderr = 1;
+ if (start_command(&cp) < 0)
+ die("Could not start child process");
+
+ /* Then close it, and try to delete it. */
+ close(tmp);
+ if (unlink(path))
+ die("Could not delete '%s'", path);
+
+ if (close(cp.in) < 0 || finish_command(&cp) < 0)
+ die("Child did not finish");
+
+ return 0;
+}
+
+static int inherit_handle_child(void)
+{
+ struct strbuf buf = STRBUF_INIT;
+
+ if (strbuf_read(&buf, 0, 0) < 0)
+ die("Could not read stdin");
+ printf("Received %s\n", buf.buf);
+ strbuf_release(&buf);
+
+ return 0;
+}
+
int cmd__run_command(int argc, const char **argv)
{
struct child_process proc = CHILD_PROCESS_INIT;
@@ -335,6 +375,10 @@ int cmd__run_command(int argc, const char **argv)
if (argc > 1 && !strcmp(argv[1], "testsuite"))
exit(testsuite(argc - 1, argv + 1));
+ if (!strcmp(argv[1], "inherited-handle"))
+ exit(inherit_handle(argv[0]));
+ if (!strcmp(argv[1], "inherited-handle-child"))
+ exit(inherit_handle_child());
if (argc >= 2 && !strcmp(argv[1], "quote-stress-test"))
return !!quote_stress_test(argc - 1, argv + 1);
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index f20989d449..c9a232d238 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -39,6 +39,7 @@ static struct test_cmd cmds[] = {
{ "oidmap", cmd__oidmap },
{ "online-cpus", cmd__online_cpus },
{ "parse-options", cmd__parse_options },
+ { "parse-pathspec-file", cmd__parse_pathspec_file },
{ "path-utils", cmd__path_utils },
{ "pkt-line", cmd__pkt_line },
{ "prio-queue", cmd__prio_queue },
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 8ed2af71d1..c8549fd87f 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -29,6 +29,7 @@ int cmd__mktemp(int argc, const char **argv);
int cmd__oidmap(int argc, const char **argv);
int cmd__online_cpus(int argc, const char **argv);
int cmd__parse_options(int argc, const char **argv);
+int cmd__parse_pathspec_file(int argc, const char** argv);
int cmd__path_utils(int argc, const char **argv);
int cmd__pkt_line(int argc, const char **argv);
int cmd__prio_queue(int argc, const char **argv);
diff --git a/t/lib-bash.sh b/t/lib-bash.sh
index 2be955fafb..b0b6060929 100644
--- a/t/lib-bash.sh
+++ b/t/lib-bash.sh
@@ -2,10 +2,12 @@
# to run under Bash; primarily intended for tests of the completion
# script.
-if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then
+if test -n "$BASH" && test -z "$POSIXLY_CORRECT"
+then
# we are in full-on bash mode
true
-elif type bash >/dev/null 2>&1; then
+elif type bash >/dev/null 2>&1
+then
# execute in full-on bash mode
unset POSIXLY_CORRECT
exec bash "$0" "$@"
diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
index 547b9f88e1..5aff2abe8b 100644
--- a/t/lib-git-p4.sh
+++ b/t/lib-git-p4.sh
@@ -175,7 +175,7 @@ stop_and_cleanup_p4d () {
cleanup_git () {
retry_until_success rm -r "$git"
- test_must_fail test -d "$git" &&
+ test_path_is_missing "$git" &&
retry_until_success mkdir "$git"
}
diff --git a/t/lib-httpd/apply-one-time-sed.sh b/t/lib-httpd/apply-one-time-sed.sh
index fcef728925..bf7689d020 100644
--- a/t/lib-httpd/apply-one-time-sed.sh
+++ b/t/lib-httpd/apply-one-time-sed.sh
@@ -7,11 +7,13 @@
#
# This can be used to simulate the effects of the repository changing in
# between HTTP request-response pairs.
-if [ -e one-time-sed ]; then
+if test -f one-time-sed
+then
"$GIT_EXEC_PATH/git-http-backend" >out
- sed "$(cat one-time-sed)" <out >out_modified
+ sed "$(cat one-time-sed)" out >out_modified
- if diff out out_modified >/dev/null; then
+ if cmp -s out out_modified
+ then
cat out
else
cat out_modified
diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 112fc23dbe..14e4cda287 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -4,7 +4,6 @@ use lib '../../perl/build/lib';
use strict;
use warnings;
use Getopt::Long;
-use Git;
use Cwd qw(realpath);
sub get_times {
@@ -85,6 +84,11 @@ sub format_size {
return $out;
}
+sub sane_backticks {
+ open(my $fh, '-|', @_);
+ return <$fh>;
+}
+
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
$codespeed, $sortby, $subsection, $reponame);
@@ -102,7 +106,8 @@ while (scalar @ARGV) {
my $prefix = '';
last if -f $arg or $arg eq "--";
if (! -d $arg) {
- my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
+ my $rev = sane_backticks(qw(git rev-parse --verify), $arg);
+ chomp $rev;
$dir = "build/".$rev;
} elsif ($arg eq '.') {
$dir = '.';
diff --git a/t/perf/p5303-many-packs.sh b/t/perf/p5303-many-packs.sh
index a369152c47..7ee791669a 100755
--- a/t/perf/p5303-many-packs.sh
+++ b/t/perf/p5303-many-packs.sh
@@ -85,4 +85,22 @@ do
'
done
+# Measure pack loading with 10,000 packs.
+test_expect_success 'generate lots of packs' '
+ for i in $(test_seq 10000); do
+ echo "blob"
+ echo "data <<EOF"
+ echo "blob $i"
+ echo "EOF"
+ echo "checkpoint"
+ done |
+ git -c fastimport.unpackLimit=0 fast-import
+'
+
+# The purpose of this test is to evaluate load time for a large number
+# of packs while doing as little other work as possible.
+test_perf "load 10,000 packs" '
+ git rev-parse --verify "HEAD^{commit}"
+'
+
test_done
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 8a81a249d0..3e440c078d 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -155,7 +155,7 @@ test_expect_success 'pretend we have a fully passing test suite' "
"
test_expect_success 'pretend we have a partially passing test suite' "
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
partial-pass '2/3 tests passing' <<-\\EOF &&
test_expect_success 'passing test #1' 'true'
test_expect_success 'failing test #2' 'false'
@@ -219,7 +219,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
"
test_expect_success 'pretend we have a pass, fail, and known breakage' "
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
mixed-results1 'mixed results #1' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_success 'failing test' 'false'
@@ -238,7 +238,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' "
"
test_expect_success 'pretend we have a mix of all possible results' "
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
mixed-results2 'mixed results #2' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_success 'passing test' 'true'
@@ -274,7 +274,7 @@ test_expect_success 'pretend we have a mix of all possible results' "
"
test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
t1234-verbose "test verbose" --verbose <<-\EOF &&
test_expect_success "passing test" true
test_expect_success "test with output" "echo foo"
@@ -301,7 +301,7 @@ test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
'
test_expect_success 'test --verbose-only' '
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
t2345-verbose-only-2 "test verbose-only=2" \
--verbose-only=2 <<-\EOF &&
test_expect_success "passing test" true
@@ -834,7 +834,7 @@ then
fi
test_expect_success 'tests clean up even on failures' "
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
touch clean-after-failure &&
@@ -863,7 +863,7 @@ test_expect_success 'tests clean up even on failures' "
"
test_expect_success 'test_atexit is run' "
- test_must_fail run_sub_test_lib_test \
+ run_sub_test_lib_test_err \
atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
> ../../clean-atexit &&
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 71e63d8b50..b660593c20 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -5,19 +5,16 @@ test_description=gitattributes
. ./test-lib.sh
attr_check () {
- path="$1" expect="$2"
+ path="$1" expect="$2" git_opts="$3" &&
- git $3 check-attr test -- "$path" >actual 2>err &&
- echo "$path: test: $2" >expect &&
+ git $git_opts check-attr test -- "$path" >actual 2>err &&
+ echo "$path: test: $expect" >expect &&
test_cmp expect actual &&
- test_line_count = 0 err
+ test_must_be_empty err
}
attr_check_quote () {
-
- path="$1"
- quoted_path="$2"
- expect="$3"
+ path="$1" quoted_path="$2" expect="$3" &&
git check-attr test -- "$path" >actual &&
echo "\"$quoted_path\": test: $expect" >expect &&
@@ -27,7 +24,7 @@ attr_check_quote () {
test_expect_success 'open-quoted pathname' '
echo "\"a test=a" >.gitattributes &&
- test_must_fail attr_check a a
+ attr_check a unspecified
'
@@ -112,20 +109,20 @@ test_expect_success 'attribute test' '
test_expect_success 'attribute matching is case sensitive when core.ignorecase=0' '
- test_must_fail attr_check F f "-c core.ignorecase=0" &&
- test_must_fail attr_check a/F f "-c core.ignorecase=0" &&
- test_must_fail attr_check a/c/F f "-c core.ignorecase=0" &&
- test_must_fail attr_check a/G a/g "-c core.ignorecase=0" &&
- test_must_fail attr_check a/B/g a/b/g "-c core.ignorecase=0" &&
- test_must_fail attr_check a/b/G a/b/g "-c core.ignorecase=0" &&
- test_must_fail attr_check a/b/H a/b/h "-c core.ignorecase=0" &&
- test_must_fail attr_check a/b/D/g "a/b/d/*" "-c core.ignorecase=0" &&
- test_must_fail attr_check oNoFf unset "-c core.ignorecase=0" &&
- test_must_fail attr_check oFfOn set "-c core.ignorecase=0" &&
+ attr_check F unspecified "-c core.ignorecase=0" &&
+ attr_check a/F unspecified "-c core.ignorecase=0" &&
+ attr_check a/c/F unspecified "-c core.ignorecase=0" &&
+ attr_check a/G unspecified "-c core.ignorecase=0" &&
+ attr_check a/B/g a/g "-c core.ignorecase=0" &&
+ attr_check a/b/G unspecified "-c core.ignorecase=0" &&
+ attr_check a/b/H unspecified "-c core.ignorecase=0" &&
+ attr_check a/b/D/g a/g "-c core.ignorecase=0" &&
+ attr_check oNoFf unspecified "-c core.ignorecase=0" &&
+ attr_check oFfOn unspecified "-c core.ignorecase=0" &&
attr_check NO unspecified "-c core.ignorecase=0" &&
- test_must_fail attr_check a/b/D/NO "a/b/d/*" "-c core.ignorecase=0" &&
+ attr_check a/b/D/NO unspecified "-c core.ignorecase=0" &&
attr_check a/b/d/YES a/b/d/* "-c core.ignorecase=0" &&
- test_must_fail attr_check a/E/f "A/e/F" "-c core.ignorecase=0"
+ attr_check a/E/f f "-c core.ignorecase=0"
'
@@ -149,8 +146,8 @@ test_expect_success 'attribute matching is case insensitive when core.ignorecase
'
test_expect_success CASE_INSENSITIVE_FS 'additional case insensitivity tests' '
- test_must_fail attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=0" &&
- test_must_fail attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=0" &&
+ attr_check a/B/D/g a/g "-c core.ignorecase=0" &&
+ attr_check A/B/D/NO unspecified "-c core.ignorecase=0" &&
attr_check A/b/h a/b/h "-c core.ignorecase=1" &&
attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=1" &&
attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=1"
@@ -244,7 +241,7 @@ EOF
git check-attr foo -- "a/b/f" >>actual 2>>err &&
git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
test_cmp expect actual &&
- test_line_count = 0 err
+ test_must_be_empty err
'
test_expect_success '"**" with no slashes test' '
@@ -265,7 +262,7 @@ EOF
git check-attr foo -- "a/b/f" >>actual 2>>err &&
git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
test_cmp expect actual &&
- test_line_count = 0 err
+ test_must_be_empty err
'
test_expect_success 'using --git-dir and --work-tree' '
diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh
index 2694c81afd..8d3d9144c0 100755
--- a/t/t0014-alias.sh
+++ b/t/t0014-alias.sh
@@ -38,8 +38,8 @@ test_expect_success 'looping aliases - internal execution' '
#'
test_expect_success 'run-command formats empty args properly' '
- GIT_TRACE=1 git frotz a "" b " " c 2>&1 |
- sed -ne "/run_command:/s/.*trace: run_command: //p" >actual &&
+ test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw &&
+ sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual &&
echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
test_cmp expect actual
'
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 854da0ae16..b63ba62e5d 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -159,8 +159,8 @@ test_expect_success 'checkout with autocrlf=input' '
rm -f tmp one dir/two three &&
git config core.autocrlf input &&
git read-tree --reset -u HEAD &&
- test_must_fail has_cr one &&
- test_must_fail has_cr dir/two &&
+ ! has_cr one &&
+ ! has_cr dir/two &&
git update-index -- one dir/two &&
test "$one" = $(git hash-object --stdin <one) &&
test "$two" = $(git hash-object --stdin <dir/two) &&
@@ -237,9 +237,9 @@ test_expect_success '.gitattributes says two is binary' '
git config core.autocrlf true &&
git read-tree --reset -u HEAD &&
- test_must_fail has_cr dir/two &&
+ ! has_cr dir/two &&
verbose has_cr one &&
- test_must_fail has_cr three
+ ! has_cr three
'
test_expect_success '.gitattributes says two is input' '
@@ -248,7 +248,7 @@ test_expect_success '.gitattributes says two is input' '
echo "two crlf=input" >.gitattributes &&
git read-tree --reset -u HEAD &&
- test_must_fail has_cr dir/two
+ ! has_cr dir/two
'
test_expect_success '.gitattributes says two and three are text' '
@@ -270,7 +270,7 @@ test_expect_success 'in-tree .gitattributes (1)' '
rm -rf tmp one dir .gitattributes patch.file three &&
git read-tree --reset -u HEAD &&
- test_must_fail has_cr one &&
+ ! has_cr one &&
verbose has_cr three
'
@@ -280,7 +280,7 @@ test_expect_success 'in-tree .gitattributes (2)' '
git read-tree --reset HEAD &&
git checkout-index -f -q -u -a &&
- test_must_fail has_cr one &&
+ ! has_cr one &&
verbose has_cr three
'
@@ -291,7 +291,7 @@ test_expect_success 'in-tree .gitattributes (3)' '
git checkout-index -u .gitattributes &&
git checkout-index -u one dir/two three &&
- test_must_fail has_cr one &&
+ ! has_cr one &&
verbose has_cr three
'
@@ -302,7 +302,7 @@ test_expect_success 'in-tree .gitattributes (4)' '
git checkout-index -u one dir/two three &&
git checkout-index -u .gitattributes &&
- test_must_fail has_cr one &&
+ ! has_cr one &&
verbose has_cr three
'
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index de2df573a7..2ea2d00c39 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -469,11 +469,14 @@ test_expect_success 'match .gitmodules' '
'
test_expect_success MINGW 'is_valid_path() on Windows' '
- test-tool path-utils is_valid_path \
+ test-tool path-utils is_valid_path \
win32 \
"win32 x" \
../hello.txt \
C:\\git \
+ comm \
+ conout.c \
+ lptN \
\
--not \
"win32 " \
@@ -481,7 +484,13 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
"win32." \
"win32 . ." \
.../hello.txt \
- colon:test
+ colon:test \
+ "AUX.c" \
+ "abc/conOut\$ .xyz/test" \
+ lpt8 \
+ "lpt*" \
+ Nul \
+ "PRN./abc"
'
test_done
diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
index 17c9c0f3bb..7d599675e3 100755
--- a/t/t0061-run-command.sh
+++ b/t/t0061-run-command.sh
@@ -12,6 +12,10 @@ cat >hello-script <<-EOF
cat hello-script
EOF
+test_expect_success MINGW 'subprocess inherits only std handles' '
+ test-tool run-command inherited-handle
+'
+
test_expect_success 'start_command reports ENOENT (slash)' '
test-tool run-command start-command-ENOENT ./does-not-exist 2>err &&
test_i18ngrep "\./does-not-exist" err
diff --git a/t/t0067-parse_pathspec_file.sh b/t/t0067-parse_pathspec_file.sh
new file mode 100755
index 0000000000..7bab49f361
--- /dev/null
+++ b/t/t0067-parse_pathspec_file.sh
@@ -0,0 +1,108 @@
+#!/bin/sh
+
+test_description='Test parse_pathspec_file()'
+
+. ./test-lib.sh
+
+test_expect_success 'one item from stdin' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ EOF
+
+ echo fileA.t |
+ test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'one item from file' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ EOF
+
+ echo fileA.t >list &&
+ test-tool parse-pathspec-file --pathspec-from-file=list >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'NUL delimiters' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ fileB.t
+ EOF
+
+ printf "fileA.t\0fileB.t\0" |
+ test-tool parse-pathspec-file --pathspec-from-file=- --pathspec-file-nul >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'LF delimiters' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ fileB.t
+ EOF
+
+ printf "fileA.t\nfileB.t\n" |
+ test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'no trailing delimiter' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ fileB.t
+ EOF
+
+ printf "fileA.t\nfileB.t" |
+ test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'CRLF delimiters' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ fileB.t
+ EOF
+
+ printf "fileA.t\r\nfileB.t\r\n" |
+ test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'quotes' '
+ cat >expect <<-\EOF &&
+ fileA.t
+ EOF
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ test-tool parse-pathspec-file --pathspec-from-file=list >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success '--pathspec-file-nul takes quotes literally' '
+ # Note: there is an extra newline because --pathspec-file-nul takes
+ # input \n literally, too
+ cat >expect <<-\EOF &&
+ "file\101.t"
+
+ EOF
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ test-tool parse-pathspec-file --pathspec-from-file=list --pathspec-file-nul >actual &&
+
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index ce9a4a5f32..5a633690bf 100755
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh
@@ -21,9 +21,10 @@ generate_expected_cache_tree_rec () {
parent="$2" &&
# ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux
# We want to count only foo because it's the only direct child
- subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) &&
+ git ls-files >files &&
+ subtrees=$(grep / files|cut -d / -f 1|uniq) &&
subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') &&
- entries=$(git ls-files|wc -l) &&
+ entries=$(wc -l <files) &&
printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" &&
for subtree in $subtrees
do
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
new file mode 100755
index 0000000000..ff7f8f7a1f
--- /dev/null
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -0,0 +1,371 @@
+#!/bin/sh
+
+test_description='sparse checkout builtin tests'
+
+. ./test-lib.sh
+
+list_files() {
+ # Do not replace this with 'ls "$1"', as "ls" with BSD-lineage
+ # enables "-A" by default for root and ends up including ".git" and
+ # such in its output. (Note, though, that running the test suite as
+ # root is generally not recommended.)
+ (cd "$1" && printf '%s\n' *)
+}
+
+test_expect_success 'setup' '
+ git init repo &&
+ (
+ cd repo &&
+ echo "initial" >a &&
+ mkdir folder1 folder2 deep &&
+ mkdir deep/deeper1 deep/deeper2 &&
+ mkdir deep/deeper1/deepest &&
+ cp a folder1 &&
+ cp a folder2 &&
+ cp a deep &&
+ cp a deep/deeper1 &&
+ cp a deep/deeper2 &&
+ cp a deep/deeper1/deepest &&
+ git add . &&
+ git commit -m "initial commit"
+ )
+'
+
+test_expect_success 'git sparse-checkout list (empty)' '
+ git -C repo sparse-checkout list >list 2>err &&
+ test_must_be_empty list &&
+ test_i18ngrep "this worktree is not sparse (sparse-checkout file may not exist)" err
+'
+
+test_expect_success 'git sparse-checkout list (populated)' '
+ test_when_finished rm -f repo/.git/info/sparse-checkout &&
+ cat >repo/.git/info/sparse-checkout <<-EOF &&
+ /folder1/*
+ /deep/
+ **/a
+ !*bin*
+ EOF
+ cp repo/.git/info/sparse-checkout expect &&
+ git -C repo sparse-checkout list >list &&
+ test_cmp expect list
+'
+
+test_expect_success 'git sparse-checkout init' '
+ git -C repo sparse-checkout init &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ EOF
+ test_cmp expect repo/.git/info/sparse-checkout &&
+ test_cmp_config -C repo true core.sparsecheckout &&
+ list_files repo >dir &&
+ echo a >expect &&
+ test_cmp expect dir
+'
+
+test_expect_success 'git sparse-checkout list after init' '
+ git -C repo sparse-checkout list >actual &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'init with existing sparse-checkout' '
+ echo "*folder*" >> repo/.git/info/sparse-checkout &&
+ git -C repo sparse-checkout init &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ *folder*
+ EOF
+ test_cmp expect repo/.git/info/sparse-checkout &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ folder1
+ folder2
+ EOF
+ test_cmp expect dir
+'
+
+test_expect_success 'clone --sparse' '
+ git clone --sparse repo clone &&
+ git -C clone sparse-checkout list >actual &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ EOF
+ test_cmp expect actual &&
+ list_files clone >dir &&
+ echo a >expect &&
+ test_cmp expect dir
+'
+
+test_expect_success 'set enables config' '
+ git init empty-config &&
+ (
+ cd empty-config &&
+ test_commit test file &&
+ test_path_is_missing .git/config.worktree &&
+ test_must_fail git sparse-checkout set nothing &&
+ test_path_is_file .git/config.worktree &&
+ test_must_fail git config core.sparseCheckout &&
+ git sparse-checkout set "/*" &&
+ test_cmp_config true core.sparseCheckout
+ )
+'
+
+test_expect_success 'set sparse-checkout using builtin' '
+ git -C repo sparse-checkout set "/*" "!/*/" "*folder*" &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ *folder*
+ EOF
+ git -C repo sparse-checkout list >actual &&
+ test_cmp expect actual &&
+ test_cmp expect repo/.git/info/sparse-checkout &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ folder1
+ folder2
+ EOF
+ test_cmp expect dir
+'
+
+test_expect_success 'set sparse-checkout using --stdin' '
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ /folder1/
+ /folder2/
+ EOF
+ git -C repo sparse-checkout set --stdin <expect &&
+ git -C repo sparse-checkout list >actual &&
+ test_cmp expect actual &&
+ test_cmp expect repo/.git/info/sparse-checkout &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ folder1
+ folder2
+ EOF
+ test_cmp expect dir
+'
+
+test_expect_success 'cone mode: match patterns' '
+ git -C repo config --worktree core.sparseCheckoutCone true &&
+ rm -rf repo/a repo/folder1 repo/folder2 &&
+ git -C repo read-tree -mu HEAD 2>err &&
+ test_i18ngrep ! "disabling cone patterns" err &&
+ git -C repo reset --hard &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ folder1
+ folder2
+ EOF
+ test_cmp expect dir
+'
+
+test_expect_success 'cone mode: warn on bad pattern' '
+ test_when_finished mv sparse-checkout repo/.git/info/ &&
+ cp repo/.git/info/sparse-checkout . &&
+ echo "!/deep/deeper/*" >>repo/.git/info/sparse-checkout &&
+ git -C repo read-tree -mu HEAD 2>err &&
+ test_i18ngrep "unrecognized negative pattern" err
+'
+
+test_expect_success 'sparse-checkout disable' '
+ test_when_finished rm -rf repo/.git/info/sparse-checkout &&
+ git -C repo sparse-checkout disable &&
+ test_path_is_file repo/.git/info/sparse-checkout &&
+ git -C repo config --list >config &&
+ test_must_fail git config core.sparseCheckout &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ deep
+ folder1
+ folder2
+ EOF
+ test_cmp expect dir
+'
+
+test_expect_success 'cone mode: init and set' '
+ git -C repo sparse-checkout init --cone &&
+ git -C repo config --list >config &&
+ test_i18ngrep "core.sparsecheckoutcone=true" config &&
+ list_files repo >dir &&
+ echo a >expect &&
+ test_cmp expect dir &&
+ git -C repo sparse-checkout set deep/deeper1/deepest/ 2>err &&
+ test_must_be_empty err &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ deep
+ EOF
+ test_cmp expect dir &&
+ list_files repo/deep >dir &&
+ cat >expect <<-EOF &&
+ a
+ deeper1
+ EOF
+ test_cmp expect dir &&
+ list_files repo/deep/deeper1 >dir &&
+ cat >expect <<-EOF &&
+ a
+ deepest
+ EOF
+ test_cmp expect dir &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ /deep/
+ !/deep/*/
+ /deep/deeper1/
+ !/deep/deeper1/*/
+ /deep/deeper1/deepest/
+ EOF
+ test_cmp expect repo/.git/info/sparse-checkout &&
+ git -C repo sparse-checkout set --stdin 2>err <<-EOF &&
+ folder1
+ folder2
+ EOF
+ test_must_be_empty err &&
+ cat >expect <<-EOF &&
+ a
+ folder1
+ folder2
+ EOF
+ list_files repo >dir &&
+ test_cmp expect dir
+'
+
+test_expect_success 'cone mode: list' '
+ cat >expect <<-EOF &&
+ folder1
+ folder2
+ EOF
+ git -C repo sparse-checkout set --stdin <expect &&
+ git -C repo sparse-checkout list >actual 2>err &&
+ test_must_be_empty err &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cone mode: set with nested folders' '
+ git -C repo sparse-checkout set deep deep/deeper1/deepest 2>err &&
+ test_line_count = 0 err &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ /deep/
+ EOF
+ test_cmp repo/.git/info/sparse-checkout expect
+'
+
+test_expect_success 'revert to old sparse-checkout on bad update' '
+ test_when_finished git -C repo reset --hard &&
+ echo update >repo/deep/deeper2/a &&
+ cp repo/.git/info/sparse-checkout expect &&
+ test_must_fail git -C repo sparse-checkout set deep/deeper1 2>err &&
+ test_i18ngrep "cannot set sparse-checkout patterns" err &&
+ test_cmp repo/.git/info/sparse-checkout expect &&
+ list_files repo/deep >dir &&
+ cat >expect <<-EOF &&
+ a
+ deeper1
+ deeper2
+ EOF
+ test_cmp dir expect
+'
+
+test_expect_success 'revert to old sparse-checkout on empty update' '
+ git init empty-test &&
+ (
+ echo >file &&
+ git add file &&
+ git commit -m "test" &&
+ test_must_fail git sparse-checkout set nothing 2>err &&
+ test_i18ngrep "Sparse checkout leaves no entry on working directory" err &&
+ test_i18ngrep ! ".git/index.lock" err &&
+ git sparse-checkout set file
+ )
+'
+
+test_expect_success 'fail when lock is taken' '
+ test_when_finished rm -rf repo/.git/info/sparse-checkout.lock &&
+ touch repo/.git/info/sparse-checkout.lock &&
+ test_must_fail git -C repo sparse-checkout set deep 2>err &&
+ test_i18ngrep "File exists" err
+'
+
+test_expect_success '.gitignore should not warn about cone mode' '
+ git -C repo config --worktree core.sparseCheckoutCone true &&
+ echo "**/bin/*" >repo/.gitignore &&
+ git -C repo reset --hard 2>err &&
+ test_i18ngrep ! "disabling cone patterns" err
+'
+
+test_expect_success 'sparse-checkout (init|set|disable) fails with dirty status' '
+ git clone repo dirty &&
+ echo dirty >dirty/folder1/a &&
+ test_must_fail git -C dirty sparse-checkout init &&
+ test_must_fail git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
+ test_must_fail git -C dirty sparse-checkout disable &&
+ git -C dirty reset --hard &&
+ git -C dirty sparse-checkout init &&
+ git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
+ git -C dirty sparse-checkout disable
+'
+
+test_expect_success 'cone mode: set with core.ignoreCase=true' '
+ git -C repo sparse-checkout init --cone &&
+ git -C repo -c core.ignoreCase=true sparse-checkout set folder1 &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ /folder1/
+ EOF
+ test_cmp expect repo/.git/info/sparse-checkout &&
+ list_files repo >dir &&
+ cat >expect <<-EOF &&
+ a
+ folder1
+ EOF
+ test_cmp expect dir
+'
+
+test_expect_success 'interaction with submodules' '
+ git clone repo super &&
+ (
+ cd super &&
+ mkdir modules &&
+ git submodule add ../repo modules/child &&
+ git add . &&
+ git commit -m "add submodule" &&
+ git sparse-checkout init --cone &&
+ git sparse-checkout set folder1
+ ) &&
+ list_files super >dir &&
+ cat >expect <<-\EOF &&
+ a
+ folder1
+ modules
+ EOF
+ test_cmp expect dir &&
+ list_files super/modules/child >dir &&
+ cat >expect <<-\EOF &&
+ a
+ deep
+ folder1
+ folder2
+ EOF
+ test_cmp expect dir
+'
+
+test_done
diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh
index 21e139a313..dd87b43be1 100755
--- a/t/t1306-xdg-files.sh
+++ b/t/t1306-xdg-files.sh
@@ -153,7 +153,7 @@ test_expect_success 'Checking attributes in both XDG and local attributes files'
test_expect_success 'Checking attributes in a non-XDG global attributes file' '
- test_might_fail rm .gitattributes &&
+ rm -f .gitattributes &&
echo "f attr_f=test" >"$HOME"/my_gitattributes &&
git config core.attributesfile "$HOME"/my_gitattributes &&
echo "f: attr_f: test" >expected &&
@@ -165,7 +165,7 @@ test_expect_success 'Checking attributes in a non-XDG global attributes file' '
test_expect_success 'write: xdg file exists and ~/.gitconfig doesn'\''t' '
mkdir -p "$HOME"/.config/git &&
>"$HOME"/.config/git/config &&
- test_might_fail rm "$HOME"/.gitconfig &&
+ rm -f "$HOME"/.gitconfig &&
git config --global user.name "write_config" &&
echo "[user]" >expected &&
echo " name = write_config" >>expected &&
@@ -183,8 +183,8 @@ test_expect_success 'write: xdg file exists and ~/.gitconfig exists' '
test_expect_success 'write: ~/.config/git/ exists and config file doesn'\''t' '
- test_might_fail rm "$HOME"/.gitconfig &&
- test_might_fail rm "$HOME"/.config/git/config &&
+ rm -f "$HOME"/.gitconfig &&
+ rm -f "$HOME"/.config/git/config &&
git config --global user.name "write_gitconfig" &&
echo "[user]" >expected &&
echo " name = write_gitconfig" >>expected &&
diff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh
index 37dc689d8c..002e6d3388 100755
--- a/t/t1307-config-blob.sh
+++ b/t/t1307-config-blob.sh
@@ -74,7 +74,7 @@ test_expect_success 'can parse blob ending with CR' '
'
test_expect_success 'config --blob outside of a repository is an error' '
- test_must_fail nongit git config --blob=foo --list
+ nongit test_must_fail git config --blob=foo --list
'
test_done
diff --git a/t/t1409-avoid-packing-refs.sh b/t/t1409-avoid-packing-refs.sh
index e5cb8a252d..be12fb6350 100755
--- a/t/t1409-avoid-packing-refs.sh
+++ b/t/t1409-avoid-packing-refs.sh
@@ -8,7 +8,7 @@ test_description='avoid rewriting packed-refs unnecessarily'
# shouldn't upset readers, and it should be omitted if the file is
# ever rewritten.
mark_packed_refs () {
- sed -e "s/^\(#.*\)/\1 t1409 /" <.git/packed-refs >.git/packed-refs.new &&
+ sed -e "s/^\(#.*\)/\1 t1409 /" .git/packed-refs >.git/packed-refs.new &&
mv .git/packed-refs.new .git/packed-refs
}
@@ -27,15 +27,15 @@ test_expect_success 'setup' '
'
test_expect_success 'do not create packed-refs file gratuitously' '
- test_must_fail test -f .git/packed-refs &&
+ test_path_is_missing .git/packed-refs &&
git update-ref refs/heads/foo $A &&
- test_must_fail test -f .git/packed-refs &&
+ test_path_is_missing .git/packed-refs &&
git update-ref refs/heads/foo $B &&
- test_must_fail test -f .git/packed-refs &&
+ test_path_is_missing .git/packed-refs &&
git update-ref refs/heads/foo $C $B &&
- test_must_fail test -f .git/packed-refs &&
+ test_path_is_missing .git/packed-refs &&
git update-ref -d refs/heads/foo &&
- test_must_fail test -f .git/packed-refs
+ test_path_is_missing .git/packed-refs
'
test_expect_success 'check that marking the packed-refs file works' '
@@ -46,7 +46,7 @@ test_expect_success 'check that marking the packed-refs file works' '
git for-each-ref >actual &&
test_cmp expected actual &&
git pack-refs --all &&
- test_must_fail check_packed_refs_marked &&
+ ! check_packed_refs_marked &&
git for-each-ref >actual2 &&
test_cmp expected actual2
'
@@ -80,7 +80,7 @@ test_expect_success 'touch packed-refs on delete of packed' '
git pack-refs --all &&
mark_packed_refs &&
git update-ref -d refs/heads/packed-delete &&
- test_must_fail check_packed_refs_marked
+ ! check_packed_refs_marked
'
test_expect_success 'leave packed-refs untouched on update of loose' '
diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh
index 3498d3d55e..b75558040f 100755
--- a/t/t1501-work-tree.sh
+++ b/t/t1501-work-tree.sh
@@ -350,7 +350,7 @@ test_expect_success 'Multi-worktree setup' '
mkdir work &&
mkdir -p repo.git/repos/foo &&
cp repo.git/HEAD repo.git/index repo.git/repos/foo &&
- test_might_fail cp repo.git/sharedindex.* repo.git/repos/foo &&
+ { cp repo.git/sharedindex.* repo.git/repos/foo || :; } &&
sane_unset GIT_DIR GIT_CONFIG GIT_WORK_TREE
'
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index 8b4cf8a6e3..dfc0d96d8a 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -28,14 +28,9 @@ test_expect_success 'setup' '
)
'
-full_name () {
- (cd clone &&
- git rev-parse --symbolic-full-name "$@")
-}
-
commit_subject () {
(cd clone &&
- git show -s --pretty=format:%s "$@")
+ git show -s --pretty=tformat:%s "$@")
}
error_message () {
@@ -44,63 +39,78 @@ error_message () {
}
test_expect_success '@{upstream} resolves to correct full name' '
- test refs/remotes/origin/master = "$(full_name @{upstream})" &&
- test refs/remotes/origin/master = "$(full_name @{UPSTREAM})" &&
- test refs/remotes/origin/master = "$(full_name @{UpSTReam})"
+ echo refs/remotes/origin/master >expect &&
+ git -C clone rev-parse --symbolic-full-name @{upstream} >actual &&
+ test_cmp expect actual &&
+ git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual &&
+ test_cmp expect actual &&
+ git -C clone rev-parse --symbolic-full-name @{UpSTReam} >actual &&
+ test_cmp expect actual
'
test_expect_success '@{u} resolves to correct full name' '
- test refs/remotes/origin/master = "$(full_name @{u})" &&
- test refs/remotes/origin/master = "$(full_name @{U})"
+ echo refs/remotes/origin/master >expect &&
+ git -C clone rev-parse --symbolic-full-name @{u} >actual &&
+ test_cmp expect actual &&
+ git -C clone rev-parse --symbolic-full-name @{U} >actual &&
+ test_cmp expect actual
'
test_expect_success 'my-side@{upstream} resolves to correct full name' '
- test refs/remotes/origin/side = "$(full_name my-side@{u})"
+ echo refs/remotes/origin/side >expect &&
+ git -C clone rev-parse --symbolic-full-name my-side@{u} >actual &&
+ test_cmp expect actual
'
test_expect_success 'upstream of branch with @ in middle' '
- full_name fun@ny@{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name fun@ny@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual &&
- full_name fun@ny@{U} >actual &&
+ git -C clone rev-parse --symbolic-full-name fun@ny@{U} >actual &&
test_cmp expect actual
'
test_expect_success 'upstream of branch with @ at start' '
- full_name @funny@{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name @funny@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual
'
test_expect_success 'upstream of branch with @ at end' '
- full_name funny@@{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name funny@@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual
'
test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
- test_must_fail full_name refs/heads/my-side@{upstream}
+ test_must_fail git -C clone rev-parse --symbolic-full-name refs/heads/my-side@{upstream}
'
test_expect_success 'my-side@{u} resolves to correct commit' '
git checkout side &&
test_commit 5 &&
(cd clone && git fetch) &&
- test 2 = "$(commit_subject my-side)" &&
- test 5 = "$(commit_subject my-side@{u})"
+ echo 2 >expect &&
+ commit_subject my-side >actual &&
+ test_cmp expect actual &&
+ echo 5 >expect &&
+ commit_subject my-side@{u} >actual
'
test_expect_success 'not-tracking@{u} fails' '
- test_must_fail full_name non-tracking@{u} &&
+ test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} &&
(cd clone && git checkout --no-track -b non-tracking) &&
- test_must_fail full_name non-tracking@{u}
+ test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u}
'
test_expect_success '<branch>@{u}@{1} resolves correctly' '
test_commit 6 &&
(cd clone && git fetch) &&
- test 5 = $(commit_subject my-side@{u}@{1}) &&
- test 5 = $(commit_subject my-side@{U}@{1})
+ echo 5 >expect &&
+ commit_subject my-side@{u}@{1} >actual &&
+ test_cmp expect actual &&
+ commit_subject my-side@{U}@{1} >actual &&
+ test_cmp expect actual
'
test_expect_success '@{u} without specifying branch fails on a detached HEAD' '
@@ -149,7 +159,9 @@ test_expect_success 'checkout other@{u}' '
'
test_expect_success 'branch@{u} works when tracking a local branch' '
- test refs/heads/master = "$(full_name local-master@{u})"
+ echo refs/heads/master >expect &&
+ git -C clone rev-parse --symbolic-full-name local-master@{u} >actual &&
+ test_cmp expect actual
'
test_expect_success 'branch@{u} error message when no upstream' '
@@ -203,35 +215,37 @@ test_expect_success 'pull works when tracking a local branch' '
# makes sense if the previous one succeeded
test_expect_success '@{u} works when tracking a local branch' '
- test refs/heads/master = "$(full_name @{u})"
+ echo refs/heads/master >expect &&
+ git -C clone rev-parse --symbolic-full-name @{u} >actual &&
+ test_cmp expect actual
'
-commit=$(git rev-parse HEAD)
-cat >expect <<EOF
-commit $commit
-Reflog: master@{0} (C O Mitter <committer@example.com>)
-Reflog message: branch: Created from HEAD
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:15:13 2005 -0700
-
- 3
-EOF
test_expect_success 'log -g other@{u}' '
+ commit=$(git rev-parse HEAD) &&
+ cat >expect <<-EOF &&
+ commit $commit
+ Reflog: master@{0} (C O Mitter <committer@example.com>)
+ Reflog message: branch: Created from HEAD
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
+
+ 3
+ EOF
git log -1 -g other@{u} >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-commit $commit
-Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>)
-Reflog message: branch: Created from HEAD
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:15:13 2005 -0700
-
- 3
-EOF
-
test_expect_success 'log -g other@{u}@{now}' '
+ commit=$(git rev-parse HEAD) &&
+ cat >expect <<-EOF &&
+ commit $commit
+ Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>)
+ Reflog message: branch: Created from HEAD
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
+
+ 3
+ EOF
git log -1 -g other@{u}@{now} >actual &&
test_cmp expect actual
'
diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh
index fa0718c730..accfa9aa4b 100755
--- a/t/t2024-checkout-dwim.sh
+++ b/t/t2024-checkout-dwim.sh
@@ -37,7 +37,9 @@ test_expect_success 'setup' '
git checkout -b foo &&
test_commit a_foo &&
git checkout -b bar &&
- test_commit a_bar
+ test_commit a_bar &&
+ git checkout -b ambiguous_branch_and_file &&
+ test_commit a_ambiguous_branch_and_file
) &&
git init repo_b &&
(
@@ -46,7 +48,9 @@ test_expect_success 'setup' '
git checkout -b foo &&
test_commit b_foo &&
git checkout -b baz &&
- test_commit b_baz
+ test_commit b_baz &&
+ git checkout -b ambiguous_branch_and_file &&
+ test_commit b_ambiguous_branch_and_file
) &&
git remote add repo_a repo_a &&
git remote add repo_b repo_b &&
@@ -75,6 +79,26 @@ test_expect_success 'checkout of branch from multiple remotes fails #1' '
test_branch master
'
+test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' '
+ # create a file with name matching remote branch name
+ git checkout -b t_ambiguous_branch_and_file &&
+ >ambiguous_branch_and_file &&
+ git add ambiguous_branch_and_file &&
+ git commit -m "ambiguous_branch_and_file" &&
+
+ # modify file to verify that it will not be touched by checkout
+ test_when_finished "git checkout -- ambiguous_branch_and_file" &&
+ echo "file contents" >ambiguous_branch_and_file &&
+ cp ambiguous_branch_and_file expect &&
+
+ test_must_fail git checkout ambiguous_branch_and_file 2>err &&
+
+ test_i18ngrep "matched multiple (2) remote tracking branches" err &&
+
+ # file must not be altered
+ test_cmp expect ambiguous_branch_and_file
+'
+
test_expect_success 'checkout of branch from multiple remotes fails with advice' '
git checkout -B master &&
test_might_fail git branch -D foo &&
diff --git a/t/t2026-checkout-pathspec-file.sh b/t/t2026-checkout-pathspec-file.sh
new file mode 100755
index 0000000000..43d31d7948
--- /dev/null
+++ b/t/t2026-checkout-pathspec-file.sh
@@ -0,0 +1,163 @@
+#!/bin/sh
+
+test_description='checkout --pathspec-from-file'
+
+. ./test-lib.sh
+
+test_tick
+
+test_expect_success setup '
+ test_commit file0 &&
+
+ echo 1 >fileA.t &&
+ echo 1 >fileB.t &&
+ echo 1 >fileC.t &&
+ echo 1 >fileD.t &&
+ git add fileA.t fileB.t fileC.t fileD.t &&
+ git commit -m "files 1" &&
+
+ echo 2 >fileA.t &&
+ echo 2 >fileB.t &&
+ echo 2 >fileC.t &&
+ echo 2 >fileD.t &&
+ git add fileA.t fileB.t fileC.t fileD.t &&
+ git commit -m "files 2" &&
+
+ git tag checkpoint
+'
+
+restore_checkpoint () {
+ git reset --hard checkpoint
+}
+
+verify_expect () {
+ git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success '--pathspec-from-file from stdin' '
+ restore_checkpoint &&
+
+ echo fileA.t | git checkout --pathspec-from-file=- HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success '--pathspec-from-file from file' '
+ restore_checkpoint &&
+
+ echo fileA.t >list &&
+ git checkout --pathspec-from-file=list HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'NUL delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\0fileB.t\0" | git checkout --pathspec-from-file=- --pathspec-file-nul HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'LF delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\nfileB.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'no trailing delimiter' '
+ restore_checkpoint &&
+
+ printf "fileA.t\nfileB.t" | git checkout --pathspec-from-file=- HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'CRLF delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\r\nfileB.t\r\n" | git checkout --pathspec-from-file=- HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'quotes' '
+ restore_checkpoint &&
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ git checkout --pathspec-from-file=list HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'quotes not compatible with --pathspec-file-nul' '
+ restore_checkpoint &&
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
+'
+
+test_expect_success 'only touches what was listed' '
+ restore_checkpoint &&
+
+ printf "fileB.t\nfileC.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileB.t
+ M fileC.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+
+ test_must_fail git checkout --pathspec-from-file=list --detach 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --detach" err &&
+
+ test_must_fail git checkout --pathspec-from-file=list --patch 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+ test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git checkout --pathspec-file-nul 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err
+'
+
+test_done
diff --git a/t/t2070-restore.sh b/t/t2070-restore.sh
index 21c3f84459..076d0df7fc 100755
--- a/t/t2070-restore.sh
+++ b/t/t2070-restore.sh
@@ -106,4 +106,21 @@ test_expect_success 'restore --staged adds deleted intent-to-add file back to in
git diff --cached --exit-code
'
+test_expect_success 'restore --staged invalidates cache tree for deletions' '
+ test_when_finished git reset --hard &&
+ >new1 &&
+ >new2 &&
+ git add new1 new2 &&
+
+ # It is important to commit and then reset here, so that the index
+ # contains a valid cache-tree for the "both" tree.
+ git commit -m both &&
+ git reset --soft HEAD^ &&
+
+ git restore --staged new1 &&
+ git commit -m "just new2" &&
+ git rev-parse HEAD:new2 &&
+ test_must_fail git rev-parse HEAD:new1
+'
+
test_done
diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh
new file mode 100755
index 0000000000..0d47946e8a
--- /dev/null
+++ b/t/t2072-restore-pathspec-file.sh
@@ -0,0 +1,164 @@
+#!/bin/sh
+
+test_description='restore --pathspec-from-file'
+
+. ./test-lib.sh
+
+test_tick
+
+test_expect_success setup '
+ test_commit file0 &&
+
+ echo 1 >fileA.t &&
+ echo 1 >fileB.t &&
+ echo 1 >fileC.t &&
+ echo 1 >fileD.t &&
+ git add fileA.t fileB.t fileC.t fileD.t &&
+ git commit -m "files 1" &&
+
+ echo 2 >fileA.t &&
+ echo 2 >fileB.t &&
+ echo 2 >fileC.t &&
+ echo 2 >fileD.t &&
+ git add fileA.t fileB.t fileC.t fileD.t &&
+ git commit -m "files 2" &&
+
+ git tag checkpoint
+'
+
+restore_checkpoint () {
+ git reset --hard checkpoint
+}
+
+verify_expect () {
+ git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success '--pathspec-from-file from stdin' '
+ restore_checkpoint &&
+
+ echo fileA.t | git restore --pathspec-from-file=- --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success '--pathspec-from-file from file' '
+ restore_checkpoint &&
+
+ echo fileA.t >list &&
+ git restore --pathspec-from-file=list --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'NUL delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\0fileB.t\0" | git restore --pathspec-from-file=- --pathspec-file-nul --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'LF delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\nfileB.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'no trailing delimiter' '
+ restore_checkpoint &&
+
+ printf "fileA.t\nfileB.t" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'CRLF delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\r\nfileB.t\r\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ M fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'quotes' '
+ restore_checkpoint &&
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ git restore --pathspec-from-file=list --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'quotes not compatible with --pathspec-file-nul' '
+ restore_checkpoint &&
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
+'
+
+test_expect_success 'only touches what was listed' '
+ restore_checkpoint &&
+
+ printf "fileB.t\nfileC.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+
+ cat >expect <<-\EOF &&
+ M fileB.t
+ M fileC.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ >empty_list &&
+
+ test_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+ test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ test_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err &&
+ test_i18ngrep -e "you must specify path(s) to restore" err
+'
+
+test_done
diff --git a/t/t3008-ls-files-lazy-init-name-hash.sh b/t/t3008-ls-files-lazy-init-name-hash.sh
index 64f047332b..85f3704958 100755
--- a/t/t3008-ls-files-lazy-init-name-hash.sh
+++ b/t/t3008-ls-files-lazy-init-name-hash.sh
@@ -4,7 +4,7 @@ test_description='Test the lazy init name hash with various folder structures'
. ./test-lib.sh
-if test 1 -eq $($GIT_BUILD_DIR/t/helper/test-tool online-cpus)
+if test 1 -eq $(test-tool online-cpus)
then
skip_all='skipping lazy-init tests, single cpu'
test_done
diff --git a/t/t3011-common-prefixes-and-directory-traversal.sh b/t/t3011-common-prefixes-and-directory-traversal.sh
new file mode 100755
index 0000000000..3da5b2b6e7
--- /dev/null
+++ b/t/t3011-common-prefixes-and-directory-traversal.sh
@@ -0,0 +1,209 @@
+#!/bin/sh
+
+test_description='directory traversal handling, especially with common prefixes'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit hello &&
+
+ >empty &&
+ mkdir untracked_dir &&
+ >untracked_dir/empty &&
+ git init untracked_repo &&
+ >untracked_repo/empty &&
+
+ cat <<-EOF >.gitignore &&
+ ignored
+ an_ignored_dir/
+ EOF
+ mkdir an_ignored_dir &&
+ mkdir an_untracked_dir &&
+ >an_ignored_dir/ignored &&
+ >an_ignored_dir/untracked &&
+ >an_untracked_dir/ignored &&
+ >an_untracked_dir/untracked
+'
+
+test_expect_success 'git ls-files -o shows the right entries' '
+ cat <<-EOF >expect &&
+ .gitignore
+ actual
+ an_ignored_dir/ignored
+ an_ignored_dir/untracked
+ an_untracked_dir/ignored
+ an_untracked_dir/untracked
+ empty
+ expect
+ untracked_dir/empty
+ untracked_repo/
+ EOF
+ git ls-files -o >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o --exclude-standard shows the right entries' '
+ cat <<-EOF >expect &&
+ .gitignore
+ actual
+ an_untracked_dir/untracked
+ empty
+ expect
+ untracked_dir/empty
+ untracked_repo/
+ EOF
+ git ls-files -o --exclude-standard >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o untracked_dir recurses' '
+ echo untracked_dir/empty >expect &&
+ git ls-files -o untracked_dir >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o untracked_dir/ recurses' '
+ echo untracked_dir/empty >expect &&
+ git ls-files -o untracked_dir/ >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o --directory untracked_dir does not recurse' '
+ echo untracked_dir/ >expect &&
+ git ls-files -o --directory untracked_dir >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o --directory untracked_dir/ does not recurse' '
+ echo untracked_dir/ >expect &&
+ git ls-files -o --directory untracked_dir/ >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o untracked_repo does not recurse' '
+ echo untracked_repo/ >expect &&
+ git ls-files -o untracked_repo >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o untracked_repo/ does not recurse' '
+ echo untracked_repo/ >expect &&
+ git ls-files -o untracked_repo/ >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o untracked_dir untracked_repo recurses into untracked_dir only' '
+ cat <<-EOF >expect &&
+ untracked_dir/empty
+ untracked_repo/
+ EOF
+ git ls-files -o untracked_dir untracked_repo >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o untracked_dir/ untracked_repo/ recurses into untracked_dir only' '
+ cat <<-EOF >expect &&
+ untracked_dir/empty
+ untracked_repo/
+ EOF
+ git ls-files -o untracked_dir/ untracked_repo/ >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o --directory untracked_dir untracked_repo does not recurse' '
+ cat <<-EOF >expect &&
+ untracked_dir/
+ untracked_repo/
+ EOF
+ git ls-files -o --directory untracked_dir untracked_repo >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o --directory untracked_dir/ untracked_repo/ does not recurse' '
+ cat <<-EOF >expect &&
+ untracked_dir/
+ untracked_repo/
+ EOF
+ git ls-files -o --directory untracked_dir/ untracked_repo/ >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o .git shows nothing' '
+ git ls-files -o .git >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'git ls-files -o .git/ shows nothing' '
+ git ls-files -o .git/ >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success FUNNYNAMES 'git ls-files -o untracked_* recurses appropriately' '
+ mkdir "untracked_*" &&
+ >"untracked_*/empty" &&
+
+ cat <<-EOF >expect &&
+ untracked_*/empty
+ untracked_dir/empty
+ untracked_repo/
+ EOF
+ git ls-files -o "untracked_*" >actual &&
+ test_cmp expect actual
+'
+
+# It turns out fill_directory returns the right paths, but ls-files' post-call
+# filtering in show_dir_entry() via calling dir_path_match() which ends up
+# in git_fnmatch() has logic for PATHSPEC_ONESTAR that assumes the pathspec
+# must match the full path; it doesn't check it for matching a leading
+# directory.
+test_expect_failure FUNNYNAMES 'git ls-files -o untracked_*/ recurses appropriately' '
+ cat <<-EOF >expect &&
+ untracked_*/empty
+ untracked_dir/empty
+ untracked_repo/
+ EOF
+ git ls-files -o "untracked_*/" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success FUNNYNAMES 'git ls-files -o --directory untracked_* does not recurse' '
+ cat <<-EOF >expect &&
+ untracked_*/
+ untracked_dir/
+ untracked_repo/
+ EOF
+ git ls-files -o --directory "untracked_*" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success FUNNYNAMES 'git ls-files -o --directory untracked_*/ does not recurse' '
+ cat <<-EOF >expect &&
+ untracked_*/
+ untracked_dir/
+ untracked_repo/
+ EOF
+ git ls-files -o --directory "untracked_*/" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git ls-files -o consistent between one or two dirs' '
+ git ls-files -o --exclude-standard an_ignored_dir/ an_untracked_dir/ >tmp &&
+ ! grep ^an_ignored_dir/ tmp >expect &&
+ git ls-files -o --exclude-standard an_ignored_dir/ >actual &&
+ test_cmp expect actual
+'
+
+# ls-files doesn't have a way to request showing both untracked and ignored
+# files at the same time, so use `git status --ignored`
+test_expect_success 'git status --ignored shows same files under dir with or without pathspec' '
+ cat <<-EOF >expect &&
+ ?? an_untracked_dir/
+ !! an_untracked_dir/ignored
+ EOF
+ git status --porcelain --ignored >output &&
+ grep an_untracked_dir output >expect &&
+ git status --porcelain --ignored an_untracked_dir/ >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index ec2b456dbb..0575dd72b1 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -638,7 +638,7 @@ test_expect_success 'format-patch --range-diff with --notes' '
test_cmp expect actual
'
-test_expect_success 'format-patch --range-diff with --notes' '
+test_expect_success 'format-patch --range-diff with format.notes config' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index d66a5f6faa..8f43303007 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -54,7 +54,9 @@ test_expect_success 'create notes' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
- test "b4" = "$(git notes show)" &&
+ echo b4 >expect &&
+ git notes show >actual &&
+ test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@@ -79,14 +81,21 @@ test_expect_success 'edit existing notes' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
- test "b3" = "$(git notes show)" &&
+ echo b3 >expect &&
+ git notes show >actual &&
+ test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
test_expect_success 'show notes from treeish' '
- test "b3" = "$(git notes --ref commits^{tree} show)" &&
- test "b4" = "$(git notes --ref commits@{1} show)"
+ echo b3 >expect &&
+ git notes --ref commits^{tree} show >actual &&
+ test_cmp expect actual &&
+
+ echo b4 >expect &&
+ git notes --ref commits@{1} show >actual &&
+ test_cmp expect actual
'
test_expect_success 'cannot edit notes from non-ref' '
@@ -99,7 +108,9 @@ test_expect_success 'cannot "git notes add -m" where notes already exists' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
- test "b3" = "$(git notes show)" &&
+ echo b3 >expect &&
+ git notes show >actual &&
+ test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@@ -109,7 +120,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f -m"' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
- test "b1" = "$(git notes show)" &&
+ echo b1 >expect &&
+ git notes show >actual &&
+ test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@@ -119,7 +132,9 @@ test_expect_success 'add w/no options on existing note morphs into edit' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
- test "b2" = "$(git notes show)" &&
+ echo b2 >expect &&
+ git notes show >actual &&
+ test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@@ -129,7 +144,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f"' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
- test "b1" = "$(git notes show)" &&
+ echo b1 >expect &&
+ git notes show >actual &&
+ test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@@ -146,7 +163,8 @@ test_expect_success 'show notes' '
Notes:
${indent}b1
EOF
- ! (git cat-file commit HEAD | grep b1) &&
+ git cat-file commit HEAD >commits &&
+ ! grep b1 commits &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -472,9 +490,11 @@ test_expect_success 'removing with --stdin --ignore-missing' '
test_expect_success 'list notes with "git notes list"' '
commit_2=$(git rev-parse 2nd) &&
commit_3=$(git rev-parse 3rd) &&
+ note_2=$(git rev-parse refs/notes/commits:$commit_2) &&
+ note_3=$(git rev-parse refs/notes/commits:$commit_3) &&
sort -t" " -k2 >expect <<-EOF &&
- $(git rev-parse refs/notes/commits:$commit_2) $commit_2
- $(git rev-parse refs/notes/commits:$commit_3) $commit_3
+ $note_2 $commit_2
+ $note_3 $commit_3
EOF
git notes list >actual &&
test_cmp expect actual
@@ -486,9 +506,7 @@ test_expect_success 'list notes with "git notes"' '
'
test_expect_success 'list specific note with "git notes list <object>"' '
- cat >expect <<-EOF &&
- $(git rev-parse refs/notes/commits:$commit_3)
- EOF
+ git rev-parse refs/notes/commits:$commit_3 >expect &&
git notes list HEAD^^ >actual &&
test_cmp expect actual
'
@@ -512,10 +530,11 @@ test_expect_success 'append to existing note with "git notes append"' '
test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
commit_5=$(git rev-parse 5th) &&
+ note_5=$(git rev-parse refs/notes/commits:$commit_5) &&
sort -t" " -k2 >expect_list <<-EOF &&
- $(git rev-parse refs/notes/commits:$commit_2) $commit_2
- $(git rev-parse refs/notes/commits:$commit_3) $commit_3
- $(git rev-parse refs/notes/commits:$commit_5) $commit_5
+ $note_2 $commit_2
+ $note_3 $commit_3
+ $note_5 $commit_5
EOF
git notes list >actual &&
test_cmp expect_list actual
@@ -721,7 +740,8 @@ test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
git notes show HEAD: >actual &&
test_cmp expect actual &&
echo "Note on a blob" >expect &&
- filename=$(git ls-tree --name-only HEAD | head -n1) &&
+ git ls-tree --name-only HEAD >files &&
+ filename=$(head -n1 files) &&
git notes add -m "Note on a blob" HEAD:$filename &&
git notes show HEAD:$filename >actual &&
test_cmp expect actual &&
@@ -745,10 +765,13 @@ test_expect_success 'create note from other note with "git notes add -C"' '
Notes:
${indent}order test
EOF
- git notes add -C $(git notes list HEAD^) &&
+ note=$(git notes list HEAD^) &&
+ git notes add -C $note &&
git log -1 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
+ git notes list HEAD^ >expect &&
+ git notes list HEAD >actual &&
+ test_cmp expect actual
'
test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
@@ -777,11 +800,12 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i
Notes:
${indent}This is a blob object
EOF
- blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
- git notes add -C $blob &&
+ echo "This is a blob object" | git hash-object -w --stdin >blob &&
+ git notes add -C $(cat blob) &&
git log -1 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$blob"
+ git notes list HEAD >actual &&
+ test_cmp blob actual
'
test_expect_success 'create note from other note with "git notes add -c"' '
@@ -797,7 +821,8 @@ test_expect_success 'create note from other note with "git notes add -c"' '
Notes:
${indent}yet another note
EOF
- MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
+ note=$(git notes list HEAD^^) &&
+ MSG="yet another note" git notes add -c $note &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -822,7 +847,8 @@ test_expect_success 'append to note from other note with "git notes append -C"'
${indent}
${indent}yet another note
EOF
- git notes append -C $(git notes list HEAD^) HEAD^ &&
+ note=$(git notes list HEAD^) &&
+ git notes append -C $note HEAD^ &&
git log -1 HEAD^ >actual &&
test_cmp expect actual
'
@@ -839,7 +865,8 @@ test_expect_success 'create note from other note with "git notes append -c"' '
Notes:
${indent}other note
EOF
- MSG="other note" git notes append -c $(git notes list HEAD^) &&
+ note=$(git notes list HEAD^) &&
+ MSG="other note" git notes append -c $note &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -858,7 +885,8 @@ test_expect_success 'append to note from other note with "git notes append -c"'
${indent}
${indent}yet another note
EOF
- MSG="yet another note" git notes append -c $(git notes list HEAD) &&
+ note=$(git notes list HEAD) &&
+ MSG="yet another note" git notes append -c $note &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -878,7 +906,9 @@ test_expect_success 'copy note with "git notes copy"' '
git notes copy 8th 4th &&
git log 3rd..4th >actual &&
test_cmp expect actual &&
- test "$(git note list 4th)" = "$(git note list 8th)"
+ git notes list 4th >expect &&
+ git notes list 8th >actual &&
+ test_cmp expect actual
'
test_expect_success 'copy note with "git notes copy" with default' '
@@ -899,14 +929,30 @@ test_expect_success 'copy note with "git notes copy" with default' '
git notes copy HEAD^ &&
git log -1 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
+ git notes list HEAD^ >expect &&
+ git notes list HEAD >actual &&
+ test_cmp expect actual
'
test_expect_success 'prevent overwrite with "git notes copy"' '
test_must_fail git notes copy HEAD~2 HEAD &&
+ cat >expect <<-EOF &&
+ commit $commit
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:23:13 2005 -0700
+
+ ${indent}11th
+
+ Notes:
+ ${indent}other note
+ ${indent}
+ ${indent}yet another note
+ EOF
git log -1 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
+ git notes list HEAD^ >expect &&
+ git notes list HEAD >actual &&
+ test_cmp expect actual
'
test_expect_success 'allow overwrite with "git notes copy -f"' '
@@ -924,7 +970,9 @@ test_expect_success 'allow overwrite with "git notes copy -f"' '
git notes copy -f HEAD~3 HEAD &&
git log -1 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$(git notes list HEAD~3)"
+ git notes list HEAD~3 >expect &&
+ git notes list HEAD >actual &&
+ test_cmp expect actual
'
test_expect_success 'allow overwrite with "git notes copy -f" with default' '
@@ -944,7 +992,9 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' '
git notes copy -f HEAD~2 &&
git log -1 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
+ git notes list HEAD~2 >expect &&
+ git notes list HEAD >actual &&
+ test_cmp expect actual
'
test_expect_success 'cannot copy note from object without notes' '
@@ -979,13 +1029,21 @@ test_expect_success 'git notes copy --stdin' '
${indent}
${indent}yet another note
EOF
- (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
- echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
- git notes copy --stdin &&
+ from=$(git rev-parse HEAD~3) &&
+ to=$(git rev-parse HEAD^) &&
+ echo "$from" "$to" >copy &&
+ from=$(git rev-parse HEAD~2) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >>copy &&
+ git notes copy --stdin <copy &&
git log -2 >actual &&
test_cmp expect actual &&
- test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
- test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
+ git notes list HEAD~2 >expect &&
+ git notes list HEAD >actual &&
+ test_cmp expect actual &&
+ git notes list HEAD~3 >expect &&
+ git notes list HEAD^ >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
@@ -1006,9 +1064,13 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
${indent}14th
EOF
- (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
- echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD~3) &&
+ to=$(git rev-parse HEAD^) &&
+ echo "$from" "$to" >copy &&
+ from=$(git rev-parse HEAD~2) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >>copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -2 >actual &&
test_cmp expect actual
'
@@ -1041,17 +1103,23 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
EOF
test_config notes.rewriteMode overwrite &&
test_config notes.rewriteRef "refs/notes/*" &&
- (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
- echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD~3) &&
+ to=$(git rev-parse HEAD^) &&
+ echo "$from" "$to" >copy &&
+ from=$(git rev-parse HEAD~2) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >>copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -2 >actual &&
test_cmp expect actual
'
test_expect_success 'git notes copy --for-rewrite (disabled)' '
test_config notes.rewrite.bar false &&
- echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
- git notes copy --for-rewrite=bar &&
+ from=$(git rev-parse HEAD~3) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ git notes copy --for-rewrite=bar <copy &&
git log -2 >actual &&
test_cmp expect actual
'
@@ -1071,8 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
git notes add -f -m"a fresh note" HEAD^ &&
test_config notes.rewriteMode overwrite &&
test_config notes.rewriteRef "refs/notes/*" &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1080,8 +1150,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
test_expect_success 'git notes copy --for-rewrite (ignore)' '
test_config notes.rewriteMode ignore &&
test_config notes.rewriteRef "refs/notes/*" &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1103,8 +1175,10 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
git notes add -f -m"another fresh note" HEAD^ &&
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1131,9 +1205,13 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
git notes add -f -m"append 2" HEAD^^ &&
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
- (echo $(git rev-parse HEAD^) $(git rev-parse HEAD) &&
- echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ from=$(git rev-parse HEAD^^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >>copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1142,8 +1220,10 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' '
git notes remove HEAD^ &&
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
- git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1163,8 +1243,10 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
git notes add -f -m"replacement note 1" HEAD^ &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
- GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
+ GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1184,9 +1266,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' '
git notes add -f -m"replacement note 2" HEAD^ &&
test_config notes.rewriteMode overwrite &&
test_unconfig notes.rewriteRef &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
- git notes copy --for-rewrite=foo &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@@ -1195,9 +1279,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
git notes add -f -m"replacement note 3" HEAD^ &&
test_config notes.rewriteMode overwrite &&
test_config notes.rewriteRef refs/notes/other &&
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
+ from=$(git rev-parse HEAD^) &&
+ to=$(git rev-parse HEAD) &&
+ echo "$from" "$to" >copy &&
GIT_NOTES_REWRITE_REF=refs/notes/commits \
- git notes copy --for-rewrite=foo &&
+ git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
grep "replacement note 3" actual
'
@@ -1212,26 +1298,36 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' '
test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' '
test_unconfig core.notesRef &&
sane_unset GIT_NOTES_REF &&
- test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master"
+ echo refs/notes/refs/heads/master >expect &&
+ git notes --ref=refs/heads/master get-ref >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes get-ref (no overrides)' '
test_unconfig core.notesRef &&
sane_unset GIT_NOTES_REF &&
- test "$(git notes get-ref)" = "refs/notes/commits"
+ echo refs/notes/commits >expect &&
+ git notes get-ref >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes get-ref (core.notesRef)' '
test_config core.notesRef refs/notes/foo &&
- test "$(git notes get-ref)" = "refs/notes/foo"
+ echo refs/notes/foo >expect &&
+ git notes get-ref >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes get-ref (GIT_NOTES_REF)' '
- test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
+ echo refs/notes/bar >expect &&
+ GIT_NOTES_REF=refs/notes/bar git notes get-ref >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes get-ref (--ref)' '
- test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"
+ echo refs/notes/baz >expect &&
+ GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref >actual &&
+ test_cmp expect actual
'
test_expect_success 'setup testing of empty notes' '
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index f267f6cd54..221b35f2df 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -159,6 +159,12 @@ test_expect_success 'fail when upstream arg is missing and not configured' '
test_must_fail git rebase
'
+test_expect_success 'rebase works with format.useAutoBase' '
+ test_config format.useAutoBase true &&
+ git checkout topic &&
+ git rebase master
+'
+
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '
git checkout -b default-base master &&
git checkout -b default topic &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index bf0dc756d2..ae6e55ce79 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1265,11 +1265,11 @@ test_expect_success SHA1 'short SHA-1 collide' '
test_when_finished "reset_rebase && git checkout master" &&
git checkout collide &&
(
- unset test_tick &&
- test_tick &&
- set_fake_editor &&
- FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \
- FAKE_LINES="reword 1 2" git rebase -i HEAD~2
+ unset test_tick &&
+ test_tick &&
+ set_fake_editor &&
+ FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \
+ FAKE_LINES="reword 1 2" git rebase -i HEAD~2
)
'
diff --git a/t/t3434-rebase-i18n.sh b/t/t3434-rebase-i18n.sh
index 4b5b128cd6..c7c835cde9 100755
--- a/t/t3434-rebase-i18n.sh
+++ b/t/t3434-rebase-i18n.sh
@@ -45,7 +45,7 @@ test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' '
compare_msg eucJP.txt eucJP UTF-8
'
-test_expect_failure 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
+test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
git switch -c merge-eucJP-ISO-2022-JP first &&
git config i18n.commitencoding eucJP &&
git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index 1c51a9131d..7c1da21df1 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -150,7 +150,7 @@ test_expect_success 'cherry-pick works with dirty renamed file' '
test_tick &&
git commit -m renamed &&
echo modified >renamed &&
- git cherry-pick refs/heads/unrelated >out &&
+ git cherry-pick refs/heads/unrelated &&
test $(git rev-parse :0:renamed) = $(git rev-parse HEAD~2:to-rename.t) &&
grep -q "^modified$" renamed
'
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 8c8cca5bfb..0ea858d652 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -113,9 +113,10 @@ test_expect_success '"rm" command printed' '
echo frotz >test-file &&
git add test-file &&
git commit -m "add file for rm test" &&
- git rm test-file >rm-output &&
- test $(grep "^rm " rm-output | wc -l) = 1 &&
- rm -f test-file rm-output &&
+ git rm test-file >rm-output.raw &&
+ grep "^rm " rm-output.raw >rm-output &&
+ test_line_count = 1 rm-output &&
+ rm -f test-file rm-output.raw rm-output &&
git commit -m "remove file from rm test"
'
@@ -250,6 +251,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
echo "100644 $hash 0 some-file-$i"
i=$(( $i + 1 ))
done | git update-index --index-info &&
+ # git command is intentionally placed upstream of pipe to induce SIGPIPE
git rm -n "some-file-*" | : &&
test_path_is_missing .git/index.lock
'
@@ -303,7 +305,8 @@ EOF
test_expect_success 'rm removes empty submodules from work tree' '
mkdir submod &&
- git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) submod &&
+ hash=$(git rev-parse HEAD) &&
+ git update-index --add --cacheinfo 160000 "$hash" submod &&
git config -f .gitmodules submodule.sub.url ./. &&
git config -f .gitmodules submodule.sub.path submod &&
git submodule init &&
@@ -622,7 +625,8 @@ test_expect_success 'setup subsubmodule' '
git submodule update &&
(
cd submod &&
- git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod &&
+ hash=$(git rev-parse HEAD) &&
+ git update-index --add --cacheinfo 160000 "$hash" subsubmod &&
git config -f .gitmodules submodule.sub.url ../. &&
git config -f .gitmodules submodule.sub.path subsubmod &&
git submodule init &&
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index d4f9386621..e36fd0a5d3 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -23,6 +23,17 @@ diff_cmp () {
test_cmp "$1.filtered" "$2.filtered"
}
+# This function uses a trick to manipulate the interactive add to use color:
+# the `want_color()` function special-cases the situation where a pager was
+# spawned and Git now wants to output colored text: to detect that situation,
+# the environment variable `GIT_PAGER_IN_USE` is set. However, color is
+# suppressed despite that environment variable if the `TERM` variable
+# indicates a dumb terminal, so we set that variable, too.
+
+force_color () {
+ env GIT_PAGER_IN_USE=true TERM=vt100 "$@"
+}
+
test_expect_success 'setup (initial)' '
echo content >file &&
git add file &&
@@ -57,6 +68,15 @@ test_expect_success 'revert works (initial)' '
! grep . output
'
+test_expect_success 'add untracked (multiple)' '
+ test_when_finished "git reset && rm [1-9]" &&
+ touch $(test_seq 9) &&
+ test_write_lines a "2-5 8-" | git add -i -- [1-9] &&
+ test_write_lines 2 3 4 5 8 9 >expected &&
+ git ls-files [1-9] >output &&
+ test_cmp expected output
+'
+
test_expect_success 'setup (commit)' '
echo baseline >file &&
git add file &&
@@ -94,7 +114,6 @@ test_expect_success 'revert works (commit)' '
grep "unchanged *+3/-0 file" output
'
-
test_expect_success 'setup expected' '
cat >expected <<-\EOF
EOF
@@ -263,6 +282,35 @@ test_expect_success FILEMODE 'stage mode and hunk' '
# end of tests disabled when filemode is not usable
+test_expect_success 'different prompts for mode change/deleted' '
+ git reset --hard &&
+ >file &&
+ >deleted &&
+ git add --chmod=+x file deleted &&
+ echo changed >file &&
+ rm deleted &&
+ test_write_lines n n n |
+ git -c core.filemode=true add -p >actual &&
+ sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
+ cat >expect <<-\EOF &&
+ (1/1) Stage deletion [y,n,q,a,d,?]?
+ (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,?]?
+ (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]?
+ EOF
+ test_cmp expect actual.filtered
+'
+
+test_expect_success 'correct message when there is nothing to do' '
+ git reset --hard &&
+ git add -p 2>err &&
+ test_i18ngrep "No changes" err &&
+ printf "\\0123" >binary &&
+ git add binary &&
+ printf "\\0abc" >binary &&
+ git add -p 2>err &&
+ test_i18ngrep "Only binary files changed" err
+'
+
test_expect_success 'setup again' '
git reset --hard &&
test_chmod +x file &&
@@ -374,6 +422,36 @@ test_expect_success 'split hunk setup' '
test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
'
+test_expect_success 'goto hunk' '
+ test_when_finished "git reset" &&
+ tr _ " " >expect <<-EOF &&
+ (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + 1: -1,2 +1,3 +15
+ _ 2: -2,4 +3,8 +21
+ go to which hunk? @@ -1,2 +1,3 @@
+ _10
+ +15
+ _20
+ (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
+ EOF
+ test_write_lines s y g 1 | git add -p >actual &&
+ tail -n 7 <actual >actual.trimmed &&
+ test_cmp expect actual.trimmed
+'
+
+test_expect_success 'navigate to hunk via regex' '
+ test_when_finished "git reset" &&
+ tr _ " " >expect <<-EOF &&
+ (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? @@ -1,2 +1,3 @@
+ _10
+ +15
+ _20
+ (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
+ EOF
+ test_write_lines s y /1,2 | git add -p >actual &&
+ tail -n 5 <actual >actual.trimmed &&
+ test_cmp expect actual.trimmed
+'
+
test_expect_success 'split hunk "add -p (edit)"' '
# Split, say Edit and do nothing. Then:
#
@@ -403,6 +481,40 @@ test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
! grep "^+31" actual
'
+test_expect_success 'split hunk with incomplete line at end' '
+ git reset --hard &&
+ printf "missing LF" >>test &&
+ git add test &&
+ test_write_lines before 10 20 30 40 50 60 70 >test &&
+ git grep --cached missing &&
+ test_write_lines s n y q | git add -p &&
+ test_must_fail git grep --cached missing &&
+ git grep before &&
+ test_must_fail git grep --cached before
+'
+
+test_expect_failure 'edit, adding lines to the first hunk' '
+ test_write_lines 10 11 20 30 40 50 51 60 >test &&
+ git reset &&
+ tr _ " " >patch <<-EOF &&
+ @@ -1,5 +1,6 @@
+ _10
+ +11
+ +12
+ _20
+ +21
+ +22
+ _30
+ EOF
+ # test sequence is s(plit), e(dit), n(o)
+ # q n q q is there to make sure we exit at the end.
+ printf "%s\n" s e n q n q q |
+ EDITOR=./fake_editor.sh git add -p 2>error &&
+ test_must_be_empty error &&
+ git diff --cached >actual &&
+ grep "^+22" actual
+'
+
test_expect_success 'patch mode ignores unmerged entries' '
git reset --hard &&
test_commit conflict &&
@@ -429,35 +541,48 @@ test_expect_success 'patch mode ignores unmerged entries' '
diff_cmp expected diff
'
-test_expect_success TTY 'diffs can be colorized' '
+test_expect_success 'diffs can be colorized' '
git reset --hard &&
echo content >test &&
- printf y | test_terminal git add -p >output 2>&1 &&
+ printf y >y &&
+ force_color git add -p >output 2>&1 <y &&
# We do not want to depend on the exact coloring scheme
# git uses for diffs, so just check that we saw some kind of color.
grep "$(printf "\\033")" output
'
-test_expect_success TTY 'diffFilter filters diff' '
+test_expect_success 'diffFilter filters diff' '
git reset --hard &&
echo content >test &&
test_config interactive.diffFilter "sed s/^/foo:/" &&
- printf y | test_terminal git add -p >output 2>&1 &&
+ printf y >y &&
+ force_color git add -p >output 2>&1 <y &&
# avoid depending on the exact coloring or content of the prompts,
# and just make sure we saw our diff prefixed
grep foo:.*content output
'
-test_expect_success TTY 'detect bogus diffFilter output' '
+test_expect_success 'detect bogus diffFilter output' '
git reset --hard &&
echo content >test &&
- test_config interactive.diffFilter "echo too-short" &&
- printf y | test_must_fail test_terminal git add -p
+ test_config interactive.diffFilter "sed 1d" &&
+ printf y >y &&
+ test_must_fail force_color git add -p <y
+'
+
+test_expect_success 'diff.algorithm is passed to `git diff-files`' '
+ git reset --hard &&
+
+ >file &&
+ git add file &&
+ echo changed >file &&
+ test_must_fail git -c diff.algorithm=bogus add -p 2>err &&
+ test_i18ngrep "error: option diff-algorithm accepts " err
'
test_expect_success 'patch-mode via -i prompts for files' '
@@ -667,7 +792,7 @@ test_expect_success 'show help from add--helper' '
<BOLD;BLUE>What now<RESET>>$SP
Bye.
EOF
- test_write_lines h | GIT_PAGER_IN_USE=true TERM=vt100 git add -i >actual.colored &&
+ test_write_lines h | force_color git add -i >actual.colored &&
test_decode_color <actual.colored >actual &&
test_i18ncmp expect actual
'
diff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh
new file mode 100755
index 0000000000..9e35c1fbca
--- /dev/null
+++ b/t/t3704-add-pathspec-file.sh
@@ -0,0 +1,159 @@
+#!/bin/sh
+
+test_description='add --pathspec-from-file'
+
+. ./test-lib.sh
+
+test_tick
+
+test_expect_success setup '
+ test_commit file0 &&
+ echo A >fileA.t &&
+ echo B >fileB.t &&
+ echo C >fileC.t &&
+ echo D >fileD.t
+'
+
+restore_checkpoint () {
+ git reset
+}
+
+verify_expect () {
+ git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success '--pathspec-from-file from stdin' '
+ restore_checkpoint &&
+
+ echo fileA.t | git add --pathspec-from-file=- &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success '--pathspec-from-file from file' '
+ restore_checkpoint &&
+
+ echo fileA.t >list &&
+ git add --pathspec-from-file=list &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'NUL delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\0fileB.t\0" | git add --pathspec-from-file=- --pathspec-file-nul &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ A fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'LF delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\nfileB.t\n" | git add --pathspec-from-file=- &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ A fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'no trailing delimiter' '
+ restore_checkpoint &&
+
+ printf "fileA.t\nfileB.t" | git add --pathspec-from-file=- &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ A fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'CRLF delimiters' '
+ restore_checkpoint &&
+
+ printf "fileA.t\r\nfileB.t\r\n" | git add --pathspec-from-file=- &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ A fileB.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'quotes' '
+ restore_checkpoint &&
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ git add --pathspec-from-file=list &&
+
+ cat >expect <<-\EOF &&
+ A fileA.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'quotes not compatible with --pathspec-file-nul' '
+ restore_checkpoint &&
+
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ test_must_fail git add --pathspec-from-file=list --pathspec-file-nul
+'
+
+test_expect_success 'only touches what was listed' '
+ restore_checkpoint &&
+
+ printf "fileB.t\nfileC.t\n" | git add --pathspec-from-file=- &&
+
+ cat >expect <<-\EOF &&
+ A fileB.t
+ A fileC.t
+ EOF
+ verify_expect
+'
+
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ >empty_list &&
+
+ test_must_fail git add --pathspec-from-file=list --interactive 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git add --pathspec-from-file=list --patch 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git add --pathspec-from-file=list --edit 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --edit" err &&
+
+ test_must_fail git add --pathspec-from-file=list -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git add --pathspec-file-nul 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ # This case succeeds, but still prints to stderr
+ git add --pathspec-from-file=empty_list 2>err &&
+ test_i18ngrep -e "Nothing specified, nothing added." err
+'
+
+test_done
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 69267b16f0..b653dd7d44 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -793,6 +793,38 @@ test_expect_success 'format-patch with multiple notes refs' '
! grep "this is note 2" out
'
+test_expect_success 'format-patch with multiple notes refs in config' '
+ test_when_finished "test_unconfig format.notes" &&
+
+ git notes --ref note1 add -m "this is note 1" HEAD &&
+ test_when_finished git notes --ref note1 remove HEAD &&
+ git notes --ref note2 add -m "this is note 2" HEAD &&
+ test_when_finished git notes --ref note2 remove HEAD &&
+
+ git config format.notes note1 &&
+ git format-patch -1 --stdout >out &&
+ grep "this is note 1" out &&
+ ! grep "this is note 2" out &&
+ git config format.notes note2 &&
+ git format-patch -1 --stdout >out &&
+ ! grep "this is note 1" out &&
+ grep "this is note 2" out &&
+ git config --add format.notes note1 &&
+ git format-patch -1 --stdout >out &&
+ grep "this is note 1" out &&
+ grep "this is note 2" out &&
+
+ git config --replace-all format.notes note1 &&
+ git config --add format.notes false &&
+ git format-patch -1 --stdout >out &&
+ ! grep "this is note 1" out &&
+ ! grep "this is note 2" out &&
+ git config --add format.notes note2 &&
+ git format-patch -1 --stdout >out &&
+ ! grep "this is note 1" out &&
+ grep "this is note 2" out
+'
+
echo "fatal: --name-only does not make sense" >expect.name-only
echo "fatal: --name-status does not make sense" >expect.name-status
echo "fatal: --check does not make sense" >expect.check
@@ -1939,10 +1971,9 @@ test_expect_success 'format-patch errors out when history involves criss-cross'
test_must_fail git format-patch --base=auto -1
'
-test_expect_success 'format-patch format.useAutoBaseoption' '
- test_when_finished "git config --unset format.useAutoBase" &&
+test_expect_success 'format-patch format.useAutoBase option' '
git checkout local &&
- git config format.useAutoBase true &&
+ test_config format.useAutoBase true &&
git format-patch --stdout -1 >patch &&
grep "^base-commit:" patch >actual &&
git rev-parse upstream >commit-id-base &&
@@ -1951,8 +1982,7 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
'
test_expect_success 'format-patch --base overrides format.useAutoBase' '
- test_when_finished "git config --unset format.useAutoBase" &&
- git config format.useAutoBase true &&
+ test_config format.useAutoBase true &&
git format-patch --stdout --base=HEAD~1 -1 >patch &&
grep "^base-commit:" patch >actual &&
git rev-parse HEAD~1 >commit-id-base &&
@@ -1960,6 +1990,12 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
test_cmp expect actual
'
+test_expect_success 'format-patch --no-base overrides format.useAutoBase' '
+ test_config format.useAutoBase true &&
+ git format-patch --stdout --no-base -1 >patch &&
+ ! grep "^base-commit:" patch
+'
+
test_expect_success 'format-patch --base with --attach' '
git format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&
sed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index eadaf57262..88d3026894 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -16,7 +16,8 @@ test_expect_success "Ray Lehtiniemi's example" '
} while (0);
EOF
git update-index --add x &&
- before=$(git rev-parse --short $(git hash-object x)) &&
+ old_hash_x=$(git hash-object x) &&
+ before=$(git rev-parse --short "$old_hash_x") &&
cat <<-\EOF >x &&
do
@@ -25,7 +26,8 @@ test_expect_success "Ray Lehtiniemi's example" '
}
while (0);
EOF
- after=$(git rev-parse --short $(git hash-object x)) &&
+ new_hash_x=$(git hash-object x) &&
+ after=$(git rev-parse --short "$new_hash_x") &&
cat <<-EOF >expect &&
diff --git a/x b/x
@@ -63,7 +65,8 @@ test_expect_success 'another test, without options' '
EOF
git update-index x &&
- before=$(git rev-parse --short $(git hash-object x)) &&
+ old_hash_x=$(git hash-object x) &&
+ before=$(git rev-parse --short "$old_hash_x") &&
tr "_" " " <<-\EOF >x &&
_ whitespace at beginning
@@ -73,7 +76,8 @@ test_expect_success 'another test, without options' '
unchanged line
CR at end
EOF
- after=$(git rev-parse --short $(git hash-object x)) &&
+ new_hash_x=$(git hash-object x) &&
+ after=$(git rev-parse --short "$new_hash_x") &&
tr "Q_" "\015 " <<-EOF >expect &&
diff --git a/x b/x
@@ -526,13 +530,15 @@ test_expect_success 'ignore-blank-lines: mix changes and blank lines' '
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" >x &&
- git diff --check | grep "space before tab in indent"
+ test_must_fail git diff --check >check &&
+ grep "space before tab in indent" check
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" >x &&
- git diff --check | grep "space before tab in indent"
+ test_must_fail git diff --check >check &&
+ grep "space before tab in indent" check
'
test_expect_success 'check with no whitespace errors' '
@@ -753,20 +759,23 @@ test_expect_success 'check tab-in-indent excluded from wildcard whitespace attri
test_expect_success 'line numbers in --check output are correct' '
echo "" >x &&
echo "foo(); " >>x &&
- git diff --check | grep "x:2:"
+ test_must_fail git diff --check >check &&
+ grep "x:2:" check
'
test_expect_success 'checkdiff detects new trailing blank lines (1)' '
echo "foo();" >x &&
echo "" >>x &&
- git diff --check | grep "new blank line"
+ test_must_fail git diff --check >check &&
+ grep "new blank line" check
'
test_expect_success 'checkdiff detects new trailing blank lines (2)' '
- { echo a; echo b; echo; echo; } >x &&
+ test_write_lines a b "" "" >x &&
git add x &&
- { echo a; echo; echo; echo; echo; } >x &&
- git diff --check | grep "new blank line"
+ test_write_lines a "" "" "" "" >x &&
+ test_must_fail git diff --check >check &&
+ grep "new blank line" check
'
test_expect_success 'checkdiff allows new blank lines' '
@@ -794,14 +803,16 @@ test_expect_success 'whitespace-only changes reported across renames' '
git reset --hard &&
for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x &&
git add x &&
- before=$(git rev-parse --short $(git hash-object x)) &&
+ hash_x=$(git hash-object x) &&
+ before=$(git rev-parse --short "$hash_x") &&
git commit -m "base" &&
sed -e "5s/^/ /" x >z &&
git rm x &&
git add z &&
- after=$(git rev-parse --short $(git hash-object z)) &&
- git diff -w -M --cached |
- sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual &&
+ hash_z=$(git hash-object z) &&
+ after=$(git rev-parse --short "$hash_z") &&
+ git diff -w -M --cached >actual.raw &&
+ sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" actual.raw >actual &&
cat <<-EOF >expect &&
diff --git a/x b/z
similarity index NUM%
@@ -840,7 +851,8 @@ test_expect_success 'combined diff with autocrlf conversion' '
git config core.autocrlf true &&
test_must_fail git merge master &&
- git diff | sed -e "1,/^@@@/d" >actual &&
+ git diff >actual.raw &&
+ sed -e "1,/^@@@/d" actual.raw >actual &&
! grep "^-" actual
'
@@ -864,11 +876,14 @@ test_expect_success 'diff that introduces a line with only tabs' '
git config core.whitespace blank-at-eol &&
git reset --hard &&
echo "test" >x &&
- before=$(git rev-parse --short $(git hash-object x)) &&
+ old_hash_x=$(git hash-object x) &&
+ before=$(git rev-parse --short "$old_hash_x") &&
git commit -m "initial" x &&
echo "{NTN}" | tr "NT" "\n\t" >>x &&
- after=$(git rev-parse --short $(git hash-object x)) &&
- git diff --color | test_decode_color >current &&
+ new_hash_x=$(git hash-object x) &&
+ after=$(git rev-parse --short "$new_hash_x") &&
+ git diff --color >current.raw &&
+ test_decode_color <current.raw >current &&
cat >expected <<-EOF &&
<BOLD>diff --git a/x b/x<RESET>
@@ -891,17 +906,19 @@ test_expect_success 'diff that introduces and removes ws breakages' '
echo "0. blank-at-eol " &&
echo "1. blank-at-eol "
} >x &&
- before=$(git rev-parse --short $(git hash-object x)) &&
+ old_hash_x=$(git hash-object x) &&
+ before=$(git rev-parse --short "$old_hash_x") &&
git commit -a --allow-empty -m preimage &&
{
echo "0. blank-at-eol " &&
echo "1. still-blank-at-eol " &&
echo "2. and a new line "
} >x &&
- after=$(git rev-parse --short $(git hash-object x)) &&
+ new_hash_x=$(git hash-object x) &&
+ after=$(git rev-parse --short "$new_hash_x") &&
- git diff --color |
- test_decode_color >current &&
+ git diff --color >current.raw &&
+ test_decode_color <current.raw >current &&
cat >expected <<-EOF &&
<BOLD>diff --git a/x b/x<RESET>
@@ -925,14 +942,16 @@ test_expect_success 'ws-error-highlight test setup' '
echo "0. blank-at-eol " &&
echo "1. blank-at-eol "
} >x &&
- before=$(git rev-parse --short $(git hash-object x)) &&
+ old_hash_x=$(git hash-object x) &&
+ before=$(git rev-parse --short "$old_hash_x") &&
git commit -a --allow-empty -m preimage &&
{
echo "0. blank-at-eol " &&
echo "1. still-blank-at-eol " &&
echo "2. and a new line "
} >x &&
- after=$(git rev-parse --short $(git hash-object x)) &&
+ new_hash_x=$(git hash-object x) &&
+ after=$(git rev-parse --short "$new_hash_x") &&
cat >expect.default-old <<-EOF &&
<BOLD>diff --git a/x b/x<RESET>
@@ -974,32 +993,32 @@ test_expect_success 'ws-error-highlight test setup' '
test_expect_success 'test --ws-error-highlight option' '
- git diff --color --ws-error-highlight=default,old |
- test_decode_color >current &&
+ git diff --color --ws-error-highlight=default,old >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.default-old current &&
- git diff --color --ws-error-highlight=all |
- test_decode_color >current &&
+ git diff --color --ws-error-highlight=all >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.all current &&
- git diff --color --ws-error-highlight=none |
- test_decode_color >current &&
+ git diff --color --ws-error-highlight=none >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.none current
'
test_expect_success 'test diff.wsErrorHighlight config' '
- git -c diff.wsErrorHighlight=default,old diff --color |
- test_decode_color >current &&
+ git -c diff.wsErrorHighlight=default,old diff --color >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.default-old current &&
- git -c diff.wsErrorHighlight=all diff --color |
- test_decode_color >current &&
+ git -c diff.wsErrorHighlight=all diff --color >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.all current &&
- git -c diff.wsErrorHighlight=none diff --color |
- test_decode_color >current &&
+ git -c diff.wsErrorHighlight=none diff --color >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.none current
'
@@ -1007,18 +1026,18 @@ test_expect_success 'test diff.wsErrorHighlight config' '
test_expect_success 'option overrides diff.wsErrorHighlight' '
git -c diff.wsErrorHighlight=none \
- diff --color --ws-error-highlight=default,old |
- test_decode_color >current &&
+ diff --color --ws-error-highlight=default,old >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.default-old current &&
git -c diff.wsErrorHighlight=default \
- diff --color --ws-error-highlight=all |
- test_decode_color >current &&
+ diff --color --ws-error-highlight=all >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.all current &&
git -c diff.wsErrorHighlight=all \
- diff --color --ws-error-highlight=none |
- test_decode_color >current &&
+ diff --color --ws-error-highlight=none >current.raw &&
+ test_decode_color <current.raw >current &&
test_cmp expect.none current
'
@@ -1038,7 +1057,8 @@ test_expect_success 'detect moved code, complete file' '
git mv test.c main.c &&
test_config color.diff.oldMoved "normal red" &&
test_config color.diff.newMoved "normal green" &&
- git diff HEAD --color-moved=zebra --color --no-renames | test_decode_color >actual &&
+ git diff HEAD --color-moved=zebra --color --no-renames >actual.raw &&
+ test_decode_color <actual.raw >actual &&
cat >expected <<-EOF &&
<BOLD>diff --git a/main.c b/main.c<RESET>
<BOLD>new file mode 100644<RESET>
@@ -1141,9 +1161,12 @@ test_expect_success 'detect malicious moved code, inside file' '
bar();
}
EOF
- after_main=$(git rev-parse --short $(git hash-object main.c)) &&
- after_test=$(git rev-parse --short $(git hash-object test.c)) &&
- git diff HEAD --no-renames --color-moved=zebra --color | test_decode_color >actual &&
+ hash_main=$(git hash-object main.c) &&
+ after_main=$(git rev-parse --short "$hash_main") &&
+ hash_test=$(git hash-object test.c) &&
+ after_test=$(git rev-parse --short "$hash_test") &&
+ git diff HEAD --no-renames --color-moved=zebra --color >actual.raw &&
+ test_decode_color <actual.raw >actual &&
cat <<-EOF >expected &&
<BOLD>diff --git a/main.c b/main.c<RESET>
<BOLD>index $before_main..$after_main 100644<RESET>
@@ -1192,7 +1215,8 @@ test_expect_success 'plain moved code, inside file' '
test_config color.diff.oldMovedAlternative "blue" &&
test_config color.diff.newMovedAlternative "yellow" &&
# needs previous test as setup
- git diff HEAD --no-renames --color-moved=plain --color | test_decode_color >actual &&
+ git diff HEAD --no-renames --color-moved=plain --color >actual.raw &&
+ test_decode_color <actual.raw >actual &&
cat <<-EOF >expected &&
<BOLD>diff --git a/main.c b/main.c<RESET>
<BOLD>index $before_main..$after_main 100644<RESET>
@@ -1771,7 +1795,8 @@ test_expect_success 'move detection with submodules' '
! grep BRED decoded_actual &&
# nor did we mess with it another way
- git diff --submodule=diff --color | test_decode_color >expect &&
+ git diff --submodule=diff --color >expect.raw &&
+ test_decode_color <expect.raw >expect &&
test_cmp expect decoded_actual &&
rm -rf bananas &&
git submodule deinit bananas
@@ -2025,11 +2050,6 @@ test_expect_success 'compare mixed whitespace delta across moved blocks' '
test_cmp expected actual
'
-# Note that the "6" in the expected hunk header below is funny, since we only
-# show 5 lines (the missing one was blank and thus ignored). This is how
-# --ignore-blank-lines behaves even without --function-context, and this test
-# is just checking the interaction of the two features. Don't take it as an
-# endorsement of that output.
test_expect_success 'combine --ignore-blank-lines with --function-context' '
test_write_lines 1 "" 2 3 4 5 >a &&
test_write_lines 1 2 3 4 >b &&
@@ -2039,6 +2059,7 @@ test_expect_success 'combine --ignore-blank-lines with --function-context' '
cat <<-\EOF >expect &&
@@ -1,6 +1,4 @@
1
+ -
2
3
4
@@ -2047,4 +2068,27 @@ test_expect_success 'combine --ignore-blank-lines with --function-context' '
test_cmp expect actual
'
+test_expect_success 'combine --ignore-blank-lines with --function-context 2' '
+ test_write_lines a b c "" function 1 2 3 4 5 "" 6 7 8 9 >a &&
+ test_write_lines "" a b c "" function 1 2 3 4 5 6 7 8 >b &&
+ test_must_fail git diff --no-index \
+ --ignore-blank-lines --function-context a b >actual.raw &&
+ sed -n "/@@/,\$p" <actual.raw >actual &&
+ cat <<-\EOF >expect &&
+ @@ -5,11 +6,9 @@ c
+ function
+ 1
+ 2
+ 3
+ 4
+ 5
+ -
+ 6
+ 7
+ 8
+ -9
+ EOF
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index c0f4839543..02255a08bf 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -106,7 +106,6 @@ do
result=success
fi
test_expect_$result "hunk header: $i" "
- test_when_finished 'cat actual' && # for debugging only
git diff -U1 $i >actual &&
grep '@@ .* @@.*RIGHT' actual
"
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 3b636a63a3..b19faeb67a 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -17,8 +17,8 @@ test_expect_success setup '
printf "\t%s\n" 1 2 3 >after &&
printf "%64s\n" a b c >>after &&
printf "\t%s\n" 4 5 6 >>after &&
- git diff --no-index before after |
- sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch &&
+ test_expect_code 1 git diff --no-index before after >patch1.patch.raw &&
+ sed -e "s/before/test-1/" -e "s/after/test-1/" patch1.patch.raw >patch1.patch &&
printf "%64s\n" 1 2 3 4 5 6 >test-1 &&
printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 &&
@@ -33,8 +33,8 @@ test_expect_success setup '
x=$(( $x + 1 ))
done &&
printf "\t%s\n" d e f >>after &&
- git diff --no-index before after |
- sed -e "s/before/test-2/" -e "s/after/test-2/" >patch2.patch &&
+ test_expect_code 1 git diff --no-index before after >patch2.patch.raw &&
+ sed -e "s/before/test-2/" -e "s/after/test-2/" patch2.patch.raw >patch2.patch &&
printf "%64s\n" a b c d e f >test-2 &&
printf "%64s\n" a b c >expect-2 &&
x=1 &&
@@ -56,8 +56,8 @@ test_expect_success setup '
x=$(( $x + 1 ))
done &&
printf "\t%s\n" d e f >>after &&
- git diff --no-index before after |
- sed -e "s/before/test-3/" -e "s/after/test-3/" >patch3.patch &&
+ test_expect_code 1 git diff --no-index before after >patch3.patch.raw &&
+ sed -e "s/before/test-3/" -e "s/after/test-3/" patch3.patch.raw >patch3.patch &&
printf "%64s\n" a b c d e f >test-3 &&
printf "%64s\n" a b c >expect-3 &&
x=0 &&
@@ -84,8 +84,8 @@ test_expect_success setup '
printf "\t%02d\n" $x >>after
x=$(( $x + 1 ))
done &&
- git diff --no-index before after |
- sed -e "s/before/test-4/" -e "s/after/test-4/" >patch4.patch &&
+ test_expect_code 1 git diff --no-index before after >patch4.patch.raw &&
+ sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch &&
>test-4 &&
x=0 &&
while test $x -lt 50
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2f251b27d0..204c149d5a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -134,6 +134,36 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '
test_cmp expected actual
'
+for p in short medium full fuller email raw
+do
+ test_expect_success "NUL termination with --reflog --pretty=$p" '
+ revs="$(git rev-list --reflog)" &&
+ for r in $revs
+ do
+ git show -s "$r" --pretty="$p" &&
+ printf "\0" || return 1
+ done >expect &&
+ {
+ git log -z --reflog --pretty="$p" &&
+ printf "\0"
+ } >actual &&
+ test_cmp expect actual
+ '
+done
+
+test_expect_success 'NUL termination with --reflog --pretty=oneline' '
+ revs="$(git rev-list --reflog)" &&
+ for r in $revs
+ do
+ git show -s --pretty=oneline "$r" >raw &&
+ cat raw | lf_to_nul || exit 1
+ done >expect &&
+ # the trailing NUL is already produced so we do not need to
+ # output another one
+ git log -z --pretty=oneline --reflog >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'setup more commits' '
test_commit "message one" one one message-one &&
test_commit "message two" two two message-two &&
@@ -503,6 +533,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' '
test_cmp expected actual
'
+test_expect_success 'short date' '
+ git log --format=%ad%n%cd --date=short >expected &&
+ git log --format=%as%n%cs >actual &&
+ test_cmp expected actual
+'
+
# get new digests (with no abbreviations)
test_expect_success 'set up log decoration tests' '
head1=$(git rev-parse --verify HEAD~0) &&
@@ -788,4 +824,47 @@ test_expect_success '%S in git log --format works with other placeholders (part
test_cmp expect actual
'
+test_expect_success 'log --pretty=reference' '
+ git log --pretty="tformat:%h (%s, %as)" >expect &&
+ git log --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=reference with log.date is overridden by short date' '
+ git log --pretty="tformat:%h (%s, %as)" >expect &&
+ test_config log.date rfc &&
+ git log --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=reference with explicit date overrides short date' '
+ git log --date=rfc --pretty="tformat:%h (%s, %ad)" >expect &&
+ git log --date=rfc --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=reference is never unabbreviated' '
+ git log --pretty="tformat:%h (%s, %as)" >expect &&
+ git log --no-abbrev-commit --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=reference is never decorated' '
+ git log --pretty="tformat:%h (%s, %as)" >expect &&
+ git log --decorate=short --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=reference does not output reflog info' '
+ git log --walk-reflogs --pretty="tformat:%h (%s, %as)" >expect &&
+ git log --walk-reflogs --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=reference is colored appropriately' '
+ git log --color=always --pretty="tformat:%C(auto)%h (%s, %as)" >expect &&
+ git log --color=always --pretty=reference >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh
index 6e61f57f09..c3792081e6 100755
--- a/t/t4210-log-i18n.sh
+++ b/t/t4210-log-i18n.sh
@@ -70,7 +70,7 @@ do
then
force_regex=.*
fi
- test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not find non-reencoded values (latin1 + locale)" "
+ test_expect_success !MINGW,!REGEX_ILLSEQ,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not find non-reencoded values (latin1 + locale)" "
cat >expect <<-\EOF &&
latin1
utf8
@@ -84,7 +84,7 @@ do
test_must_be_empty actual
"
- test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not die on invalid UTF-8 value (latin1 + locale + invalid needle)" "
+ test_expect_success !MINGW,!REGEX_ILLSEQ,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not die on invalid UTF-8 value (latin1 + locale + invalid needle)" "
LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$invalid_e\" >actual &&
test_must_be_empty actual
"
diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh
index 18709a723e..1d0d3240ff 100755
--- a/t/t4215-log-skewed-merges.sh
+++ b/t/t4215-log-skewed-merges.sh
@@ -240,4 +240,137 @@ test_expect_success 'log --graph with octopus merge with column joining its penu
EOF
'
+test_expect_success 'log --graph with multiple tips' '
+ git checkout --orphan 6_1 &&
+ test_commit 6_A &&
+ git branch 6_2 &&
+ git branch 6_4 &&
+ test_commit 6_B &&
+ git branch 6_3 &&
+ test_commit 6_C &&
+ git checkout 6_2 && test_commit 6_D &&
+ git checkout 6_3 && test_commit 6_E &&
+ git checkout -b 6_5 6_1 &&
+ git merge --no-ff 6_2 -m 6_F &&
+ git checkout 6_4 && test_commit 6_G &&
+ git checkout 6_3 &&
+ git merge --no-ff 6_4 -m 6_H &&
+ git checkout 6_1 &&
+ git merge --no-ff 6_2 -m 6_I &&
+
+ check_graph 6_1 6_3 6_5 <<-\EOF
+ * 6_I
+ |\
+ | | * 6_H
+ | | |\
+ | | | * 6_G
+ | | * | 6_E
+ | | | | * 6_F
+ | |_|_|/|
+ |/| | |/
+ | | |/|
+ | |/| |
+ | * | | 6_D
+ | | |/
+ | |/|
+ * | | 6_C
+ | |/
+ |/|
+ * | 6_B
+ |/
+ * 6_A
+ EOF
+'
+
+test_expect_success 'log --graph with multiple tips and colors' '
+ test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
+ cat >expect.colors <<-\EOF &&
+ * 6_I
+ <RED>|<RESET><GREEN>\<RESET>
+ <RED>|<RESET> <GREEN>|<RESET> * 6_H
+ <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET>
+ <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 6_G
+ <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 6_F
+ <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET><GREEN>|<RESET>
+ <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET><GREEN>/<RESET>
+ <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><GREEN>/<RESET><BLUE>|<RESET>
+ <RED>|<RESET> <GREEN>|<RESET><GREEN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
+ <RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 6_E
+ <RED>|<RESET> * <CYAN>|<RESET> <BLUE>|<RESET> 6_D
+ <RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><BLUE>/<RESET>
+ <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET><CYAN>|<RESET>
+ * <BLUE>|<RESET> <CYAN>|<RESET> 6_C
+ <CYAN>|<RESET> <BLUE>|<RESET><CYAN>/<RESET>
+ <CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
+ * <BLUE>|<RESET> 6_B
+ <BLUE>|<RESET><BLUE>/<RESET>
+ * 6_A
+ EOF
+ git log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&
+ test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
+ test_cmp expect.colors actual.colors
+'
+
+test_expect_success 'log --graph with multiple tips' '
+ git checkout --orphan 7_1 &&
+ test_commit 7_A &&
+ test_commit 7_B &&
+ test_commit 7_C &&
+ git checkout -b 7_2 7_1~2 &&
+ test_commit 7_D &&
+ test_commit 7_E &&
+ git checkout -b 7_3 7_1~1 &&
+ test_commit 7_F &&
+ test_commit 7_G &&
+ git checkout -b 7_4 7_2~1 &&
+ test_commit 7_H &&
+ git checkout -b 7_5 7_1~2 &&
+ test_commit 7_I &&
+ git checkout -b 7_6 7_3~1 &&
+ test_commit 7_J &&
+ git checkout -b M_1 7_1 &&
+ git merge --no-ff 7_2 -m 7_M1 &&
+ git checkout -b M_3 7_3 &&
+ git merge --no-ff 7_4 -m 7_M2 &&
+ git checkout -b M_5 7_5 &&
+ git merge --no-ff 7_6 -m 7_M3 &&
+ git checkout -b M_7 7_1 &&
+ git merge --no-ff 7_2 7_3 -m 7_M4 &&
+
+ check_graph M_1 M_3 M_5 M_7 <<-\EOF
+ * 7_M1
+ |\
+ | | * 7_M2
+ | | |\
+ | | | * 7_H
+ | | | | * 7_M3
+ | | | | |\
+ | | | | | * 7_J
+ | | | | * | 7_I
+ | | | | | | * 7_M4
+ | |_|_|_|_|/|\
+ |/| | | | |/ /
+ | | |_|_|/| /
+ | |/| | | |/
+ | | | |_|/|
+ | | |/| | |
+ | | * | | | 7_G
+ | | | |_|/
+ | | |/| |
+ | | * | | 7_F
+ | * | | | 7_E
+ | | |/ /
+ | |/| |
+ | * | | 7_D
+ | | |/
+ | |/|
+ * | | 7_C
+ | |/
+ |/|
+ * | 7_B
+ |/
+ * 7_A
+ EOF
+'
+
test_done
diff --git a/t/t4256-am-format-flowed.sh b/t/t4256-am-format-flowed.sh
index 6340310e9a..2369c4e17a 100755
--- a/t/t4256-am-format-flowed.sh
+++ b/t/t4256-am-format-flowed.sh
@@ -11,7 +11,7 @@ test_expect_success 'setup' '
'
test_expect_success 'am with format=flowed' '
- git am <"$TEST_DIRECTORY/t4256/1/patch" >stdout 2>stderr &&
+ git am <"$TEST_DIRECTORY/t4256/1/patch" 2>stderr &&
test_i18ngrep "warning: Patch sent with format=flowed" stderr &&
test_cmp "$TEST_DIRECTORY/t4256/1/mailinfo.c" mailinfo.c
'
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index 852dcd913f..1ad4ecc29a 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -4,6 +4,12 @@ test_description='Test workflows involving pull request.'
. ./test-lib.sh
+if ! test_have_prereq PERL
+then
+ skip_all='skipping request-pull tests, perl not available'
+ test_done
+fi
+
test_expect_success 'setup' '
git init --bare upstream.git &&
diff --git a/t/t5314-pack-cycle-detection.sh b/t/t5314-pack-cycle-detection.sh
index e525466de0..0aec8619e2 100755
--- a/t/t5314-pack-cycle-detection.sh
+++ b/t/t5314-pack-cycle-detection.sh
@@ -53,7 +53,7 @@ immediately after the lookup for "dummy".
-# Create a pack containing the the tree $1 and blob $1:file, with
+# Create a pack containing the tree $1 and blob $1:file, with
# the latter stored as a delta against $2:file.
#
# We convince pack-objects to make the delta in the direction of our choosing
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 2d2f5d0229..dc0446574b 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -45,12 +45,7 @@ test_expect_success 'verify blob:none packfile has no blobs' '
git -C r1 index-pack ../filter.pack &&
git -C r1 verify-pack -v ../filter.pack >verify_result &&
- grep blob verify_result |
- awk -f print_1.awk |
- sort >observed &&
-
- nr=$(wc -l <observed) &&
- test 0 -eq $nr
+ ! grep blob verify_result
'
test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
@@ -72,7 +67,8 @@ test_expect_success 'get an error for missing tree object' '
echo foo >r5/foo &&
git -C r5 add foo &&
git -C r5 commit -m "foo" &&
- del=$(git -C r5 rev-parse HEAD^{tree} | sed "s|..|&/|") &&
+ git -C r5 rev-parse HEAD^{tree} >tree &&
+ del=$(sed "s|..|&/|" tree) &&
rm r5/.git/objects/$del &&
test_must_fail git -C r5 pack-objects --revs --stdout 2>bad_tree <<-EOF &&
HEAD
@@ -148,12 +144,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack >verify_result &&
- grep blob verify_result |
- awk -f print_1.awk |
- sort >observed &&
-
- nr=$(wc -l <observed) &&
- test 0 -eq $nr
+ ! grep blob verify_result
'
test_expect_success 'verify blob:limit=1000' '
@@ -163,12 +154,7 @@ test_expect_success 'verify blob:limit=1000' '
git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack >verify_result &&
- grep blob verify_result |
- awk -f print_1.awk |
- sort >observed &&
-
- nr=$(wc -l <observed) &&
- test 0 -eq $nr
+ ! grep blob verify_result
'
test_expect_success 'verify blob:limit=1001' '
@@ -230,10 +216,9 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
awk -f print_2.awk ls_files_result |
sort >expected &&
- git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
- HEAD
- $(git -C r2 rev-parse HEAD:large.10000)
- EOF
+ echo HEAD >objects &&
+ git -C r2 rev-parse HEAD:large.10000 >>objects &&
+ git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k <objects >filter.pack &&
git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack >verify_result &&
@@ -377,7 +362,8 @@ test_expect_success 'verify sparse:oid=OID' '
awk -f print_2.awk ls_files_result |
sort >expected &&
- oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
+ git -C r4 ls-files -s pattern >staged &&
+ oid=$(awk -f print_2.awk staged) &&
git -C r4 pack-objects --revs --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
HEAD
EOF
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index d6b5cf2fc3..81cf118cb6 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -132,7 +132,7 @@ test_expect_success 'commit-graph write progress off for redirected stderr' '
test_expect_success 'commit-graph write force progress on for stderr' '
cd "$TRASH_DIRECTORY/full" &&
- git commit-graph write --progress 2>err &&
+ GIT_PROGRESS_DELAY=0 git commit-graph write --progress 2>err &&
test_file_not_empty err
'
@@ -150,7 +150,7 @@ test_expect_success 'commit-graph verify progress off for redirected stderr' '
test_expect_success 'commit-graph verify force progress on for stderr' '
cd "$TRASH_DIRECTORY/full" &&
- git commit-graph verify --progress 2>err &&
+ GIT_PROGRESS_DELAY=0 git commit-graph verify --progress 2>err &&
test_file_not_empty err
'
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 2ceae14164..566994cede 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -174,6 +174,30 @@ test_expect_success 'fetch --prune --tags with refspec prunes based on refspec'
git rev-parse sometag
'
+test_expect_success '--refmap="" ignores configured refspec' '
+ cd "$TRASH_DIRECTORY" &&
+ git clone "$D" remote-refs &&
+ git -C remote-refs rev-parse remotes/origin/master >old &&
+ git -C remote-refs update-ref refs/remotes/origin/master master~1 &&
+ git -C remote-refs rev-parse remotes/origin/master >new &&
+ git -C remote-refs fetch --refmap= origin "+refs/heads/*:refs/hidden/origin/*" &&
+ git -C remote-refs rev-parse remotes/origin/master >actual &&
+ test_cmp new actual &&
+ git -C remote-refs fetch origin &&
+ git -C remote-refs rev-parse remotes/origin/master >actual &&
+ test_cmp old actual
+'
+
+test_expect_success '--refmap="" and --prune' '
+ git -C remote-refs update-ref refs/remotes/origin/foo/otherbranch master &&
+ git -C remote-refs update-ref refs/hidden/foo/otherbranch master &&
+ git -C remote-refs fetch --prune --refmap="" origin +refs/heads/*:refs/hidden/* &&
+ git -C remote-refs rev-parse remotes/origin/foo/otherbranch &&
+ test_must_fail git -C remote-refs rev-parse refs/hidden/foo/otherbranch &&
+ git -C remote-refs fetch --prune origin &&
+ test_must_fail git -C remote-refs rev-parse remotes/origin/foo/otherbranch
+'
+
test_expect_success 'fetch tags when there is no tags' '
cd "$D" &&
diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh
index f70cbcc9ca..8f25f4b31f 100755
--- a/t/t5552-skipping-fetch-negotiator.sh
+++ b/t/t5552-skipping-fetch-negotiator.sh
@@ -107,7 +107,11 @@ test_expect_success 'use ref advertisement to filter out commits' '
# The ref advertisement itself is filtered when protocol v2 is used, so
# use v0.
- GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch &&
+ (
+ GIT_TEST_PROTOCOL_VERSION= &&
+ export GIT_TEST_PROTOCOL_VERSION &&
+ trace_fetch client origin to_fetch
+ ) &&
have_sent c5 c4^ c2side &&
have_not_sent c4 c4^^ c4^^^
'
@@ -169,7 +173,17 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
test_commit -C server commit-on-b1 &&
test_config -C client fetch.negotiationalgorithm skipping &&
- trace_fetch client "$(pwd)/server" to_fetch &&
+
+ # NEEDSWORK: The number of "have"s sent depends on whether the transport
+ # is stateful. If the overspecification of the result were reduced, this
+ # test could be used for both stateful and stateless transports.
+ (
+ # Force protocol v0, in which local transport is stateful (in
+ # protocol v2 it is stateless).
+ GIT_TEST_PROTOCOL_VERSION=0 &&
+ export GIT_TEST_PROTOCOL_VERSION &&
+ trace_fetch client "$(pwd)/server" to_fetch
+ ) &&
grep " fetch" trace &&
# fetch-pack sends 2 requests each containing 16 "have" lines before
diff --git a/t/t5573-pull-verify-signatures.sh b/t/t5573-pull-verify-signatures.sh
index 3e9876e197..a53dd8550d 100755
--- a/t/t5573-pull-verify-signatures.sh
+++ b/t/t5573-pull-verify-signatures.sh
@@ -60,6 +60,27 @@ test_expect_success GPG 'pull commit with untrusted signature with --verify-sign
test_i18ngrep "has an untrusted GPG signature" pullerror
'
+test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=ultimate' '
+ test_when_finished "git reset --hard && git checkout initial" &&
+ test_config gpg.minTrustLevel ultimate &&
+ test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror &&
+ test_i18ngrep "has an untrusted GPG signature" pullerror
+'
+
+test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=marginal' '
+ test_when_finished "git reset --hard && git checkout initial" &&
+ test_config gpg.minTrustLevel marginal &&
+ test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror &&
+ test_i18ngrep "has an untrusted GPG signature" pullerror
+'
+
+test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=undefined' '
+ test_when_finished "git reset --hard && git checkout initial" &&
+ test_config gpg.minTrustLevel undefined &&
+ git pull --ff-only --verify-signatures untrusted >pulloutput &&
+ test_i18ngrep "has a good GPG signature" pulloutput
+'
+
test_expect_success GPG 'pull signed commit with --verify-signatures' '
test_when_finished "git reset --hard && git checkout initial" &&
git pull --verify-signatures signed >pulloutput &&
@@ -79,10 +100,53 @@ test_expect_success GPG 'pull commit with bad signature with --no-verify-signatu
'
test_expect_success GPG 'pull unsigned commit into unborn branch' '
+ test_when_finished "rm -rf empty-repo" &&
git init empty-repo &&
test_must_fail \
git -C empty-repo pull --verify-signatures .. 2>pullerror &&
test_i18ngrep "does not have a GPG signature" pullerror
'
+test_expect_success GPG 'pull commit into unborn branch with bad signature and --verify-signatures' '
+ test_when_finished "rm -rf empty-repo" &&
+ git init empty-repo &&
+ test_must_fail \
+ git -C empty-repo pull --ff-only --verify-signatures ../bad 2>pullerror &&
+ test_i18ngrep "has a bad GPG signature" pullerror
+'
+
+test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures' '
+ test_when_finished "rm -rf empty-repo" &&
+ git init empty-repo &&
+ test_must_fail \
+ git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror &&
+ test_i18ngrep "has an untrusted GPG signature" pullerror
+'
+
+test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=ultimate' '
+ test_when_finished "rm -rf empty-repo" &&
+ git init empty-repo &&
+ test_config_global gpg.minTrustLevel ultimate &&
+ test_must_fail \
+ git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror &&
+ test_i18ngrep "has an untrusted GPG signature" pullerror
+'
+
+test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=marginal' '
+ test_when_finished "rm -rf empty-repo" &&
+ git init empty-repo &&
+ test_config_global gpg.minTrustLevel marginal &&
+ test_must_fail \
+ git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror &&
+ test_i18ngrep "has an untrusted GPG signature" pullerror
+'
+
+test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=undefined' '
+ test_when_finished "rm -rf empty-repo" &&
+ git init empty-repo &&
+ test_config_global gpg.minTrustLevel undefined &&
+ git -C empty-repo pull --ff-only --verify-signatures ../untrusted >pulloutput &&
+ test_i18ngrep "has a good GPG signature" pulloutput
+'
+
test_done
diff --git a/t/t5580-clone-push-unc.sh b/t/t5580-clone-push-unc.sh
index b3c8a92450..01b52c195a 100755
--- a/t/t5580-clone-push-unc.sh
+++ b/t/t5580-clone-push-unc.sh
@@ -58,7 +58,7 @@ test_expect_success push '
test_expect_success MINGW 'remote nick cannot contain backslashes' '
BACKSLASHED="$(winpwd | tr / \\\\)" &&
- git ls-remote "$BACKSLASHED" >out 2>err &&
+ git ls-remote "$BACKSLASHED" 2>err &&
test_i18ngrep ! "unable to access" err
'
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index e73067d23f..7fd7102c87 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -665,6 +665,18 @@ test_expect_success 'fetch from namespaced repo respects namespaces' '
test_cmp expect actual
'
+test_expect_success 'ls-remote with v2 http sends only one POST' '
+ test_when_finished "rm -f log" &&
+
+ git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
+ GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
+ ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
+ test_cmp expect actual &&
+
+ grep "Send header: POST" log >posts &&
+ test_line_count = 1 posts
+'
+
test_expect_success 'push with http:// and a config of v2 does not request v2' '
test_when_finished "rm -f log" &&
# Till v2 for push is designed, make sure that if a client has
diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
index 3a2c143c6d..1424fabd4a 100755
--- a/t/t5703-upload-pack-ref-in-want.sh
+++ b/t/t5703-upload-pack-ref-in-want.sh
@@ -18,14 +18,16 @@ get_actual_commits () {
p
}' <out | test-tool pkt-line unpack-sideband >o.pack &&
git index-pack o.pack &&
- git verify-pack -v o.idx | grep commit | cut -c-40 | sort >actual_commits
+ git verify-pack -v o.idx >objs &&
+ grep commit objs | cut -c-40 | sort >actual_commits
}
check_output () {
get_actual_refs &&
test_cmp expected_refs actual_refs &&
get_actual_commits &&
- test_cmp expected_commits actual_commits
+ sort expected_commits >sorted_commits &&
+ test_cmp sorted_commits actual_commits
}
# c(o/foo) d(o/bar)
@@ -75,17 +77,19 @@ test_expect_success 'invalid want-ref line' '
'
test_expect_success 'basic want-ref' '
+ oid=$(git rev-parse f) &&
cat >expected_refs <<-EOF &&
- $(git rev-parse f) refs/heads/master
+ $oid refs/heads/master
EOF
- git rev-parse f | sort >expected_commits &&
+ git rev-parse f >expected_commits &&
+ oid=$(git rev-parse a) &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
0001
no-progress
want-ref refs/heads/master
- have $(git rev-parse a)
+ have $oid
done
0000
EOF
@@ -95,19 +99,22 @@ test_expect_success 'basic want-ref' '
'
test_expect_success 'multiple want-ref lines' '
+ oid_c=$(git rev-parse c) &&
+ oid_d=$(git rev-parse d) &&
cat >expected_refs <<-EOF &&
- $(git rev-parse c) refs/heads/o/foo
- $(git rev-parse d) refs/heads/o/bar
+ $oid_c refs/heads/o/foo
+ $oid_d refs/heads/o/bar
EOF
- git rev-parse c d | sort >expected_commits &&
+ git rev-parse c d >expected_commits &&
+ oid=$(git rev-parse b) &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
0001
no-progress
want-ref refs/heads/o/foo
want-ref refs/heads/o/bar
- have $(git rev-parse b)
+ have $oid
done
0000
EOF
@@ -117,10 +124,11 @@ test_expect_success 'multiple want-ref lines' '
'
test_expect_success 'mix want and want-ref' '
+ oid=$(git rev-parse f) &&
cat >expected_refs <<-EOF &&
- $(git rev-parse f) refs/heads/master
+ $oid refs/heads/master
EOF
- git rev-parse e f | sort >expected_commits &&
+ git rev-parse e f >expected_commits &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
@@ -138,17 +146,19 @@ test_expect_success 'mix want and want-ref' '
'
test_expect_success 'want-ref with ref we already have commit for' '
+ oid=$(git rev-parse c) &&
cat >expected_refs <<-EOF &&
- $(git rev-parse c) refs/heads/o/foo
+ $oid refs/heads/o/foo
EOF
>expected_commits &&
+ oid=$(git rev-parse c) &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
0001
no-progress
want-ref refs/heads/o/foo
- have $(git rev-parse c)
+ have $oid
done
0000
EOF
@@ -211,13 +221,14 @@ test_expect_success 'fetching with exact OID' '
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
+ oid=$(git -C "$REPO" rev-parse d) &&
GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
- $(git -C "$REPO" rev-parse d):refs/heads/actual &&
+ "$oid":refs/heads/actual &&
git -C "$REPO" rev-parse "d" >expected &&
git -C local rev-parse refs/heads/actual >actual &&
test_cmp expected actual &&
- grep "want $(git -C "$REPO" rev-parse d)" log
+ grep "want $oid" log
'
test_expect_success 'fetching multiple refs' '
@@ -239,13 +250,14 @@ test_expect_success 'fetching ref and exact OID' '
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
+ oid=$(git -C "$REPO" rev-parse b) &&
GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
- master $(git -C "$REPO" rev-parse b):refs/heads/actual &&
+ master "$oid":refs/heads/actual &&
git -C "$REPO" rev-parse "master" "b" >expected &&
git -C local rev-parse refs/remotes/origin/master refs/heads/actual >actual &&
test_cmp expected actual &&
- grep "want $(git -C "$REPO" rev-parse b)" log &&
+ grep "want $oid" log &&
grep "want-ref refs/heads/master" log
'
@@ -312,10 +324,9 @@ inconsistency () {
# repository appears to change during negotiation, for example, when
# different servers in a load-balancing arrangement serve (stateless)
# RPCs during a single negotiation.
- printf "s/%s/%s/" \
- $(git -C "$REPO" rev-parse $1 | tr -d "\n") \
- $(git -C "$REPO" rev-parse $2 | tr -d "\n") \
- >"$HTTPD_ROOT_PATH/one-time-sed"
+ oid1=$(git -C "$REPO" rev-parse $1) &&
+ oid2=$(git -C "$REPO" rev-parse $2) &&
+ echo "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-sed"
}
test_expect_success 'server is initially ahead - no ref in want' '
diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh
index 433c4de08f..6c0a90d044 100755
--- a/t/t6025-merge-symlinks.sh
+++ b/t/t6025-merge-symlinks.sh
@@ -10,52 +10,53 @@ if core.symlinks is false.'
. ./test-lib.sh
-test_expect_success \
-'setup' '
-git config core.symlinks false &&
-> file &&
-git add file &&
-git commit -m initial &&
-git branch b-symlink &&
-git branch b-file &&
-l=$(printf file | git hash-object -t blob -w --stdin) &&
-echo "120000 $l symlink" | git update-index --index-info &&
-git commit -m master &&
-git checkout b-symlink &&
-l=$(printf file-different | git hash-object -t blob -w --stdin) &&
-echo "120000 $l symlink" | git update-index --index-info &&
-git commit -m b-symlink &&
-git checkout b-file &&
-echo plain-file > symlink &&
-git add symlink &&
-git commit -m b-file'
-
-test_expect_success \
-'merge master into b-symlink, which has a different symbolic link' '
-git checkout b-symlink &&
-test_must_fail git merge master'
-
-test_expect_success \
-'the merge result must be a file' '
-test -f symlink'
-
-test_expect_success \
-'merge master into b-file, which has a file instead of a symbolic link' '
-git reset --hard && git checkout b-file &&
-test_must_fail git merge master'
-
-test_expect_success \
-'the merge result must be a file' '
-test -f symlink'
-
-test_expect_success \
-'merge b-file, which has a file instead of a symbolic link, into master' '
-git reset --hard &&
-git checkout master &&
-test_must_fail git merge b-file'
-
-test_expect_success \
-'the merge result must be a file' '
-test -f symlink'
+test_expect_success 'setup' '
+ git config core.symlinks false &&
+ >file &&
+ git add file &&
+ git commit -m initial &&
+ git branch b-symlink &&
+ git branch b-file &&
+ l=$(printf file | git hash-object -t blob -w --stdin) &&
+ echo "120000 $l symlink" | git update-index --index-info &&
+ git commit -m master &&
+ git checkout b-symlink &&
+ l=$(printf file-different | git hash-object -t blob -w --stdin) &&
+ echo "120000 $l symlink" | git update-index --index-info &&
+ git commit -m b-symlink &&
+ git checkout b-file &&
+ echo plain-file >symlink &&
+ git add symlink &&
+ git commit -m b-file
+'
+
+test_expect_success 'merge master into b-symlink, which has a different symbolic link' '
+ git checkout b-symlink &&
+ test_must_fail git merge master
+'
+
+test_expect_success 'the merge result must be a file' '
+ test_path_is_file symlink
+'
+
+test_expect_success 'merge master into b-file, which has a file instead of a symbolic link' '
+ git reset --hard &&
+ git checkout b-file &&
+ test_must_fail git merge master
+'
+
+test_expect_success 'the merge result must be a file' '
+ test_path_is_file symlink
+'
+
+test_expect_success 'merge b-file, which has a file instead of a symbolic link, into master' '
+ git reset --hard &&
+ git checkout master &&
+ test_must_fail git merge b-file
+'
+
+test_expect_success 'the merge result must be a file' '
+ test_path_is_file symlink
+'
test_done
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index bdc42e9440..821a0c88cf 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -482,7 +482,7 @@ test_expect_success 'optimized merge base checks' '
git bisect good > my_bisect_log2.txt &&
test -f ".git/BISECT_ANCESTORS_OK" &&
test "$HASH6" = $(git rev-parse --verify HEAD) &&
- git bisect bad > my_bisect_log3.txt &&
+ git bisect bad &&
git bisect good "$A_HASH" > my_bisect_log4.txt &&
test_i18ngrep "merge base must be tested" my_bisect_log4.txt &&
test_must_fail test -f ".git/BISECT_ANCESTORS_OK"
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 45047d0a72..09c50f3f04 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -1,28 +1,27 @@
#!/bin/sh
-test_description='test describe
+test_description='test describe'
+
+# o---o-----o----o----o-------o----x
+# \ D,R e /
+# \---o-------------o-'
+# \ B /
+# `-o----o----o-'
+# A c
+#
+# First parent of a merge commit is on the same line, second parent below.
- B
- .--------------o----o----o----x
- / / /
- o----o----o----o----o----. /
- \ A c /
- .------------o---o---o
- D,R e
-'
. ./test-lib.sh
check_describe () {
expect="$1"
shift
- R=$(git describe "$@" 2>err.actual)
- S=$?
- cat err.actual >&3
- test_expect_success "describe $*" '
- test $S = 0 &&
+ describe_opts="$@"
+ test_expect_success "describe $describe_opts" '
+ R=$(git describe $describe_opts 2>err.actual) &&
case "$R" in
$expect) echo happy ;;
- *) echo "Oops - $R is not $expect";
+ *) echo "Oops - $R is not $expect" &&
false ;;
esac
'
@@ -382,7 +381,7 @@ test_expect_success 'describe tag object' '
test_i18ngrep "fatal: test-blob-1 is neither a commit nor blob" actual
'
-test_expect_failure ULIMIT_STACK_SIZE 'name-rev works in a deep repo' '
+test_expect_success ULIMIT_STACK_SIZE 'name-rev works in a deep repo' '
i=1 &&
while test $i -lt 8000
do
@@ -439,4 +438,45 @@ test_expect_success 'name-rev a rev shortly after epoch' '
test_cmp expect actual
'
+# A--------------master
+# \ /
+# \----------M2
+# \ /
+# \---M1-C
+# \ /
+# B
+test_expect_success 'name-rev covers all conditions while looking at parents' '
+ git init repo &&
+ (
+ cd repo &&
+
+ echo A >file &&
+ git add file &&
+ git commit -m A &&
+ A=$(git rev-parse HEAD) &&
+
+ git checkout --detach &&
+ echo B >file &&
+ git commit -m B file &&
+ B=$(git rev-parse HEAD) &&
+
+ git checkout $A &&
+ git merge --no-ff $B && # M1
+
+ echo C >file &&
+ git commit -m C file &&
+
+ git checkout $A &&
+ git merge --no-ff HEAD@{1} && # M2
+
+ git checkout master &&
+ git merge --no-ff HEAD@{1} &&
+
+ echo "$B master^2^2~1^2" >expect &&
+ git name-rev $B >actual &&
+
+ test_cmp expect actual
+ )
+'
+
test_done
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index c0f04dc6b0..0a69a67117 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -103,14 +103,14 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre
'
test_expect_success 'gc --no-quiet' '
- git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
+ GIT_PROGRESS_DELAY=0 git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
test_must_be_empty stdout &&
- test_line_count = 1 stderr &&
test_i18ngrep "Computing commit graph generation numbers" stderr
'
test_expect_success TTY 'with TTY: gc --no-quiet' '
- test_terminal git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
+ test_terminal env GIT_PROGRESS_DELAY=0 \
+ git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
test_must_be_empty stdout &&
test_i18ngrep "Enumerating objects" stderr &&
test_i18ngrep "Computing commit graph generation numbers" stderr
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 4a09bea1d6..6db92bd3ba 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -517,7 +517,6 @@ test_expect_success \
test_expect_success \
'trying to create tags giving both -m or -F options should fail' '
echo "message file 1" >msgfile1 &&
- echo "message file 2" >msgfile2 &&
! tag_exists msgtag &&
test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
! tag_exists msgtag &&
diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh
index 8f077bea60..5c5bc32ccb 100755
--- a/t/t7030-verify-tag.sh
+++ b/t/t7030-verify-tag.sh
@@ -86,6 +86,30 @@ test_expect_success GPGSM 'verify and show signatures x509' '
echo ninth-signed-x509 OK
'
+test_expect_success GPGSM 'verify and show signatures x509 with low minTrustLevel' '
+ test_config gpg.minTrustLevel undefined &&
+ git verify-tag ninth-signed-x509 2>actual &&
+ grep "Good signature from" actual &&
+ ! grep "BAD signature from" actual &&
+ echo ninth-signed-x509 OK
+'
+
+test_expect_success GPGSM 'verify and show signatures x509 with matching minTrustLevel' '
+ test_config gpg.minTrustLevel fully &&
+ git verify-tag ninth-signed-x509 2>actual &&
+ grep "Good signature from" actual &&
+ ! grep "BAD signature from" actual &&
+ echo ninth-signed-x509 OK
+'
+
+test_expect_success GPGSM 'verify and show signatures x509 with high minTrustLevel' '
+ test_config gpg.minTrustLevel ultimate &&
+ test_must_fail git verify-tag ninth-signed-x509 2>actual &&
+ grep "Good signature from" actual &&
+ ! grep "BAD signature from" actual &&
+ echo ninth-signed-x509 OK
+'
+
test_expect_success GPG 'detect fudged signature' '
git cat-file tag seventh-signed >raw &&
sed -e "/^tag / s/seventh/7th forged/" raw >forged1 &&
diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh
index 0c394cf995..e4cf5484f9 100755
--- a/t/t7061-wtstatus-ignore.sh
+++ b/t/t7061-wtstatus-ignore.sh
@@ -43,11 +43,16 @@ test_expect_success 'status untracked directory with --ignored -u' '
test_cmp expected actual
'
cat >expected <<\EOF
-?? untracked/uncommitted
+?? untracked/
!! untracked/ignored
EOF
-test_expect_success 'status prefixed untracked directory with --ignored' '
+test_expect_success 'status of untracked directory with --ignored works with or without prefix' '
+ git status --porcelain --ignored >tmp &&
+ grep untracked/ tmp >actual &&
+ rm tmp &&
+ test_cmp expected actual &&
+
git status --porcelain --ignored untracked/ >actual &&
test_cmp expected actual
'
diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh
index 6b1a731fff..cad3a9de9e 100755
--- a/t/t7107-reset-pathspec-file.sh
+++ b/t/t7107-reset-pathspec-file.sh
@@ -105,8 +105,12 @@ test_expect_success 'CRLF delimiters' '
test_expect_success 'quotes' '
restore_checkpoint &&
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
git rm fileA.t &&
- printf "\"file\\101.t\"" | git reset --pathspec-from-file=- &&
+ git reset --pathspec-from-file=list &&
cat >expect <<-\EOF &&
D fileA.t
@@ -117,8 +121,10 @@ test_expect_success 'quotes' '
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
restore_checkpoint &&
- git rm fileA.t &&
- printf "\"file\\101.t\"" >list &&
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
# Note: "git reset" has not yet learned to fail on wrong pathspecs
git reset --pathspec-from-file=list --pathspec-file-nul &&
@@ -128,15 +134,6 @@ test_expect_success 'quotes not compatible with --pathspec-file-nul' '
test_must_fail verify_expect
'
-test_expect_success '--pathspec-from-file is not compatible with --soft or --hard' '
- restore_checkpoint &&
-
- git rm fileA.t &&
- echo fileA.t >list &&
- test_must_fail git reset --soft --pathspec-from-file=list &&
- test_must_fail git reset --hard --pathspec-from-file=list
-'
-
test_expect_success 'only touches what was listed' '
restore_checkpoint &&
@@ -152,4 +149,25 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ git rm fileA.t &&
+
+ test_must_fail git reset --pathspec-from-file=list --patch 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+ test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git reset --pathspec-file-nul 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ test_must_fail git reset --soft --pathspec-from-file=list 2>err &&
+ test_i18ngrep -e "fatal: Cannot do soft reset with paths" err &&
+
+ test_must_fail git reset --hard --pathspec-from-file=list 2>err &&
+ test_i18ngrep -e "fatal: Cannot do hard reset with paths" err
+'
+
test_done
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 7f75bb1be6..42a00f95b9 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -156,9 +156,9 @@ test_expect_success 'submodule add to .gitignored path fails' '
(
cd addtest-ignore &&
cat <<-\EOF >expect &&
- The following path is ignored by one of your .gitignore files:
+ The following paths are ignored by one of your .gitignore files:
submod
- Use -f if you really want to add it.
+ Use -f if you really want to add them.
EOF
# Does not use test_commit due to the ignore
echo "*" > .gitignore &&
@@ -191,6 +191,17 @@ test_expect_success 'submodule add to reconfigure existing submodule with --forc
)
'
+test_expect_success 'submodule add relays add --dry-run stderr' '
+ test_when_finished "rm -rf addtest/.git/index.lock" &&
+ (
+ cd addtest &&
+ : >.git/index.lock &&
+ ! git submodule add "$submodurl" sub-while-locked 2>output.err &&
+ test_i18ngrep "^fatal: .*index\.lock" output.err &&
+ test_path_is_missing sub-while-locked
+ )
+'
+
test_expect_success 'submodule add --branch' '
echo "refs/heads/initial" >expect-head &&
cat <<-\EOF >expect-heads &&
diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh
index 905a557585..f70368bc2e 100755
--- a/t/t7415-submodule-names.sh
+++ b/t/t7415-submodule-names.sh
@@ -207,6 +207,9 @@ test_expect_success MINGW 'prevent git~1 squatting on Windows' '
git hash-object -w --stdin)" &&
rev="$(git rev-parse --verify HEAD)" &&
hash="$(echo x | git hash-object -w --stdin)" &&
+ test_must_fail git update-index --add \
+ --cacheinfo 160000,$rev,d\\a 2>err &&
+ test_i18ngrep "Invalid path" err &&
git -c core.protectNTFS=false update-index --add \
--cacheinfo 100644,$modules,.gitmodules \
--cacheinfo 160000,$rev,c \
@@ -214,9 +217,7 @@ test_expect_success MINGW 'prevent git~1 squatting on Windows' '
--cacheinfo 100644,$hash,d./a/x \
--cacheinfo 100644,$hash,d./a/..git &&
test_tick &&
- git -c core.protectNTFS=false commit -m "module" &&
- test_must_fail git show HEAD: 2>err &&
- test_i18ngrep backslash err
+ git -c core.protectNTFS=false commit -m "module"
) &&
test_must_fail git -c core.protectNTFS=false \
clone --recurse-submodules squatting squatting-clone 2>err &&
diff --git a/t/t7420-submodule-set-url.sh b/t/t7420-submodule-set-url.sh
new file mode 100755
index 0000000000..ef0cb6e8e1
--- /dev/null
+++ b/t/t7420-submodule-set-url.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (c) 2019 Denton Liu
+#
+
+test_description='Test submodules set-url subcommand
+
+This test verifies that the set-url subcommand of git-submodule is working
+as expected.
+'
+
+TEST_NO_CREATE_REPO=1
+. ./test-lib.sh
+
+test_expect_success 'submodule config cache setup' '
+ mkdir submodule &&
+ (
+ cd submodule &&
+ git init &&
+ echo a >file &&
+ git add file &&
+ git commit -ma
+ ) &&
+ mkdir super &&
+ (
+ cd super &&
+ git init &&
+ git submodule add ../submodule &&
+ git commit -m "add submodule"
+ )
+'
+
+test_expect_success 'test submodule set-url' '
+ # add a commit and move the submodule (change the url)
+ (
+ cd submodule &&
+ echo b >>file &&
+ git add file &&
+ git commit -mb
+ ) &&
+ mv submodule newsubmodule &&
+
+ git -C newsubmodule show >expect &&
+ (
+ cd super &&
+ test_must_fail git submodule update --remote &&
+ git submodule set-url submodule ../newsubmodule &&
+ grep -F "url = ../newsubmodule" .gitmodules &&
+ git submodule update --remote
+ ) &&
+ git -C super/submodule show >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
index 46a5cd4b73..6d19ece05d 100755
--- a/t/t7500-commit-template-squash-signoff.sh
+++ b/t/t7500-commit-template-squash-signoff.sh
@@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' '
)
'
+test_expect_success 'commit without staging files fails and displays hints' '
+ echo "initial" >file &&
+ git add file &&
+ git commit -m initial &&
+ echo "changes" >>file &&
+ test_must_fail git commit -m update >actual &&
+ test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual
+'
+
test_done
diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
index f1349af56e..110b4bf459 100755
--- a/t/t7501-commit-basic-functionality.sh
+++ b/t/t7501-commit-basic-functionality.sh
@@ -150,7 +150,7 @@ test_expect_success 'setup: commit message from file' '
test_expect_success 'amend commit' '
cat >editor <<-\EOF &&
#!/bin/sh
- sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
+ sed -e "s/a file/an amend commit/g" <"$1" >"$1-"
mv "$1-" "$1"
EOF
chmod 755 editor &&
@@ -263,7 +263,7 @@ test_expect_success 'using message from other commit' '
test_expect_success 'editing message from other commit' '
cat >editor <<-\EOF &&
#!/bin/sh
- sed -e "s/amend/older/g" < "$1" > "$1-"
+ sed -e "s/amend/older/g" <"$1" >"$1-"
mv "$1-" "$1"
EOF
chmod 755 editor &&
@@ -285,9 +285,8 @@ test_expect_success 'overriding author from command line' '
'
test_expect_success PERL 'interactive add' '
- echo 7 |
- git commit --interactive |
- grep "What now"
+ echo 7 | test_must_fail git commit --interactive >out &&
+ grep "What now" out
'
test_expect_success PERL "commit --interactive doesn't change index if editor aborts" '
@@ -362,12 +361,12 @@ test_expect_success 'amend commit to fix author' '
oldtick=$GIT_AUTHOR_DATE &&
test_tick &&
git reset --hard &&
- git cat-file -p HEAD |
+ git cat-file -p HEAD >commit &&
sed -e "s/author.*/author $author $oldtick/" \
- -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
- expected &&
+ -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
+ commit >expected &&
git commit --amend --author="$author" &&
- git cat-file -p HEAD > current &&
+ git cat-file -p HEAD >current &&
test_cmp expected current
'
@@ -377,12 +376,12 @@ test_expect_success 'amend commit to fix date' '
test_tick &&
newtick=$GIT_AUTHOR_DATE &&
git reset --hard &&
- git cat-file -p HEAD |
+ git cat-file -p HEAD >commit &&
sed -e "s/author.*/author $author $newtick/" \
- -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
- expected &&
+ -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
+ commit >expected &&
git commit --amend --date="$newtick" &&
- git cat-file -p HEAD > current &&
+ git cat-file -p HEAD >current &&
test_cmp expected current
'
@@ -409,12 +408,13 @@ test_expect_success 'sign off (1)' '
echo 1 >positive &&
git add positive &&
git commit -s -m "thank you" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo thank you &&
echo &&
- git var GIT_COMMITTER_IDENT |
- sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ git var GIT_COMMITTER_IDENT >ident &&
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual
@@ -428,13 +428,14 @@ test_expect_success 'sign off (2)' '
git commit -s -m "thank you
$existing" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo thank you &&
echo &&
echo $existing &&
- git var GIT_COMMITTER_IDENT |
- sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ git var GIT_COMMITTER_IDENT >ident &&
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual
@@ -448,13 +449,14 @@ test_expect_success 'signoff gap' '
git commit -s -m "welcome
$alt" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo welcome &&
echo &&
echo $alt &&
- git var GIT_COMMITTER_IDENT |
- sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ git var GIT_COMMITTER_IDENT >ident &&
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual
'
@@ -468,15 +470,16 @@ test_expect_success 'signoff gap 2' '
We have now
$alt" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo welcome &&
echo &&
echo We have now &&
echo $alt &&
echo &&
- git var GIT_COMMITTER_IDENT |
- sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ git var GIT_COMMITTER_IDENT >ident &&
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual
'
@@ -489,7 +492,8 @@ test_expect_success 'signoff respects trailer config' '
non-trailer line
Myfooter: x" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo subject &&
echo &&
@@ -506,7 +510,8 @@ Myfooter: x" &&
non-trailer line
Myfooter: x" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo subject &&
echo &&
@@ -538,7 +543,8 @@ test_expect_success 'multiple -m' '
>negative &&
git add negative &&
git commit -m "one" -m "two" -m "three" &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ git cat-file commit HEAD >commit &&
+ sed -e "1,/^\$/d" commit >actual &&
(
echo one &&
echo &&
@@ -555,23 +561,25 @@ test_expect_success 'amend commit to fix author' '
oldtick=$GIT_AUTHOR_DATE &&
test_tick &&
git reset --hard &&
- git cat-file -p HEAD |
+ git cat-file -p HEAD >commit &&
sed -e "s/author.*/author $author $oldtick/" \
- -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
- expected &&
+ -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
+ commit >expected &&
git commit --amend --author="$author" &&
- git cat-file -p HEAD > current &&
+ git cat-file -p HEAD >current &&
test_cmp expected current
'
test_expect_success 'git commit <file> with dirty index' '
- echo tacocat > elif &&
- echo tehlulz > chz &&
+ echo tacocat >elif &&
+ echo tehlulz >chz &&
git add chz &&
git commit elif -m "tacocat is a palindrome" &&
- git show --stat | grep elif &&
- git diff --cached | grep chz
+ git show --stat >stat &&
+ grep elif stat &&
+ git diff --cached >diff &&
+ grep chz diff
'
test_expect_success 'same tree (single parent)' '
@@ -584,7 +592,8 @@ test_expect_success 'same tree (single parent)' '
test_expect_success 'same tree (single parent) --allow-empty' '
git commit --allow-empty -m "forced empty" &&
- git cat-file commit HEAD | grep forced
+ git cat-file commit HEAD >commit &&
+ grep forced commit
'
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 682b23a068..0c06d22a00 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -109,6 +109,21 @@ test_expect_success GPG 'verify-commit exits success on untrusted signature' '
grep "not certified" actual
'
+test_expect_success GPG 'verify-commit exits success with matching minTrustLevel' '
+ test_config gpg.minTrustLevel ultimate &&
+ git verify-commit sixth-signed
+'
+
+test_expect_success GPG 'verify-commit exits success with low minTrustLevel' '
+ test_config gpg.minTrustLevel fully &&
+ git verify-commit sixth-signed
+'
+
+test_expect_success GPG 'verify-commit exits failure with high minTrustLevel' '
+ test_config gpg.minTrustLevel ultimate &&
+ test_must_fail git verify-commit eighth-signed-alt
+'
+
test_expect_success GPG 'verify signatures with --raw' '
(
for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
@@ -219,6 +234,30 @@ test_expect_success GPG 'show untrusted signature with custom format' '
test_cmp expect actual
'
+test_expect_success GPG 'show untrusted signature with undefined trust level' '
+ cat >expect <<-\EOF &&
+ undefined
+ 65A0EEA02E30CAD7
+ Eris Discordia <discord@example.net>
+ F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7
+ D4BE22311AD3131E5EDA29A461092E85B7227189
+ EOF
+ git log -1 --format="%GT%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success GPG 'show untrusted signature with ultimate trust level' '
+ cat >expect <<-\EOF &&
+ ultimate
+ 13B6F51ECDDE430D
+ C O Mitter <committer@example.com>
+ 73D758744BE721698EC54E8713B6F51ECDDE430D
+ 73D758744BE721698EC54E8713B6F51ECDDE430D
+ EOF
+ git log -1 --format="%GT%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual &&
+ test_cmp expect actual
+'
+
test_expect_success GPG 'show unknown signature with custom format' '
cat >expect <<-\EOF &&
E
diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh
index a06b683534..5fbe47ebcd 100755
--- a/t/t7526-commit-pathspec-file.sh
+++ b/t/t7526-commit-pathspec-file.sh
@@ -100,7 +100,11 @@ test_expect_success 'CRLF delimiters' '
test_expect_success 'quotes' '
restore_checkpoint &&
- printf "\"file\\101.t\"" | git commit --pathspec-from-file=- -m "Commit" &&
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
+ git commit --pathspec-from-file=list -m "Commit" &&
cat >expect <<-\EOF &&
A fileA.t
@@ -111,7 +115,10 @@ test_expect_success 'quotes' '
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
restore_checkpoint &&
- printf "\"file\\101.t\"" >list &&
+ cat >list <<-\EOF &&
+ "file\101.t"
+ EOF
+
test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit"
'
@@ -127,4 +134,31 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ >empty_list &&
+
+ test_must_fail git commit --pathspec-from-file=list --interactive -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git commit --pathspec-from-file=list --patch -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git commit --pathspec-from-file=list --all -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-from-file with -a does not make sense" err &&
+
+ test_must_fail git commit --pathspec-from-file=list -m "Commit" -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ test_must_fail git commit --pathspec-from-file=empty_list --include -m "Commit" 2>err &&
+ test_i18ngrep -e "No paths with --include/--only does not make sense." err &&
+
+ test_must_fail git commit --pathspec-from-file=empty_list --only -m "Commit" 2>err &&
+ test_i18ngrep -e "No paths with --include/--only does not make sense." err
+'
+
test_done
diff --git a/t/t7612-merge-verify-signatures.sh b/t/t7612-merge-verify-signatures.sh
index d99218a725..a426f3a89a 100755
--- a/t/t7612-merge-verify-signatures.sh
+++ b/t/t7612-merge-verify-signatures.sh
@@ -66,6 +66,20 @@ test_expect_success GPG 'merge commit with untrusted signature with verification
test_i18ngrep "has an untrusted GPG signature" mergeerror
'
+test_expect_success GPG 'merge commit with untrusted signature with verification and high minTrustLevel' '
+ test_when_finished "git reset --hard && git checkout initial" &&
+ test_config gpg.minTrustLevel marginal &&
+ test_must_fail git merge --ff-only --verify-signatures side-untrusted 2>mergeerror &&
+ test_i18ngrep "has an untrusted GPG signature" mergeerror
+'
+
+test_expect_success GPG 'merge commit with untrusted signature with verification and low minTrustLevel' '
+ test_when_finished "git reset --hard && git checkout initial" &&
+ test_config gpg.minTrustLevel undefined &&
+ git merge --ff-only --verify-signatures side-untrusted >mergeoutput &&
+ test_i18ngrep "has a good GPG signature" mergeoutput
+'
+
test_expect_success GPG 'merge commit with untrusted signature with merge.verifySignatures=true' '
test_when_finished "git reset --hard && git checkout initial" &&
test_config merge.verifySignatures true &&
@@ -73,6 +87,14 @@ test_expect_success GPG 'merge commit with untrusted signature with merge.verify
test_i18ngrep "has an untrusted GPG signature" mergeerror
'
+test_expect_success GPG 'merge commit with untrusted signature with merge.verifySignatures=true and minTrustLevel' '
+ test_when_finished "git reset --hard && git checkout initial" &&
+ test_config merge.verifySignatures true &&
+ test_config gpg.minTrustLevel marginal &&
+ test_must_fail git merge --ff-only side-untrusted 2>mergeerror &&
+ test_i18ngrep "has an untrusted GPG signature" mergeerror
+'
+
test_expect_success GPG 'merge signed commit with verification' '
test_when_finished "git reset --hard && git checkout initial" &&
git merge --verbose --ff-only --verify-signatures side-signed >mergeoutput &&
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 4e855bc21b..25b235c063 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -4,129 +4,104 @@ test_description='git repack works correctly'
. ./test-lib.sh
-commit_and_pack() {
- test_commit "$@" >/dev/null &&
- SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
- echo pack-${SHA1}.pack
+commit_and_pack () {
+ test_commit "$@" 1>&2 &&
+ incrpackid=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
+ echo pack-${incrpackid}.pack
+}
+
+test_no_missing_in_packs () {
+ myidx=$(ls -1 .git/objects/pack/*.idx) &&
+ test_path_is_file "$myidx" &&
+ git verify-pack -v alt_objects/pack/*.idx >orig.raw &&
+ sed -n -e "s/^\($OID_REGEX\).*/\1/p" orig.raw | sort >orig &&
+ git verify-pack -v $myidx >dest.raw &&
+ cut -d" " -f1 dest.raw | sort >dest &&
+ comm -23 orig dest >missing &&
+ test_must_be_empty missing
+}
+
+# we expect $packid and $oid to be defined
+test_has_duplicate_object () {
+ want_duplicate_object="$1"
+ found_duplicate_object=false
+ for p in .git/objects/pack/*.idx
+ do
+ idx=$(basename $p)
+ test "pack-$packid.idx" = "$idx" && continue
+ git verify-pack -v $p >packlist || return $?
+ if grep "^$oid" packlist
+ then
+ found_duplicate_object=true
+ echo "DUPLICATE OBJECT FOUND"
+ break
+ fi
+ done &&
+ test "$want_duplicate_object" = "$found_duplicate_object"
}
test_expect_success 'objects in packs marked .keep are not repacked' '
- echo content1 > file1 &&
- echo content2 > file2 &&
+ echo content1 >file1 &&
+ echo content2 >file2 &&
git add . &&
test_tick &&
git commit -m initial_commit &&
# Create two packs
# The first pack will contain all of the objects except one
- git rev-list --objects --all | grep -v file2 |
- git pack-objects pack > /dev/null &&
+ git rev-list --objects --all >objs &&
+ grep -v file2 objs | git pack-objects pack &&
# The second pack will contain the excluded object
- packsha1=$(git rev-list --objects --all | grep file2 |
- git pack-objects pack) &&
- >pack-$packsha1.keep &&
- objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 |
- sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") &&
+ packid=$(grep file2 objs | git pack-objects pack) &&
+ >pack-$packid.keep &&
+ git verify-pack -v pack-$packid.idx >packlist &&
+ oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") &&
mv pack-* .git/objects/pack/ &&
git repack -A -d -l &&
git prune-packed &&
- for p in .git/objects/pack/*.idx; do
- idx=$(basename $p)
- test "pack-$packsha1.idx" = "$idx" && continue
- if git verify-pack -v $p | egrep "^$objsha1"; then
- found_duplicate_object=1
- echo "DUPLICATE OBJECT FOUND"
- break
- fi
- done &&
- test -z "$found_duplicate_object"
+ test_has_duplicate_object false
'
test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' '
- # build on $objsha1, $packsha1, and .keep state from previous
+ # build on $oid, $packid, and .keep state from previous
git repack -Adbl &&
- test_when_finished "found_duplicate_object=" &&
- for p in .git/objects/pack/*.idx; do
- idx=$(basename $p)
- test "pack-$packsha1.idx" = "$idx" && continue
- if git verify-pack -v $p | egrep "^$objsha1"; then
- found_duplicate_object=1
- echo "DUPLICATE OBJECT FOUND"
- break
- fi
- done &&
- test "$found_duplicate_object" = 1
+ test_has_duplicate_object true
'
test_expect_success 'writing bitmaps via config can duplicate .keep objects' '
- # build on $objsha1, $packsha1, and .keep state from previous
+ # build on $oid, $packid, and .keep state from previous
git -c repack.writebitmaps=true repack -Adl &&
- test_when_finished "found_duplicate_object=" &&
- for p in .git/objects/pack/*.idx; do
- idx=$(basename $p)
- test "pack-$packsha1.idx" = "$idx" && continue
- if git verify-pack -v $p | egrep "^$objsha1"; then
- found_duplicate_object=1
- echo "DUPLICATE OBJECT FOUND"
- break
- fi
- done &&
- test "$found_duplicate_object" = 1
+ test_has_duplicate_object true
'
test_expect_success 'loose objects in alternate ODB are not repacked' '
mkdir alt_objects &&
- echo $(pwd)/alt_objects > .git/objects/info/alternates &&
- echo content3 > file3 &&
- objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
+ echo $(pwd)/alt_objects >.git/objects/info/alternates &&
+ echo content3 >file3 &&
+ oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
git add file3 &&
test_tick &&
git commit -m commit_file3 &&
git repack -a -d -l &&
git prune-packed &&
- for p in .git/objects/pack/*.idx; do
- if git verify-pack -v $p | egrep "^$objsha1"; then
- found_duplicate_object=1
- echo "DUPLICATE OBJECT FOUND"
- break
- fi
- done &&
- test -z "$found_duplicate_object"
+ test_has_duplicate_object false
'
test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' '
mkdir alt_objects/pack &&
mv .git/objects/pack/* alt_objects/pack &&
git repack -a &&
- myidx=$(ls -1 .git/objects/pack/*.idx) &&
- test -f "$myidx" &&
- for p in alt_objects/pack/*.idx; do
- git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
- done | while read sha1 rest; do
- if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
- echo "Missing object in local pack: $sha1"
- return 1
- fi
- done
+ test_no_missing_in_packs
'
test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' '
rm -f .git/objects/pack/* &&
- echo new_content >> file1 &&
+ echo new_content >>file1 &&
git add file1 &&
test_tick &&
git commit -m more_content &&
git repack &&
git repack -a -d &&
- myidx=$(ls -1 .git/objects/pack/*.idx) &&
- test -f "$myidx" &&
- for p in alt_objects/pack/*.idx; do
- git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
- done | while read sha1 rest; do
- if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
- echo "Missing object in local pack: $sha1"
- return 1
- fi
- done
+ test_no_missing_in_packs
'
test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
@@ -134,7 +109,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
for p in alt_objects/pack/*.pack
do
base_name=$(basename $p .pack) &&
- if test -f alt_objects/pack/$base_name.keep
+ if test_path_is_file alt_objects/pack/$base_name.keep
then
rm alt_objects/pack/$base_name.keep
else
@@ -142,22 +117,13 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
fi
done &&
git repack -a -d &&
- myidx=$(ls -1 .git/objects/pack/*.idx) &&
- test -f "$myidx" &&
- for p in alt_objects/pack/*.idx; do
- git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
- done | while read sha1 rest; do
- if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
- echo "Missing object in local pack: $sha1"
- return 1
- fi
- done
+ test_no_missing_in_packs
'
test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
rm -f alt_objects/pack/*.keep &&
mv .git/objects/pack/* alt_objects/pack/ &&
- csha1=$(git rev-parse HEAD^{commit}) &&
+ coid=$(git rev-parse HEAD^{commit}) &&
git reset --hard HEAD^ &&
test_tick &&
git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
@@ -167,15 +133,15 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
--unpack-unreachable </dev/null pack &&
rm -f .git/objects/pack/* &&
mv pack-* .git/objects/pack/ &&
- test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
- egrep "^$csha1 " | sort | uniq | wc -l) &&
- echo > .git/objects/info/alternates &&
- test_must_fail git show $csha1
+ git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
+ ! grep "^$coid " packlist &&
+ echo >.git/objects/info/alternates &&
+ test_must_fail git show $coid
'
test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' '
- echo $(pwd)/alt_objects > .git/objects/info/alternates &&
- echo "$csha1" | git pack-objects --non-empty --all --reflog pack &&
+ echo $(pwd)/alt_objects >.git/objects/info/alternates &&
+ echo "$coid" | git pack-objects --non-empty --all --reflog pack &&
rm -f .git/objects/pack/* &&
mv pack-* .git/objects/pack/ &&
# The pack-objects call on the next line is equivalent to
@@ -184,10 +150,10 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar
--unpack-unreachable </dev/null pack &&
rm -f .git/objects/pack/* &&
mv pack-* .git/objects/pack/ &&
- test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
- egrep "^$csha1 " | sort | uniq | wc -l) &&
- echo > .git/objects/info/alternates &&
- test_must_fail git show $csha1
+ git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
+ ! grep "^$coid " &&
+ echo >.git/objects/info/alternates &&
+ test_must_fail git show $coid
'
test_expect_success 'objects made unreachable by grafts only are kept' '
@@ -196,7 +162,7 @@ test_expect_success 'objects made unreachable by grafts only are kept' '
H0=$(git rev-parse HEAD) &&
H1=$(git rev-parse HEAD^) &&
H2=$(git rev-parse HEAD^^) &&
- echo "$H0 $H2" > .git/info/grafts &&
+ echo "$H0 $H2" >.git/info/grafts &&
git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
git repack -a -d &&
git cat-file -t $H1
@@ -235,7 +201,7 @@ test_expect_success 'incremental repack does not complain' '
test_expect_success 'bitmaps can be disabled on bare repos' '
git -c repack.writeBitmaps=false -C bare.git repack -ad &&
- bitmap=$(ls bare.git/objects/pack/*.bitmap 2>/dev/null || :) &&
+ bitmap=$(ls bare.git/objects/pack/*.bitmap || :) &&
test -z "$bitmap"
'
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 6bac9ed180..29b92907e2 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -125,15 +125,14 @@ test_expect_success 'difftool stops on error with --trust-exit-code' '
test_when_finished "rm -f for-diff .git/fail-right-file" &&
test_when_finished "git reset -- for-diff" &&
write_script .git/fail-right-file <<-\EOF &&
- echo "$2"
+ echo failed
exit 1
EOF
>for-diff &&
git add for-diff &&
- echo file >expect &&
test_must_fail git difftool -y --trust-exit-code \
--extcmd .git/fail-right-file branch >actual &&
- test_cmp expect actual
+ test_line_count = 1 actual
'
test_expect_success 'difftool honors exit status if command not found' '
diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh
index 531eb59d57..03dba6685a 100755
--- a/t/t7812-grep-icase-non-ascii.sh
+++ b/t/t7812-grep-icase-non-ascii.sh
@@ -70,15 +70,18 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UT
test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data' '
git grep -h "æ" invalid-0x80 >actual &&
test_cmp expected actual &&
- git grep -h "(*NO_JIT)æ" invalid-0x80 &&
+ git grep -h "(*NO_JIT)æ" invalid-0x80 >actual &&
test_cmp expected actual
'
test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
- test_cmp expected actual &&
- test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 &&
- test_cmp expected actual
+ if test -s actual
+ then
+ test_cmp expected actual
+ fi &&
+ test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
+ ! test_cmp expected actual
'
test_done
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index bd94779611..a834afab4d 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -2066,7 +2066,7 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
TO2=$(echo "QZto2" | qz_to_tab_space) &&
CC1=$(echo "cc1" | append_cr) &&
- BCC1=$(echo "Q bcc1@example.com Q" | q_to_nul) &&
+ BCC1=$(echo " bcc1@example.com Q" | q_to_nul) &&
git send-email \
--dry-run \
--from=" Example <from@example.com>" \
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 05f07a1671..ae9950a9c2 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3191,13 +3191,22 @@ background_import_then_checkpoint () {
exec 9<>V.output
rm V.output
- git fast-import $options <&8 >&9 &
- echo $! >V.pid
+ (
+ git fast-import $options <&8 >&9 &
+ echo $! >&9
+ wait $!
+ echo >&2 "background fast-import terminated too early with exit code $?"
+ # Un-block the read loop in the main shell process.
+ echo >&9 UNEXPECTED
+ ) &
+ sh_pid=$!
+ read fi_pid <&9
# We don't mind if fast-import has already died by the time the test
# ends.
test_when_finished "
exec 8>&-; exec 9>&-;
- kill $(cat V.pid) && wait $(cat V.pid)
+ kill $sh_pid && wait $sh_pid
+ kill $fi_pid && wait $fi_pid
true"
# Start in the background to ensure we adhere strictly to (blocking)
@@ -3217,6 +3226,9 @@ background_import_then_checkpoint () {
then
error=0
break
+ elif test "$output" = "UNEXPECTED"
+ then
+ break
fi
# otherwise ignore cruft
echo >&2 "cruft: $output"
@@ -3229,7 +3241,7 @@ background_import_then_checkpoint () {
}
background_import_still_running () {
- if ! kill -0 "$(cat V.pid)"
+ if ! kill -0 "$fi_pid"
then
echo >&2 "background fast-import terminated too early"
false
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index ec3eccfd3d..5505e5aa24 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1363,6 +1363,63 @@ test_expect_success 'teardown after path completion tests' '
BS\\dir '$'separators\034in\035dir''
'
+test_expect_success '__git_find_on_cmdline - single match' '
+ echo list >expect &&
+ (
+ words=(git command --opt list) &&
+ cword=${#words[@]} &&
+ __git_find_on_cmdline "add list remove" >actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_expect_success '__git_find_on_cmdline - multiple matches' '
+ echo remove >expect &&
+ (
+ words=(git command -o --opt remove list add) &&
+ cword=${#words[@]} &&
+ __git_find_on_cmdline "add list remove" >actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_expect_success '__git_find_on_cmdline - no match' '
+ (
+ words=(git command --opt branch) &&
+ cword=${#words[@]} &&
+ __git_find_on_cmdline "add list remove" >actual
+ ) &&
+ test_must_be_empty actual
+'
+
+test_expect_success '__git_find_on_cmdline - single match with index' '
+ echo "3 list" >expect &&
+ (
+ words=(git command --opt list) &&
+ cword=${#words[@]} &&
+ __git_find_on_cmdline --show-idx "add list remove" >actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_expect_success '__git_find_on_cmdline - multiple matches with index' '
+ echo "4 remove" >expect &&
+ (
+ words=(git command -o --opt remove list add) &&
+ cword=${#words[@]} &&
+ __git_find_on_cmdline --show-idx "add list remove" >actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_expect_success '__git_find_on_cmdline - no match with index' '
+ (
+ words=(git command --opt branch) &&
+ cword=${#words[@]} &&
+ __git_find_on_cmdline --show-idx "add list remove" >actual
+ ) &&
+ test_must_be_empty actual
+'
test_expect_success '__git_get_config_variables' '
cat >expect <<-EOF &&
@@ -1438,6 +1495,8 @@ test_expect_success 'double dash "git checkout"' '
--no-guess Z
--no-... Z
--overlay Z
+ --pathspec-file-nul Z
+ --pathspec-from-file=Z
EOF
'
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index dc7a0411df..284c52d076 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -308,7 +308,7 @@ test_commit_bulk () {
total=$1
add_from=
- if git -C "$indir" rev-parse --verify "$ref"
+ if git -C "$indir" rev-parse --quiet --verify "$ref"
then
add_from=t
fi
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 5fbf4d25ed..44df51be8f 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1422,7 +1422,7 @@ else
'
fi
-# Fix some commands on Windows
+# Fix some commands on Windows, and other OS-specific things
uname_s=$(uname -s)
case $uname_s in
*MINGW*)
@@ -1453,6 +1453,12 @@ case $uname_s in
test_set_prereq SED_STRIPS_CR
test_set_prereq GREP_STRIPS_CR
;;
+FreeBSD)
+ test_set_prereq REGEX_ILLSEQ
+ test_set_prereq POSIXPERM
+ test_set_prereq BSLASHPSPEC
+ test_set_prereq EXECKEEPSPID
+ ;;
*)
test_set_prereq POSIXPERM
test_set_prereq BSLASHPSPEC