summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/lib-submodule-update.sh16
-rwxr-xr-xt/perf/p7519-fsmonitor.sh7
-rwxr-xr-xt/t0068-for-each-repo.sh6
-rwxr-xr-xt/t1300-config.sh72
-rwxr-xr-xt/t3203-branch-output.sh51
-rwxr-xr-xt/t4129-apply-samemode.sh2
-rwxr-xr-xt/t5516-fetch-push.sh4
-rwxr-xr-xt/t5526-fetch-submodules.sh117
-rwxr-xr-xt/t5570-git-daemon.sh5
-rwxr-xr-xt/t6007-rev-list-cherry-pick-file.sh12
-rwxr-xr-xt/t6016-rev-list-graph-simplify-history.sh354
-rwxr-xr-xt/t6030-bisect-porcelain.sh16
-rwxr-xr-xt/t7012-skip-worktree-writing.sh88
-rwxr-xr-xt/t7416-submodule-dash-url.sh15
-rwxr-xr-xt/t7610-mergetool.sh11
-rw-r--r--t/test-lib-functions.sh9
16 files changed, 536 insertions, 249 deletions
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index bd3fa3c6da..4b714e9308 100644
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -316,14 +316,7 @@ test_submodule_switch_common () {
command="$1"
######################### Appearing submodule #########################
# Switching to a commit letting a submodule appear creates empty dir ...
- if test "$KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES" = 1
- then
- # Restoring stash fails to restore submodule index entry
- RESULT="failure"
- else
- RESULT="success"
- fi
- test_expect_$RESULT "$command: added submodule creates empty directory" '
+ test_expect_success "$command: added submodule creates empty directory" '
prolog &&
reset_work_tree_to no_submodule &&
(
@@ -337,6 +330,13 @@ test_submodule_switch_common () {
)
'
# ... and doesn't care if it already exists.
+ if test "$KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES" = 1
+ then
+ # Restoring stash fails to restore submodule index entry
+ RESULT="failure"
+ else
+ RESULT="success"
+ fi
test_expect_$RESULT "$command: added submodule leaves existing empty directory alone" '
prolog &&
reset_work_tree_to no_submodule &&
diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh
index 9b43342806..1e20a184c7 100755
--- a/t/perf/p7519-fsmonitor.sh
+++ b/t/perf/p7519-fsmonitor.sh
@@ -129,7 +129,12 @@ setup_for_fsmonitor() {
git config core.fsmonitor "$INTEGRATION_SCRIPT" &&
git update-index --fsmonitor 2>error &&
- test_must_be_empty error # ensure no silent error
+ if test_have_prereq WATCHMAN
+ then
+ test_must_be_empty error # ensure no silent error
+ else
+ grep "Empty last update token" error
+ fi
}
test_perf_w_drop_caches () {
diff --git a/t/t0068-for-each-repo.sh b/t/t0068-for-each-repo.sh
index 136b4ec839..4675e85251 100755
--- a/t/t0068-for-each-repo.sh
+++ b/t/t0068-for-each-repo.sh
@@ -27,4 +27,10 @@ test_expect_success 'run based on configured value' '
grep again message
'
+test_expect_success 'do nothing on empty config' '
+ # the whole thing would fail if for-each-ref iterated even
+ # once, because "git help --no-such-option" would fail
+ git for-each-repo --config=bogus.config -- help --no-such-option
+'
+
test_done
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 97a04c6cc2..1a4156c704 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -12,75 +12,75 @@ test_expect_success 'clear default config' '
'
cat > expect << EOF
-[core]
+[section]
penguin = little blue
EOF
test_expect_success 'initial' '
- git config core.penguin "little blue" &&
+ git config section.penguin "little blue" &&
test_cmp expect .git/config
'
cat > expect << EOF
-[core]
+[section]
penguin = little blue
Movie = BadPhysics
EOF
test_expect_success 'mixed case' '
- git config Core.Movie BadPhysics &&
+ git config Section.Movie BadPhysics &&
test_cmp expect .git/config
'
cat > expect << EOF
-[core]
+[section]
penguin = little blue
Movie = BadPhysics
-[Cores]
+[Sections]
WhatEver = Second
EOF
test_expect_success 'similar section' '
- git config Cores.WhatEver Second &&
+ git config Sections.WhatEver Second &&
test_cmp expect .git/config
'
cat > expect << EOF
-[core]
+[section]
penguin = little blue
Movie = BadPhysics
UPPERCASE = true
-[Cores]
+[Sections]
WhatEver = Second
EOF
test_expect_success 'uppercase section' '
- git config CORE.UPPERCASE true &&
+ git config SECTION.UPPERCASE true &&
test_cmp expect .git/config
'
test_expect_success 'replace with non-match' '
- git config core.penguin kingpin !blue
+ git config section.penguin kingpin !blue
'
test_expect_success 'replace with non-match (actually matching)' '
- git config core.penguin "very blue" !kingpin
+ git config section.penguin "very blue" !kingpin
'
cat > expect << EOF
-[core]
+[section]
penguin = very blue
Movie = BadPhysics
UPPERCASE = true
penguin = kingpin
-[Cores]
+[Sections]
WhatEver = Second
EOF
test_expect_success 'non-match result' 'test_cmp expect .git/config'
test_expect_success 'find mixed-case key by canonical name' '
- test_cmp_config Second cores.whatever
+ test_cmp_config Second sections.whatever
'
test_expect_success 'find mixed-case key by non-canonical name' '
- test_cmp_config Second CoReS.WhAtEvEr
+ test_cmp_config Second SeCtIoNs.WhAtEvEr
'
test_expect_success 'subsections are not canonicalized by git-config' '
@@ -469,7 +469,8 @@ test_expect_success 'new variable inserts into proper section' '
'
test_expect_success 'alternative --file (non-existing file should fail)' '
- test_must_fail git config --file non-existing-config -l
+ test_must_fail git config --file non-existing-config -l &&
+ test_must_fail git config --file non-existing-config test.xyzzy
'
cat > other-config << EOF
@@ -506,10 +507,6 @@ test_expect_success 'editing stdin is an error' '
test_expect_success 'refer config from subdirectory' '
mkdir x &&
- test_cmp_config -C x strasse --get --file ../other-config ein.bahn
-'
-
-test_expect_success 'refer config from subdirectory via --file' '
test_cmp_config -C x strasse --file=../other-config --get ein.bahn
'
@@ -1036,11 +1033,6 @@ test_expect_success SYMLINKS 'symlinked configuration' '
test_cmp expect actual
'
-test_expect_success 'nonexistent configuration' '
- test_must_fail git config --file=doesnotexist --list &&
- test_must_fail git config --file=doesnotexist test.xyzzy
-'
-
test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
ln -s doesnotexist linktonada &&
ln -s linktonada linktolinktonada &&
@@ -1065,12 +1057,12 @@ test_expect_success 'git -c "key=value" support' '
true
EOF
{
- git -c core.name=value config core.name &&
+ git -c section.name=value config section.name &&
git -c foo.CamelCase=value config foo.camelcase &&
git -c foo.flag config --bool foo.flag
} >actual &&
test_cmp expect actual &&
- test_must_fail git -c name=value config core.name
+ test_must_fail git -c name=value config section.name
'
# We just need a type-specifier here that cares about the
@@ -1115,7 +1107,7 @@ test_expect_success 'aliases can be CamelCased' '
test_expect_success 'git -c does not split values on equals' '
echo "value with = in it" >expect &&
- git -c core.foo="value with = in it" config core.foo >actual &&
+ git -c section.foo="value with = in it" config section.foo >actual &&
test_cmp expect actual
'
@@ -1846,53 +1838,53 @@ do
done
cat >.git/config <<-\EOF &&
-[core]
+[section]
foo = true
number = 10
big = 1M
EOF
test_expect_success 'identical modern --type specifiers are allowed' '
- test_cmp_config 1048576 --type=int --type=int core.big
+ test_cmp_config 1048576 --type=int --type=int section.big
'
test_expect_success 'identical legacy --type specifiers are allowed' '
- test_cmp_config 1048576 --int --int core.big
+ test_cmp_config 1048576 --int --int section.big
'
test_expect_success 'identical mixed --type specifiers are allowed' '
- test_cmp_config 1048576 --int --type=int core.big
+ test_cmp_config 1048576 --int --type=int section.big
'
test_expect_success 'non-identical modern --type specifiers are not allowed' '
- test_must_fail git config --type=int --type=bool core.big 2>error &&
+ test_must_fail git config --type=int --type=bool section.big 2>error &&
test_i18ngrep "only one type at a time" error
'
test_expect_success 'non-identical legacy --type specifiers are not allowed' '
- test_must_fail git config --int --bool core.big 2>error &&
+ test_must_fail git config --int --bool section.big 2>error &&
test_i18ngrep "only one type at a time" error
'
test_expect_success 'non-identical mixed --type specifiers are not allowed' '
- test_must_fail git config --type=int --bool core.big 2>error &&
+ test_must_fail git config --type=int --bool section.big 2>error &&
test_i18ngrep "only one type at a time" error
'
test_expect_success '--type allows valid type specifiers' '
- test_cmp_config true --type=bool core.foo
+ test_cmp_config true --type=bool section.foo
'
test_expect_success '--no-type unsets type specifiers' '
- test_cmp_config 10 --type=bool --no-type core.number
+ test_cmp_config 10 --type=bool --no-type section.number
'
test_expect_success 'unset type specifiers may be reset to conflicting ones' '
- test_cmp_config 1048576 --type=bool --no-type --type=int core.big
+ test_cmp_config 1048576 --type=bool --no-type --type=int section.big
'
test_expect_success '--type rejects unknown specifiers' '
- test_must_fail git config --type=nonsense core.foo 2>error &&
+ test_must_fail git config --type=nonsense section.foo 2>error &&
test_i18ngrep "unrecognized --type argument" error
'
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index b945faf470..5e0577d5c7 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -210,7 +210,7 @@ EOF
test_i18ncmp expect actual
'
-test_expect_success 'git branch `--sort` option' '
+test_expect_success 'git branch `--sort=[-]objectsize` option' '
cat >expect <<-\EOF &&
* (HEAD detached from fromtag)
branch-two
@@ -218,6 +218,55 @@ test_expect_success 'git branch `--sort` option' '
main
EOF
git branch --sort=objectsize >actual &&
+ test_i18ncmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ main
+ branch-two
+ EOF
+ git branch --sort=-objectsize >actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'git branch `--sort=[-]type` option' '
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ branch-two
+ main
+ EOF
+ git branch --sort=type >actual &&
+ test_i18ncmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ branch-two
+ main
+ EOF
+ git branch --sort=-type >actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'git branch `--sort=[-]version:refname` option' '
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ branch-two
+ main
+ EOF
+ git branch --sort=version:refname >actual &&
+ test_i18ncmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ main
+ branch-two
+ branch-one
+ EOF
+ git branch --sort=-version:refname >actual &&
test_i18ncmp expect actual
'
diff --git a/t/t4129-apply-samemode.sh b/t/t4129-apply-samemode.sh
index 41818d8315..576632f868 100755
--- a/t/t4129-apply-samemode.sh
+++ b/t/t4129-apply-samemode.sh
@@ -78,7 +78,7 @@ test_expect_success POSIXPERM 'do not use core.sharedRepository for working tree
test_config core.sharedRepository 0666 &&
(
# Remove a default ACL if possible.
- (setfacl -k newdir 2>/dev/null || true) &&
+ (setfacl -k . 2>/dev/null || true) &&
umask 0077 &&
# Test both files (f1) and leading dirs (d)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 01004ff680..3ed121d0ce 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1260,7 +1260,9 @@ do
git cat-file commit $SHA1_2 &&
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
git fetch ../testrepo/.git $SHA1_3 2>err &&
- test_i18ngrep "remote error:.*not our ref.*$SHA1_3\$" err
+ # ideally we would insist this be on a "remote error:"
+ # line, but it is racy; see the commit message
+ test_i18ngrep "not our ref.*$SHA1_3\$" err
)
'
done
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index a877dd145e..53d7b8ed75 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -722,4 +722,121 @@ test_expect_success 'fetch new submodule commit intermittently referenced by sup
)
'
+add_commit_push () {
+ dir="$1" &&
+ msg="$2" &&
+ shift 2 &&
+ git -C "$dir" add "$@" &&
+ git -C "$dir" commit -a -m "$msg" &&
+ git -C "$dir" push
+}
+
+compare_refs_in_dir () {
+ fail= &&
+ if test "x$1" = 'x!'
+ then
+ fail='!' &&
+ shift
+ fi &&
+ git -C "$1" rev-parse --verify "$2" >expect &&
+ git -C "$3" rev-parse --verify "$4" >actual &&
+ eval $fail test_cmp expect actual
+}
+
+
+test_expect_success 'setup nested submodule fetch test' '
+ # does not depend on any previous test setups
+
+ for repo in outer middle inner
+ do
+ git init --bare $repo &&
+ git clone $repo ${repo}_content &&
+ echo "$repo" >"${repo}_content/file" &&
+ add_commit_push ${repo}_content "initial" file ||
+ return 1
+ done &&
+
+ git clone outer A &&
+ git -C A submodule add "$pwd/middle" &&
+ git -C A/middle/ submodule add "$pwd/inner" &&
+ add_commit_push A/middle/ "adding inner sub" .gitmodules inner &&
+ add_commit_push A/ "adding middle sub" .gitmodules middle &&
+
+ git clone outer B &&
+ git -C B/ submodule update --init middle &&
+
+ compare_refs_in_dir A HEAD B HEAD &&
+ compare_refs_in_dir A/middle HEAD B/middle HEAD &&
+ test_path_is_file B/file &&
+ test_path_is_file B/middle/file &&
+ test_path_is_missing B/middle/inner/file &&
+
+ echo "change on inner repo of A" >"A/middle/inner/file" &&
+ add_commit_push A/middle/inner "change on inner" file &&
+ add_commit_push A/middle "change on inner" inner &&
+ add_commit_push A "change on inner" middle
+'
+
+test_expect_success 'fetching a superproject containing an uninitialized sub/sub project' '
+ # depends on previous test for setup
+
+ git -C B/ fetch &&
+ compare_refs_in_dir A origin/HEAD B origin/HEAD
+'
+
+fetch_with_recursion_abort () {
+ # In a regression the following git call will run into infinite recursion.
+ # To handle that, we connect the sed command to the git call by a pipe
+ # so that sed can kill the infinite recursion when detected.
+ # The recursion creates git output like:
+ # Fetching submodule sub
+ # Fetching submodule sub/sub <-- [1]
+ # Fetching submodule sub/sub/sub
+ # ...
+ # [1] sed will stop reading and cause git to eventually stop and die
+
+ git -C "$1" fetch --recurse-submodules 2>&1 |
+ sed "/Fetching submodule $2[^$]/q" >out &&
+ ! grep "Fetching submodule $2[^$]" out
+}
+
+test_expect_success 'setup recursive fetch with uninit submodule' '
+ # does not depend on any previous test setups
+
+ test_create_repo super &&
+ test_commit -C super initial &&
+ test_create_repo sub &&
+ test_commit -C sub initial &&
+ git -C sub rev-parse HEAD >expect &&
+
+ git -C super submodule add ../sub &&
+ git -C super commit -m "add sub" &&
+
+ git clone super superclone &&
+ git -C superclone submodule status >out &&
+ sed -e "s/^-//" -e "s/ sub.*$//" out >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'recursive fetch with uninit submodule' '
+ # depends on previous test for setup
+
+ fetch_with_recursion_abort superclone sub &&
+ git -C superclone submodule status >out &&
+ sed -e "s/^-//" -e "s/ sub$//" out >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'recursive fetch after deinit a submodule' '
+ # depends on previous test for setup
+
+ git -C superclone submodule update --init sub &&
+ git -C superclone submodule deinit -f sub &&
+
+ fetch_with_recursion_abort superclone sub &&
+ git -C superclone submodule status >out &&
+ sed -e "s/^-//" -e "s/ sub$//" out >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index 8f69a7854f..0fbb194810 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -103,6 +103,11 @@ test_expect_success 'fetch notices corrupt idx' '
)
'
+test_expect_success 'client refuses to ask for repo with newline' '
+ test_must_fail git clone "$GIT_DAEMON_URL/repo$LF.git" dst 2>stderr &&
+ test_i18ngrep newline.is.forbidden stderr
+'
+
test_remote_error()
{
do_export=YesPlease
diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh
index f0268372d2..8bf5ae23c2 100755
--- a/t/t6007-rev-list-cherry-pick-file.sh
+++ b/t/t6007-rev-list-cherry-pick-file.sh
@@ -245,6 +245,18 @@ test_expect_success '--count --left-right' '
test_cmp expect actual
'
+test_expect_success '--cherry-pick with duplicates on each side' '
+ git checkout -b dup-orig &&
+ test_commit dup-base &&
+ git revert dup-base &&
+ git cherry-pick dup-base &&
+ git checkout -b dup-side HEAD~3 &&
+ test_tick &&
+ git cherry-pick -3 dup-orig &&
+ git rev-list --cherry-pick dup-orig...dup-side >actual &&
+ test_must_be_empty actual
+'
+
# Corrupt the object store deliberately to make sure
# the object is not even checked for its existence.
remove_loose_object () {
diff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh
index f5e6e92f5b..f79df8b6d1 100755
--- a/t/t6016-rev-list-graph-simplify-history.sh
+++ b/t/t6016-rev-list-graph-simplify-history.sh
@@ -8,6 +8,12 @@
test_description='--graph and simplified history'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-log-graph.sh
+
+check_graph () {
+ cat >expect &&
+ lib_test_cmp_graph --format=%s "$@"
+}
test_expect_success 'set up rev-list --graph test' '
# 3 commits on branch A
@@ -28,7 +34,7 @@ test_expect_success 'set up rev-list --graph test' '
# Octopus merge B and C into branch A
git checkout A &&
- git merge B C &&
+ git merge B C -m A4 &&
git tag A4 &&
test_commit A5 bar.txt &&
@@ -38,81 +44,64 @@ test_expect_success 'set up rev-list --graph test' '
test_commit C3 foo.txt &&
test_commit C4 bar.txt &&
git checkout A &&
- git merge -s ours C &&
+ git merge -s ours C -m A6 &&
git tag A6 &&
- test_commit A7 bar.txt &&
-
- # Store commit names in variables for later use
- A1=$(git rev-parse --verify A1) &&
- A2=$(git rev-parse --verify A2) &&
- A3=$(git rev-parse --verify A3) &&
- A4=$(git rev-parse --verify A4) &&
- A5=$(git rev-parse --verify A5) &&
- A6=$(git rev-parse --verify A6) &&
- A7=$(git rev-parse --verify A7) &&
- B1=$(git rev-parse --verify B1) &&
- B2=$(git rev-parse --verify B2) &&
- C1=$(git rev-parse --verify C1) &&
- C2=$(git rev-parse --verify C2) &&
- C3=$(git rev-parse --verify C3) &&
- C4=$(git rev-parse --verify C4)
- '
+ test_commit A7 bar.txt
+'
test_expect_success '--graph --all' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "| * $C3" >> expected &&
- echo "* | $A5" >> expected &&
- echo "| | " >> expected &&
- echo "| \\ " >> expected &&
- echo "*-. | $A4" >> expected &&
- echo "|\\ \\| " >> expected &&
- echo "| | * $C2" >> expected &&
- echo "| | * $C1" >> expected &&
- echo "| * | $B2" >> expected &&
- echo "| * | $B1" >> expected &&
- echo "* | | $A3" >> expected &&
- echo "| |/ " >> expected &&
- echo "|/| " >> expected &&
- echo "* | $A2" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A1" >> expected &&
- git rev-list --graph --all > actual &&
- test_cmp expected actual
- '
+ check_graph --all <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ | * C3
+ * | A5
+ | |
+ | \
+ *-. | A4
+ |\ \|
+ | | * C2
+ | | * C1
+ | * | B2
+ | * | B1
+ * | | A3
+ | |/
+ |/|
+ * | A2
+ |/
+ * A1
+ EOF
+'
# Make sure the graph_is_interesting() code still realizes
# that undecorated merges are interesting, even with --simplify-by-decoration
test_expect_success '--graph --simplify-by-decoration' '
- rm -f expected &&
git tag -d A4 &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "| * $C3" >> expected &&
- echo "* | $A5" >> expected &&
- echo "| | " >> expected &&
- echo "| \\ " >> expected &&
- echo "*-. | $A4" >> expected &&
- echo "|\\ \\| " >> expected &&
- echo "| | * $C2" >> expected &&
- echo "| | * $C1" >> expected &&
- echo "| * | $B2" >> expected &&
- echo "| * | $B1" >> expected &&
- echo "* | | $A3" >> expected &&
- echo "| |/ " >> expected &&
- echo "|/| " >> expected &&
- echo "* | $A2" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A1" >> expected &&
- git rev-list --graph --all --simplify-by-decoration > actual &&
- test_cmp expected actual
- '
+ check_graph --all --simplify-by-decoration <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ | * C3
+ * | A5
+ | |
+ | \
+ *-. | A4
+ |\ \|
+ | | * C2
+ | | * C1
+ | * | B2
+ | * | B1
+ * | | A3
+ | |/
+ |/|
+ * | A2
+ |/
+ * A1
+ EOF
+'
test_expect_success 'setup: get rid of decorations on B' '
git tag -d B2 &&
@@ -122,142 +111,133 @@ test_expect_success 'setup: get rid of decorations on B' '
# Graph with branch B simplified away
test_expect_success '--graph --simplify-by-decoration prune branch B' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "| * $C3" >> expected &&
- echo "* | $A5" >> expected &&
- echo "* | $A4" >> expected &&
- echo "|\\| " >> expected &&
- echo "| * $C2" >> expected &&
- echo "| * $C1" >> expected &&
- echo "* | $A3" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A2" >> expected &&
- echo "* $A1" >> expected &&
- git rev-list --graph --simplify-by-decoration --all > actual &&
- test_cmp expected actual
- '
+ check_graph --simplify-by-decoration --all <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ | * C3
+ * | A5
+ * | A4
+ |\|
+ | * C2
+ | * C1
+ * | A3
+ |/
+ * A2
+ * A1
+ EOF
+'
test_expect_success '--graph --full-history -- bar.txt' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "* | $A5" >> expected &&
- echo "* | $A4" >> expected &&
- echo "|\\| " >> expected &&
- echo "* | $A3" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A2" >> expected &&
- git rev-list --graph --full-history --all -- bar.txt > actual &&
- test_cmp expected actual
- '
+ check_graph --full-history --all -- bar.txt <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ * | A5
+ * | A4
+ |\|
+ * | A3
+ |/
+ * A2
+ EOF
+'
test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "* | $A5" >> expected &&
- echo "* | $A3" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A2" >> expected &&
- git rev-list --graph --full-history --simplify-merges --all \
- -- bar.txt > actual &&
- test_cmp expected actual
- '
+ check_graph --full-history --simplify-merges --all -- bar.txt <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ * | A5
+ * | A3
+ |/
+ * A2
+ EOF
+'
test_expect_success '--graph -- bar.txt' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A5" >> expected &&
- echo "* $A3" >> expected &&
- echo "| * $C4" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A2" >> expected &&
- git rev-list --graph --all -- bar.txt > actual &&
- test_cmp expected actual
- '
+ check_graph --all -- bar.txt <<-\EOF
+ * A7
+ * A5
+ * A3
+ | * C4
+ |/
+ * A2
+ EOF
+'
test_expect_success '--graph --sparse -- bar.txt' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "* $A5" >> expected &&
- echo "* $A4" >> expected &&
- echo "* $A3" >> expected &&
- echo "| * $C4" >> expected &&
- echo "| * $C3" >> expected &&
- echo "| * $C2" >> expected &&
- echo "| * $C1" >> expected &&
- echo "|/ " >> expected &&
- echo "* $A2" >> expected &&
- echo "* $A1" >> expected &&
- git rev-list --graph --sparse --all -- bar.txt > actual &&
- test_cmp expected actual
- '
+ check_graph --sparse --all -- bar.txt <<-\EOF
+ * A7
+ * A6
+ * A5
+ * A4
+ * A3
+ | * C4
+ | * C3
+ | * C2
+ | * C1
+ |/
+ * A2
+ * A1
+ EOF
+'
test_expect_success '--graph ^C4' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "* $A5" >> expected &&
- echo "* $A4" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $B2" >> expected &&
- echo "| * $B1" >> expected &&
- echo "* $A3" >> expected &&
- git rev-list --graph --all ^C4 > actual &&
- test_cmp expected actual
- '
+ check_graph --all ^C4 <<-\EOF
+ * A7
+ * A6
+ * A5
+ * A4
+ |\
+ | * B2
+ | * B1
+ * A3
+ EOF
+'
test_expect_success '--graph ^C3' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "* $A5" >> expected &&
- echo "* $A4" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $B2" >> expected &&
- echo "| * $B1" >> expected &&
- echo "* $A3" >> expected &&
- git rev-list --graph --all ^C3 > actual &&
- test_cmp expected actual
- '
+ check_graph --all ^C3 <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ * A5
+ * A4
+ |\
+ | * B2
+ | * B1
+ * A3
+ EOF
+'
# I don't think the ordering of the boundary commits is really
# that important, but this test depends on it. If the ordering ever changes
# in the code, we'll need to update this test.
test_expect_success '--graph --boundary ^C3' '
- rm -f expected &&
- echo "* $A7" >> expected &&
- echo "* $A6" >> expected &&
- echo "|\\ " >> expected &&
- echo "| * $C4" >> expected &&
- echo "* | $A5" >> expected &&
- echo "| | " >> expected &&
- echo "| \\ " >> expected &&
- echo "*-. \\ $A4" >> expected &&
- echo "|\\ \\ \\ " >> expected &&
- echo "| * | | $B2" >> expected &&
- echo "| * | | $B1" >> expected &&
- echo "* | | | $A3" >> expected &&
- echo "o | | | $A2" >> expected &&
- echo "|/ / / " >> expected &&
- echo "o / / $A1" >> expected &&
- echo " / / " >> expected &&
- echo "| o $C3" >> expected &&
- echo "|/ " >> expected &&
- echo "o $C2" >> expected &&
- git rev-list --graph --boundary --all ^C3 > actual &&
- test_cmp expected actual
- '
+ check_graph --boundary --all ^C3 <<-\EOF
+ * A7
+ * A6
+ |\
+ | * C4
+ * | A5
+ | |
+ | \
+ *-. \ A4
+ |\ \ \
+ | * | | B2
+ | * | | B1
+ * | | | A3
+ o | | | A2
+ |/ / /
+ o / / A1
+ / /
+ | o C3
+ |/
+ o C2
+ EOF
+'
test_done
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index aa226381be..52614eefc7 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -926,14 +926,14 @@ test_expect_success 'git bisect reset cleans bisection state properly' '
git bisect bad $HASH4 &&
git bisect reset &&
test -z "$(git for-each-ref "refs/bisect/*")" &&
- test_path_is_missing "$GIT_DIR/BISECT_EXPECTED_REV" &&
- test_path_is_missing "$GIT_DIR/BISECT_ANCESTORS_OK" &&
- test_path_is_missing "$GIT_DIR/BISECT_LOG" &&
- test_path_is_missing "$GIT_DIR/BISECT_RUN" &&
- test_path_is_missing "$GIT_DIR/BISECT_TERMS" &&
- test_path_is_missing "$GIT_DIR/head-name" &&
- test_path_is_missing "$GIT_DIR/BISECT_HEAD" &&
- test_path_is_missing "$GIT_DIR/BISECT_START"
+ test_path_is_missing ".git/BISECT_EXPECTED_REV" &&
+ test_path_is_missing ".git/BISECT_ANCESTORS_OK" &&
+ test_path_is_missing ".git/BISECT_LOG" &&
+ test_path_is_missing ".git/BISECT_RUN" &&
+ test_path_is_missing ".git/BISECT_TERMS" &&
+ test_path_is_missing ".git/head-name" &&
+ test_path_is_missing ".git/BISECT_HEAD" &&
+ test_path_is_missing ".git/BISECT_START"
'
test_done
diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh
index 7476781979..e5c6a038fb 100755
--- a/t/t7012-skip-worktree-writing.sh
+++ b/t/t7012-skip-worktree-writing.sh
@@ -149,6 +149,94 @@ test_expect_success '--ignore-skip-worktree-entries leaves worktree alone' '
--diff-filter=D -- keep-me.t
'
+test_expect_success 'stash restore in sparse checkout' '
+ test_create_repo stash-restore &&
+ (
+ cd stash-restore &&
+
+ mkdir subdir &&
+ echo A >subdir/A &&
+ echo untouched >untouched &&
+ echo removeme >removeme &&
+ echo modified >modified &&
+ git add . &&
+ git commit -m Initial &&
+
+ echo AA >>subdir/A &&
+ echo addme >addme &&
+ echo tweaked >>modified &&
+ rm removeme &&
+ git add addme &&
+
+ git stash push &&
+
+ git sparse-checkout set subdir &&
+
+ # Ensure after sparse-checkout we only have expected files
+ cat >expect <<-EOF &&
+ S modified
+ S removeme
+ H subdir/A
+ S untouched
+ EOF
+ git ls-files -t >actual &&
+ test_cmp expect actual &&
+
+ test_path_is_missing addme &&
+ test_path_is_missing modified &&
+ test_path_is_missing removeme &&
+ test_path_is_file subdir/A &&
+ test_path_is_missing untouched &&
+
+ # Put a file in the working directory in the way
+ echo in the way >modified &&
+ git stash apply &&
+
+ # Ensure stash vivifies modifies paths...
+ cat >expect <<-EOF &&
+ H addme
+ H modified
+ H removeme
+ H subdir/A
+ S untouched
+ EOF
+ git ls-files -t >actual &&
+ test_cmp expect actual &&
+
+ # ...and that the paths show up in status as changed...
+ cat >expect <<-EOF &&
+ A addme
+ M modified
+ D removeme
+ M subdir/A
+ ?? actual
+ ?? expect
+ ?? modified.stash.XXXXXX
+ EOF
+ git status --porcelain | \
+ sed -e s/stash......./stash.XXXXXX/ >actual &&
+ test_cmp expect actual &&
+
+ # ...and that working directory reflects the files correctly
+ test_path_is_file addme &&
+ test_path_is_file modified &&
+ test_path_is_missing removeme &&
+ test_path_is_file subdir/A &&
+ test_path_is_missing untouched &&
+
+ # ...including that we have the expected "modified" file...
+ cat >expect <<-EOF &&
+ modified
+ tweaked
+ EOF
+ test_cmp expect modified &&
+
+ # ...and that the other "modified" file is still present...
+ echo in the way >expect &&
+ test_cmp expect modified.stash.*
+ )
+'
+
#TODO test_expect_failure 'git-apply adds file' false
#TODO test_expect_failure 'git-apply updates file' false
#TODO test_expect_failure 'git-apply removes file' false
diff --git a/t/t7416-submodule-dash-url.sh b/t/t7416-submodule-dash-url.sh
index eec96e0ba9..d21dc8b009 100755
--- a/t/t7416-submodule-dash-url.sh
+++ b/t/t7416-submodule-dash-url.sh
@@ -201,4 +201,19 @@ test_expect_success 'fsck rejects embedded newline in relative url' '
grep gitmodulesUrl err
'
+test_expect_success 'fsck rejects embedded newline in git url' '
+ git checkout --orphan git-newline &&
+ cat >.gitmodules <<-\EOF &&
+ [submodule "foo"]
+ url = "git://example.com:1234/repo%0a.git"
+ EOF
+ git add .gitmodules &&
+ git commit -m "git url with newline" &&
+ test_when_finished "rm -rf dst" &&
+ git init --bare dst &&
+ git -C dst config transfer.fsckObjects true &&
+ test_must_fail git push dst HEAD 2>err &&
+ grep gitmodulesUrl err
+'
+
test_done
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index 70afdd06fa..6ac75b5d4c 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -828,4 +828,15 @@ test_expect_success 'mergetool -Oorder-file is honored' '
test_cmp expect actual
'
+test_expect_success 'mergetool --tool-help shows recognized tools' '
+ # Check a few known tools are correctly shown
+ git mergetool --tool-help >mergetools &&
+ grep vimdiff mergetools &&
+ grep vimdiff3 mergetools &&
+ grep gvimdiff2 mergetools &&
+ grep araxis mergetools &&
+ grep xxdiff mergetools &&
+ grep meld mergetools
+'
+
test_done
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 999982fe4a..2f08ce7cba 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -367,9 +367,14 @@ test_chmod () {
git update-index --add "--chmod=$@"
}
-# Get the modebits from a file or directory.
+# Get the modebits from a file or directory, ignoring the setgid bit (g+s).
+# This bit is inherited by subdirectories at their creation. So we remove it
+# from the returning string to prevent callers from having to worry about the
+# state of the bit in the test directory.
+#
test_modebits () {
- ls -ld "$1" | sed -e 's|^\(..........\).*|\1|'
+ ls -ld "$1" | sed -e 's|^\(..........\).*|\1|' \
+ -e 's|^\(......\)S|\1-|' -e 's|^\(......\)s|\1x|'
}
# Unset a configuration variable, but don't fail if it doesn't exist.