summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/lib-read-tree.sh52
-rwxr-xr-xt/t1005-read-tree-reset.sh141
-rwxr-xr-xt/t1006-cat-file.sh6
-rwxr-xr-xt/t1502-rev-parse-parseopt.sh42
-rwxr-xr-xt/t6010-merge-base.sh28
-rwxr-xr-xt/t6018-rev-list-glob.sh54
-rwxr-xr-xt/t6040-tracking-info.sh24
-rwxr-xr-xt/t6130-pathspec-noglob.sh7
-rwxr-xr-xt/t7406-submodule-update.sh26
-rwxr-xr-xt/t7407-submodule-foreach.sh9
-rw-r--r--t/test-lib.sh4
11 files changed, 290 insertions, 103 deletions
diff --git a/t/lib-read-tree.sh b/t/lib-read-tree.sh
index abc2c6f..ef079af 100644
--- a/t/lib-read-tree.sh
+++ b/t/lib-read-tree.sh
@@ -5,39 +5,39 @@
# write the index and that together with -u it doesn't touch the work tree.
#
read_tree_must_succeed () {
- git ls-files -s >pre-dry-run &&
- git read-tree -n "$@" &&
- git ls-files -s >post-dry-run &&
- test_cmp pre-dry-run post-dry-run &&
- git read-tree "$@"
+ git ls-files -s >pre-dry-run &&
+ git read-tree -n "$@" &&
+ git ls-files -s >post-dry-run &&
+ test_cmp pre-dry-run post-dry-run &&
+ git read-tree "$@"
}
read_tree_must_fail () {
- git ls-files -s >pre-dry-run &&
- test_must_fail git read-tree -n "$@" &&
- git ls-files -s >post-dry-run &&
- test_cmp pre-dry-run post-dry-run &&
- test_must_fail git read-tree "$@"
+ git ls-files -s >pre-dry-run &&
+ test_must_fail git read-tree -n "$@" &&
+ git ls-files -s >post-dry-run &&
+ test_cmp pre-dry-run post-dry-run &&
+ test_must_fail git read-tree "$@"
}
read_tree_u_must_succeed () {
- git ls-files -s >pre-dry-run &&
- git diff-files -p >pre-dry-run-wt &&
- git read-tree -n "$@" &&
- git ls-files -s >post-dry-run &&
- git diff-files -p >post-dry-run-wt &&
- test_cmp pre-dry-run post-dry-run &&
- test_cmp pre-dry-run-wt post-dry-run-wt &&
- git read-tree "$@"
+ git ls-files -s >pre-dry-run &&
+ git diff-files -p >pre-dry-run-wt &&
+ git read-tree -n "$@" &&
+ git ls-files -s >post-dry-run &&
+ git diff-files -p >post-dry-run-wt &&
+ test_cmp pre-dry-run post-dry-run &&
+ test_cmp pre-dry-run-wt post-dry-run-wt &&
+ git read-tree "$@"
}
read_tree_u_must_fail () {
- git ls-files -s >pre-dry-run &&
- git diff-files -p >pre-dry-run-wt &&
- test_must_fail git read-tree -n "$@" &&
- git ls-files -s >post-dry-run &&
- git diff-files -p >post-dry-run-wt &&
- test_cmp pre-dry-run post-dry-run &&
- test_cmp pre-dry-run-wt post-dry-run-wt &&
- test_must_fail git read-tree "$@"
+ git ls-files -s >pre-dry-run &&
+ git diff-files -p >pre-dry-run-wt &&
+ test_must_fail git read-tree -n "$@" &&
+ git ls-files -s >post-dry-run &&
+ git diff-files -p >post-dry-run-wt &&
+ test_cmp pre-dry-run post-dry-run &&
+ test_cmp pre-dry-run-wt post-dry-run-wt &&
+ test_must_fail git read-tree "$@"
}
diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh
index f53de79..0745685 100755
--- a/t/t1005-read-tree-reset.sh
+++ b/t/t1005-read-tree-reset.sh
@@ -8,84 +8,99 @@ test_description='read-tree -u --reset'
# two-tree test
test_expect_success 'setup' '
- git init &&
- mkdir df &&
- echo content >df/file &&
- git add df/file &&
- git commit -m one &&
- git ls-files >expect &&
- rm -rf df &&
- echo content >df &&
- git add df &&
- echo content >new &&
- git add new &&
- git commit -m two
+ git init &&
+ mkdir df &&
+ echo content >df/file &&
+ git add df/file &&
+ git commit -m one &&
+ git ls-files >expect &&
+ rm -rf df &&
+ echo content >df &&
+ git add df &&
+ echo content >new &&
+ git add new &&
+ git commit -m two
'
test_expect_success 'reset should work' '
- read_tree_u_must_succeed -u --reset HEAD^ &&
- git ls-files >actual &&
- test_cmp expect actual
+ read_tree_u_must_succeed -u --reset HEAD^ &&
+ git ls-files >actual &&
+ test_cmp expect actual
'
test_expect_success 'reset should remove remnants from a failed merge' '
- read_tree_u_must_succeed --reset -u HEAD &&
- git ls-files -s >expect &&
- sha1=$(git rev-parse :new) &&
- (
- echo "100644 $sha1 1 old"
- echo "100644 $sha1 3 old"
- ) | git update-index --index-info &&
- >old &&
- git ls-files -s &&
- read_tree_u_must_succeed --reset -u HEAD &&
- git ls-files -s >actual &&
- ! test -f old
+ read_tree_u_must_succeed --reset -u HEAD &&
+ git ls-files -s >expect &&
+ sha1=$(git rev-parse :new) &&
+ (
+ echo "100644 $sha1 1 old"
+ echo "100644 $sha1 3 old"
+ ) | git update-index --index-info &&
+ >old &&
+ git ls-files -s &&
+ read_tree_u_must_succeed --reset -u HEAD &&
+ git ls-files -s >actual &&
+ ! test -f old
+'
+
+test_expect_success 'two-way reset should remove remnants too' '
+ read_tree_u_must_succeed --reset -u HEAD &&
+ git ls-files -s >expect &&
+ sha1=$(git rev-parse :new) &&
+ (
+ echo "100644 $sha1 1 old"
+ echo "100644 $sha1 3 old"
+ ) | git update-index --index-info &&
+ >old &&
+ git ls-files -s &&
+ read_tree_u_must_succeed --reset -u HEAD HEAD &&
+ git ls-files -s >actual &&
+ ! test -f old
'
test_expect_success 'Porcelain reset should remove remnants too' '
- read_tree_u_must_succeed --reset -u HEAD &&
- git ls-files -s >expect &&
- sha1=$(git rev-parse :new) &&
- (
- echo "100644 $sha1 1 old"
- echo "100644 $sha1 3 old"
- ) | git update-index --index-info &&
- >old &&
- git ls-files -s &&
- git reset --hard &&
- git ls-files -s >actual &&
- ! test -f old
+ read_tree_u_must_succeed --reset -u HEAD &&
+ git ls-files -s >expect &&
+ sha1=$(git rev-parse :new) &&
+ (
+ echo "100644 $sha1 1 old"
+ echo "100644 $sha1 3 old"
+ ) | git update-index --index-info &&
+ >old &&
+ git ls-files -s &&
+ git reset --hard &&
+ git ls-files -s >actual &&
+ ! test -f old
'
test_expect_success 'Porcelain checkout -f should remove remnants too' '
- read_tree_u_must_succeed --reset -u HEAD &&
- git ls-files -s >expect &&
- sha1=$(git rev-parse :new) &&
- (
- echo "100644 $sha1 1 old"
- echo "100644 $sha1 3 old"
- ) | git update-index --index-info &&
- >old &&
- git ls-files -s &&
- git checkout -f &&
- git ls-files -s >actual &&
- ! test -f old
+ read_tree_u_must_succeed --reset -u HEAD &&
+ git ls-files -s >expect &&
+ sha1=$(git rev-parse :new) &&
+ (
+ echo "100644 $sha1 1 old"
+ echo "100644 $sha1 3 old"
+ ) | git update-index --index-info &&
+ >old &&
+ git ls-files -s &&
+ git checkout -f &&
+ git ls-files -s >actual &&
+ ! test -f old
'
test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
- read_tree_u_must_succeed --reset -u HEAD &&
- git ls-files -s >expect &&
- sha1=$(git rev-parse :new) &&
- (
- echo "100644 $sha1 1 old"
- echo "100644 $sha1 3 old"
- ) | git update-index --index-info &&
- >old &&
- git ls-files -s &&
- git checkout -f HEAD &&
- git ls-files -s >actual &&
- ! test -f old
+ read_tree_u_must_succeed --reset -u HEAD &&
+ git ls-files -s >expect &&
+ sha1=$(git rev-parse :new) &&
+ (
+ echo "100644 $sha1 1 old"
+ echo "100644 $sha1 3 old"
+ ) | git update-index --index-info &&
+ >old &&
+ git ls-files -s &&
+ git checkout -f HEAD &&
+ git ls-files -s >actual &&
+ ! test -f old
'
test_done
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index a420742..8a1bc5c 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -194,6 +194,12 @@ test_expect_success "--batch-check for an emtpy line" '
test " missing" = "$(echo | git cat-file --batch-check)"
'
+test_expect_success 'empty --batch-check notices missing object' '
+ echo "$_z40 missing" >expect &&
+ echo "$_z40" | git cat-file --batch-check="" >actual &&
+ test_cmp expect actual
+'
+
batch_input="$hello_sha1
$commit_sha1
$tag_sha1
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 13c88c9..83b1300 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -12,9 +12,11 @@ usage: some-command [options] <args>...
-h, --help show the help
--foo some nifty option --foo
--bar ... some cool option --bar with an argument
+ -b, --baz a short and long option
An option group Header
-C[...] option C with an optional argument
+ -d, --data[=...] short and long option with an optional argument
Extras
--extra1 line above used to cause a segfault but no longer does
@@ -31,9 +33,11 @@ h,help show the help
foo some nifty option --foo
bar= some cool option --bar with an argument
+b,baz a short and long option
An option group Header
C? option C with an optional argument
+d,data? short and long option with an optional argument
Extras
extra1 line above used to cause a segfault but no longer does
@@ -45,16 +49,16 @@ test_expect_success 'test --parseopt help output' '
'
cat > expect <<EOF
-set -- --foo --bar 'ham' -- 'arg'
+set -- --foo --bar 'ham' -b -- 'arg'
EOF
test_expect_success 'test --parseopt' '
- git rev-parse --parseopt -- --foo --bar=ham arg < optionspec > output &&
+ git rev-parse --parseopt -- --foo --bar=ham --baz arg < optionspec > output &&
test_cmp expect output
'
test_expect_success 'test --parseopt with mixed options and arguments' '
- git rev-parse --parseopt -- --foo arg --bar=ham < optionspec > output &&
+ git rev-parse --parseopt -- --foo arg --bar=ham --baz < optionspec > output &&
test_cmp expect output
'
@@ -99,4 +103,36 @@ test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option withou
test_cmp expect output
'
+cat > expect <<EOF
+set -- --foo --bar='z' --baz -C'Z' --data='A' -- 'arg'
+EOF
+
+test_expect_success 'test --parseopt --stuck-long' '
+ git rev-parse --parseopt --stuck-long -- --foo --bar=z -b arg -CZ -dA <optionspec >output &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --data='' -C --baz -- 'arg'
+EOF
+
+test_expect_success 'test --parseopt --stuck-long and empty optional argument' '
+ git rev-parse --parseopt --stuck-long -- --data= arg -C -b <optionspec >output &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --data --baz -- 'arg'
+EOF
+
+test_expect_success 'test --parseopt --stuck-long and long option with unset optional argument' '
+ git rev-parse --parseopt --stuck-long -- --data arg -b <optionspec >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'test --parseopt --stuck-long and short option with unset optional argument' '
+ git rev-parse --parseopt --stuck-long -- -d arg -b <optionspec >output &&
+ test_cmp expect output
+'
+
test_done
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index f80bba8..30a6833 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -230,4 +230,32 @@ test_expect_success 'criss-cross merge-base for octopus-step' '
test_cmp expected.sorted actual.sorted
'
+test_expect_success 'using reflog to find the fork point' '
+ git reset --hard &&
+ git checkout -b base $E &&
+
+ (
+ for count in 1 2 3
+ do
+ git commit --allow-empty -m "Base commit #$count" &&
+ git rev-parse HEAD >expect$count &&
+ git checkout -B derived &&
+ git commit --allow-empty -m "Derived #$count" &&
+ git rev-parse HEAD >derived$count &&
+ git checkout -B base $E || exit 1
+ done
+
+ for count in 1 2 3
+ do
+ git merge-base --fork-point base $(cat derived$count) >actual &&
+ test_cmp expect$count actual || exit 1
+ done
+
+ ) &&
+ # check that we correctly default to HEAD
+ git checkout derived &&
+ git merge-base --fork-point base >actual &&
+ test_cmp expect3 actual
+'
+
test_done
diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh
index f00cebf..d00f7db 100755
--- a/t/t6018-rev-list-glob.sh
+++ b/t/t6018-rev-list-glob.sh
@@ -129,6 +129,18 @@ test_expect_success 'rev-parse --remotes=foo' '
'
+test_expect_success 'rev-parse --exclude with --branches' '
+ compare rev-parse "--exclude=*/* --branches" "master someref subspace-x"
+'
+
+test_expect_success 'rev-parse --exclude with --all' '
+ compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags"
+'
+
+test_expect_success 'rev-parse accumulates multiple --exclude' '
+ compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
+'
+
test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
@@ -231,6 +243,48 @@ test_expect_success 'rev-list --remotes=foo' '
'
+test_expect_success 'rev-list --exclude with --branches' '
+ compare rev-list "--exclude=*/* --branches" "master someref subspace-x"
+'
+
+test_expect_success 'rev-list --exclude with --all' '
+ compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags"
+'
+
+test_expect_success 'rev-list accumulates multiple --exclude' '
+ compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
+'
+
+
+# "git rev-list<ENTER>" is likely to be a bug in the calling script and may
+# deserve an error message, but do cases where set of refs programatically
+# given using globbing and/or --stdin need to fail with the same error, or
+# are we better off reporting a success with no output? The following few
+# tests document the current behaviour to remind us that we might want to
+# think about this issue.
+
+test_expect_failure 'rev-list may want to succeed with empty output on no input (1)' '
+ >expect &&
+ git rev-list --stdin <expect >actual &&
+ test_cmp expect actual
+'
+
+test_expect_failure 'rev-list may want to succeed with empty output on no input (2)' '
+ >expect &&
+ git rev-list --exclude=* --all >actual &&
+ test_cmp expect actual
+'
+
+test_expect_failure 'rev-list may want to succeed with empty output on no input (3)' '
+ (
+ test_create_repo empty &&
+ cd empty &&
+ >expect &&
+ git rev-list --all >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
compare shortlog "subspace/one subspace/two" --branches=subspace &&
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index ba26cfe..7ac8fd0 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -39,12 +39,14 @@ test_expect_success setup '
advance h
'
-script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
+script='s/^..\(b.\) *[0-9a-f]* \(.*\)$/\1 \2/p'
cat >expect <<\EOF
-b1 ahead 1, behind 1
-b2 ahead 1, behind 1
-b3 behind 1
-b4 ahead 2
+b1 [ahead 1, behind 1] d
+b2 [ahead 1, behind 1] d
+b3 [behind 1] b
+b4 [ahead 2] f
+b5 g
+b6 c
EOF
test_expect_success 'branch -v' '
@@ -57,12 +59,12 @@ test_expect_success 'branch -v' '
'
cat >expect <<\EOF
-b1 origin/master: ahead 1, behind 1
-b2 origin/master: ahead 1, behind 1
-b3 origin/master: behind 1
-b4 origin/master: ahead 2
-b5 brokenbase: gone
-b6 origin/master
+b1 [origin/master: ahead 1, behind 1] d
+b2 [origin/master: ahead 1, behind 1] d
+b3 [origin/master: behind 1] b
+b4 [origin/master: ahead 2] f
+b5 [brokenbase: gone] g
+b6 [origin/master] c
EOF
test_expect_success 'branch -vv' '
diff --git a/t/t6130-pathspec-noglob.sh b/t/t6130-pathspec-noglob.sh
index ea00d71..6583532 100755
--- a/t/t6130-pathspec-noglob.sh
+++ b/t/t6130-pathspec-noglob.sh
@@ -108,6 +108,13 @@ test_expect_success 'no-glob environment variable works' '
test_cmp expect actual
'
+test_expect_success 'blame takes global pathspec flags' '
+ git --literal-pathspecs blame -- foo &&
+ git --icase-pathspecs blame -- foo &&
+ git --glob-pathspecs blame -- foo &&
+ git --noglob-pathspecs blame -- foo
+'
+
test_expect_success 'setup xxx/bar' '
mkdir xxx &&
test_commit xxx xxx/bar
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index f0b3305..0246e80 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -323,6 +323,21 @@ test_expect_success 'submodule update - command in .git/config catches failure'
)
'
+test_expect_success 'submodule init does not copy command into .git/config' '
+ (cd super &&
+ H=$(git ls-files -s submodule | cut -d" " -f2) &&
+ mkdir submodule1 &&
+ git update-index --add --cacheinfo 160000 $H submodule1 &&
+ git config -f .gitmodules submodule.submodule1.path submodule1 &&
+ git config -f .gitmodules submodule.submodule1.url ../submodule &&
+ git config -f .gitmodules submodule.submodule1.update !false &&
+ git submodule init submodule1 &&
+ echo "none" >expect &&
+ git config submodule.submodule1.update >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'submodule init picks up rebase' '
(cd super &&
git config -f .gitmodules submodule.rebasing.update rebase &&
@@ -747,6 +762,17 @@ test_expect_success 'submodule update clone shallow submodule' '
(cd submodule &&
test 1 = $(git log --oneline | wc -l)
)
+)
+'
+
+test_expect_success 'submodule update --recursive drops module name before recursing' '
+ (cd super2 &&
+ (cd deeper/submodule/subsubmodule &&
+ git checkout HEAD^
+ ) &&
+ git submodule update --recursive deeper/submodule >actual &&
+ test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
)
'
+
test_done
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index b64c9ed..7ca10b8 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -325,4 +325,13 @@ test_expect_success 'command passed to foreach --recursive retains notion of std
test_cmp expected actual
'
+test_expect_success 'multi-argument command passed to foreach is not shell-evaluated twice' '
+ (
+ cd super &&
+ git submodule foreach "echo \\\"quoted\\\"" > ../expected &&
+ git submodule foreach echo \"quoted\" > ../actual
+ ) &&
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index b25249e..d303e6c 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -26,6 +26,10 @@ then
# outside of t/, e.g. for running tests on the test library
# itself.
TEST_DIRECTORY=$(pwd)
+else
+ # ensure that TEST_DIRECTORY is an absolute path so that it
+ # is valid even if the current working directory is changed
+ TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
fi
if test -z "$TEST_OUTPUT_DIRECTORY"
then