summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t0000-basic.sh7
-rwxr-xr-xt/t0302-credential-store.sh91
-rwxr-xr-xt/t1011-read-tree-sparse-checkout.sh12
-rwxr-xr-xt/t1091-sparse-checkout-builtin.sh8
-rwxr-xr-xt/t2070-restore.sh11
-rwxr-xr-xt/t4018-diff-funcname.sh1
-rw-r--r--t/t4018/markdown-heading-indented6
-rw-r--r--t/t4018/markdown-heading-non-headings17
-rwxr-xr-xt/t6300-for-each-ref.sh94
9 files changed, 227 insertions, 20 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index f58f3deaa8..2ff176cd5d 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -77,9 +77,7 @@ _run_sub_test_lib_test_common () {
# the sub-test.
sane_unset HARNESS_ACTIVE &&
cd "$name" &&
- cat >"$name.sh" <<-EOF &&
- #!$SHELL_PATH
-
+ write_script "$name.sh" "$TEST_SHELL_PATH" <<-EOF &&
test_description='$descr (run in sub test-lib)
This is run in a sub test-lib so that we do not get incorrect
@@ -94,7 +92,6 @@ _run_sub_test_lib_test_common () {
. "\$TEST_DIRECTORY"/test-lib.sh
EOF
cat >>"$name.sh" &&
- chmod +x "$name.sh" &&
export TEST_DIRECTORY &&
TEST_OUTPUT_DIRECTORY=$(pwd) &&
export TEST_OUTPUT_DIRECTORY &&
@@ -103,7 +100,7 @@ _run_sub_test_lib_test_common () {
then
./"$name.sh" "$@" >out 2>err
else
- ! ./"$name.sh" "$@" >out 2>err
+ ! ./"$name.sh" "$@" >out 2>err
fi
)
}
diff --git a/t/t0302-credential-store.sh b/t/t0302-credential-store.sh
index d6b54e8c65..716bf1af9f 100755
--- a/t/t0302-credential-store.sh
+++ b/t/t0302-credential-store.sh
@@ -107,7 +107,6 @@ test_expect_success 'store: if both xdg and home files exist, only store in home
test_must_be_empty "$HOME/.config/git/credentials"
'
-
test_expect_success 'erase: erase matching credentials from both xdg and home files' '
echo "https://home-user:home-pass@example.com" >"$HOME/.git-credentials" &&
mkdir -p "$HOME/.config/git" &&
@@ -120,4 +119,94 @@ test_expect_success 'erase: erase matching credentials from both xdg and home fi
test_must_be_empty "$HOME/.config/git/credentials"
'
+invalid_credential_test() {
+ test_expect_success "get: ignore credentials without $1 as invalid" '
+ echo "$2" >"$HOME/.git-credentials" &&
+ check fill store <<-\EOF
+ protocol=https
+ host=example.com
+ --
+ protocol=https
+ host=example.com
+ username=askpass-username
+ password=askpass-password
+ --
+ askpass: Username for '\''https://example.com'\'':
+ askpass: Password for '\''https://askpass-username@example.com'\'':
+ --
+ EOF
+ '
+}
+
+invalid_credential_test "scheme" ://user:pass@example.com
+invalid_credential_test "valid host/path" https://user:pass@
+invalid_credential_test "username/password" https://pass@example.com
+
+test_expect_success 'get: credentials with DOS line endings are invalid' '
+ printf "https://user:pass@example.com\r\n" >"$HOME/.git-credentials" &&
+ check fill store <<-\EOF
+ protocol=https
+ host=example.com
+ --
+ protocol=https
+ host=example.com
+ username=askpass-username
+ password=askpass-password
+ --
+ askpass: Username for '\''https://example.com'\'':
+ askpass: Password for '\''https://askpass-username@example.com'\'':
+ --
+ EOF
+'
+
+test_expect_success 'get: credentials with path and DOS line endings are valid' '
+ printf "https://user:pass@example.com/repo.git\r\n" >"$HOME/.git-credentials" &&
+ check fill store <<-\EOF
+ url=https://example.com/repo.git
+ --
+ protocol=https
+ host=example.com
+ username=user
+ password=pass
+ --
+ EOF
+'
+
+test_expect_success 'get: credentials with DOS line endings are invalid if path is relevant' '
+ printf "https://user:pass@example.com/repo.git\r\n" >"$HOME/.git-credentials" &&
+ test_config credential.useHttpPath true &&
+ check fill store <<-\EOF
+ url=https://example.com/repo.git
+ --
+ protocol=https
+ host=example.com
+ path=repo.git
+ username=askpass-username
+ password=askpass-password
+ --
+ askpass: Username for '\''https://example.com/repo.git'\'':
+ askpass: Password for '\''https://askpass-username@example.com/repo.git'\'':
+ --
+ EOF
+'
+
+test_expect_success 'get: store file can contain empty/bogus lines' '
+ echo "" >"$HOME/.git-credentials" &&
+ q_to_tab <<-\CREDENTIAL >>"$HOME/.git-credentials" &&
+ #comment
+ Q
+ https://user:pass@example.com
+ CREDENTIAL
+ check fill store <<-\EOF
+ protocol=https
+ host=example.com
+ --
+ protocol=https
+ host=example.com
+ username=user
+ password=pass
+ --
+ EOF
+'
+
test_done
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index 63223e13bd..140f459977 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -74,13 +74,19 @@ test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-
test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
git config core.sparsecheckout true &&
echo >.git/info/sparse-checkout &&
- read_tree_u_must_fail -m -u HEAD &&
+ read_tree_u_must_succeed -m -u HEAD &&
git ls-files --stage >result &&
test_cmp expected result &&
git ls-files -t >result &&
+ cat >expected.swt <<-\EOF &&
+ S init.t
+ S sub/added
+ S sub/addedtoo
+ S subsub/added
+ EOF
test_cmp expected.swt result &&
- test -f init.t &&
- test -f sub/added
+ ! test -f init.t &&
+ ! test -f sub/added
'
test_expect_success 'match directories with trailing slash' '
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index dee99eeec3..88cdde255c 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -106,10 +106,8 @@ test_expect_success 'set enables config' '
cd empty-config &&
test_commit test file &&
test_path_is_missing .git/config.worktree &&
- test_must_fail git sparse-checkout set nothing &&
+ 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
)
'
@@ -302,8 +300,8 @@ test_expect_success 'revert to old sparse-checkout on empty update' '
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 &&
+ 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
)
diff --git a/t/t2070-restore.sh b/t/t2070-restore.sh
index 076d0df7fc..89e5a142c9 100755
--- a/t/t2070-restore.sh
+++ b/t/t2070-restore.sh
@@ -69,6 +69,17 @@ test_expect_success 'restore --staged uses HEAD as source' '
test_cmp expected actual
'
+test_expect_success 'restore --worktree --staged uses HEAD as source' '
+ test_when_finished git reset --hard &&
+ git show HEAD:./first.t >expected &&
+ echo dirty >>first.t &&
+ git add first.t &&
+ git restore --worktree --staged first.t &&
+ git show :./first.t >actual &&
+ test_cmp expected actual &&
+ test_cmp expected first.t
+'
+
test_expect_success 'restore --ignore-unmerged ignores unmerged entries' '
git init unmerged &&
(
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 02255a08bf..9d07797579 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -38,6 +38,7 @@ diffpatterns="
golang
html
java
+ markdown
matlab
objc
pascal
diff --git a/t/t4018/markdown-heading-indented b/t/t4018/markdown-heading-indented
new file mode 100644
index 0000000000..1991c2bd45
--- /dev/null
+++ b/t/t4018/markdown-heading-indented
@@ -0,0 +1,6 @@
+Indented headings are allowed, as long as the indent is no more than 3 spaces.
+
+ ### RIGHT
+
+- something
+- ChangeMe
diff --git a/t/t4018/markdown-heading-non-headings b/t/t4018/markdown-heading-non-headings
new file mode 100644
index 0000000000..c479c1a3f1
--- /dev/null
+++ b/t/t4018/markdown-heading-non-headings
@@ -0,0 +1,17 @@
+Headings can be right next to other lines of the file:
+# RIGHT
+Indents of four or more spaces make a code block:
+
+ # code comment, not heading
+
+If there's no space after the final hash, it's not a heading:
+
+#hashtag
+
+Sequences of more than 6 hashes don't make a heading:
+
+####### over-enthusiastic heading
+
+So the detected heading should be right up at the start of this file.
+
+ChangeMe
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index b3c1092338..da59fadc5d 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -650,17 +650,59 @@ test_atom refs/tags/signed-long contents "subject line
body contents
$sig"
-sort >expected <<EOF
-$(git rev-parse refs/tags/bogo) <committer@example.com> refs/tags/bogo
-$(git rev-parse refs/tags/master) <committer@example.com> refs/tags/master
-EOF
+test_expect_success 'set up multiple-sort tags' '
+ for when in 100000 200000
+ do
+ for email in user1 user2
+ do
+ for ref in ref1 ref2
+ do
+ GIT_COMMITTER_DATE="@$when +0000" \
+ GIT_COMMITTER_EMAIL="$email@example.com" \
+ git tag -m "tag $ref-$when-$email" \
+ multi-$ref-$when-$email || return 1
+ done
+ done
+ done
+'
test_expect_success 'Verify sort with multiple keys' '
- git for-each-ref --format="%(objectname) %(taggeremail) %(refname)" --sort=objectname --sort=taggeremail \
- refs/tags/bogo refs/tags/master > actual &&
+ cat >expected <<-\EOF &&
+ 100000 <user1@example.com> refs/tags/multi-ref2-100000-user1
+ 100000 <user1@example.com> refs/tags/multi-ref1-100000-user1
+ 100000 <user2@example.com> refs/tags/multi-ref2-100000-user2
+ 100000 <user2@example.com> refs/tags/multi-ref1-100000-user2
+ 200000 <user1@example.com> refs/tags/multi-ref2-200000-user1
+ 200000 <user1@example.com> refs/tags/multi-ref1-200000-user1
+ 200000 <user2@example.com> refs/tags/multi-ref2-200000-user2
+ 200000 <user2@example.com> refs/tags/multi-ref1-200000-user2
+ EOF
+ git for-each-ref \
+ --format="%(taggerdate:unix) %(taggeremail) %(refname)" \
+ --sort=-refname \
+ --sort=taggeremail \
+ --sort=taggerdate \
+ "refs/tags/multi-*" >actual &&
test_cmp expected actual
'
+test_expect_success 'equivalent sorts fall back on refname' '
+ cat >expected <<-\EOF &&
+ 100000 <user1@example.com> refs/tags/multi-ref1-100000-user1
+ 100000 <user2@example.com> refs/tags/multi-ref1-100000-user2
+ 100000 <user1@example.com> refs/tags/multi-ref2-100000-user1
+ 100000 <user2@example.com> refs/tags/multi-ref2-100000-user2
+ 200000 <user1@example.com> refs/tags/multi-ref1-200000-user1
+ 200000 <user2@example.com> refs/tags/multi-ref1-200000-user2
+ 200000 <user1@example.com> refs/tags/multi-ref2-200000-user1
+ 200000 <user2@example.com> refs/tags/multi-ref2-200000-user2
+ EOF
+ git for-each-ref \
+ --format="%(taggerdate:unix) %(taggeremail) %(refname)" \
+ --sort=taggerdate \
+ "refs/tags/multi-*" >actual &&
+ test_cmp expected actual
+'
test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
test_when_finished "git checkout master" &&
@@ -895,4 +937,44 @@ test_expect_success 'for-each-ref --ignore-case ignores case' '
test_cmp expect actual
'
+test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' '
+ # name refs numerically to avoid case-insensitive filesystem conflicts
+ nr=0 &&
+ for email in a A b B
+ do
+ for subject in a A b B
+ do
+ GIT_COMMITTER_EMAIL="$email@example.com" \
+ git tag -m "tag $subject" icase-$(printf %02d $nr) &&
+ nr=$((nr+1))||
+ return 1
+ done
+ done &&
+ git for-each-ref --ignore-case \
+ --format="%(taggeremail) %(subject) %(refname)" \
+ --sort=refname \
+ --sort=subject \
+ --sort=taggeremail \
+ refs/tags/icase-* >actual &&
+ cat >expect <<-\EOF &&
+ <a@example.com> tag a refs/tags/icase-00
+ <a@example.com> tag A refs/tags/icase-01
+ <A@example.com> tag a refs/tags/icase-04
+ <A@example.com> tag A refs/tags/icase-05
+ <a@example.com> tag b refs/tags/icase-02
+ <a@example.com> tag B refs/tags/icase-03
+ <A@example.com> tag b refs/tags/icase-06
+ <A@example.com> tag B refs/tags/icase-07
+ <b@example.com> tag a refs/tags/icase-08
+ <b@example.com> tag A refs/tags/icase-09
+ <B@example.com> tag a refs/tags/icase-12
+ <B@example.com> tag A refs/tags/icase-13
+ <b@example.com> tag b refs/tags/icase-10
+ <b@example.com> tag B refs/tags/icase-11
+ <B@example.com> tag b refs/tags/icase-14
+ <B@example.com> tag B refs/tags/icase-15
+ EOF
+ test_cmp expect actual
+'
+
test_done