Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/lib-submodule-update.sh16
-rw-r--r--t/oid-info/README2
-rwxr-xr-xt/perf/p7519-fsmonitor.sh7
-rw-r--r--t/perf/perf-lib.sh5
-rwxr-xr-xt/t0068-for-each-repo.sh6
-rwxr-xr-xt/t1006-cat-file.sh2
-rwxr-xr-xt/t1300-config.sh72
-rwxr-xr-xt/t1500-rev-parse.sh57
-rwxr-xr-xt/t1512-rev-parse-disambiguation.sh2
-rwxr-xr-xt/t2406-worktree-repair.sh26
-rwxr-xr-xt/t3200-branch.sh2
-rwxr-xr-xt/t3800-mktag.sh236
-rwxr-xr-xt/t4058-diff-duplicates.sh114
-rwxr-xr-xt/t4129-apply-samemode.sh2
-rwxr-xr-xt/t4205-log-pretty-formats.sh99
-rwxr-xr-xt/t5310-pack-bitmaps.sh177
-rwxr-xr-xt/t5516-fetch-push.sh4
-rwxr-xr-xt/t5526-fetch-submodules.sh117
-rwxr-xr-xt/t6016-rev-list-graph-simplify-history.sh354
-rwxr-xr-xt/t6030-bisect-porcelain.sh16
-rwxr-xr-xt/t6050-replace.sh2
-rwxr-xr-xt/t7012-skip-worktree-writing.sh88
-rwxr-xr-xt/t7601-merge-pull-config.sh66
-rwxr-xr-xt/t7610-mergetool.sh11
-rwxr-xr-xt/t7900-maintenance.sh106
-rwxr-xr-xt/t9902-completion.sh20
-rw-r--r--t/test-lib-functions.sh9
-rw-r--r--t/test-lib.sh7
28 files changed, 1261 insertions, 364 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/oid-info/README b/t/oid-info/README
index 27f843fc00..ca56a74b1e 100644
--- a/t/oid-info/README
+++ b/t/oid-info/README
@@ -5,7 +5,7 @@ starting with `#` are ignored. The key and value are separated by whitespace
(specifically, those whitespace in the default `$IFS`). The key consists only
of shell identifier characters, and the value consists of a hash algorithm,
colon, and value. The hash algorithm also consists only of shell identifier
-characters; it should match the value in sha1-file.c.
+characters; it should match the value in object-file.c.
For example, the following lines map the key "rawsz" to "20" if SHA-1 is in use
and to "32" if SHA-256 is in use:
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/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 22d727cef8..e385c6896f 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -147,10 +147,7 @@ test_run_perf_ () {
"$GTIME" -f "%E %U %S" -o test_time.$i "$SHELL" -c '
. '"$TEST_DIRECTORY"/test-lib-functions.sh'
test_export () {
- [ $# != 0 ] || return 0
- test_export_="$test_export_ $1"
- shift
- test_export "$@"
+ test_export_="$test_export_ $*"
}
'"$1"'
ret=$?
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/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 2f501d2dc9..5d2dc99b74 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -166,7 +166,7 @@ tag_content="$tag_header_without_timestamp 0000000000 +0000
$tag_description"
-tag_sha1=$(echo_without_newline "$tag_content" | git mktag)
+tag_sha1=$(echo_without_newline "$tag_content" | git hash-object -t tag --stdin -w)
tag_size=$(strlen "$tag_content")
run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content" 1
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/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 408b97d5af..51d7d40ec1 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -3,6 +3,16 @@
test_description='test git rev-parse'
. ./test-lib.sh
+test_one () {
+ dir="$1" &&
+ expect="$2" &&
+ shift &&
+ shift &&
+ echo "$expect" >expect &&
+ git -C "$dir" rev-parse "$@" >actual &&
+ test_cmp expect actual
+}
+
# usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir absolute-git-dir
test_rev_parse () {
d=
@@ -60,7 +70,13 @@ ROOT=$(pwd)
test_expect_success 'setup' '
mkdir -p sub/dir work &&
- cp -R .git repo.git
+ cp -R .git repo.git &&
+ git checkout -B main &&
+ test_commit abc &&
+ git checkout -b side &&
+ test_commit def &&
+ git checkout main &&
+ git worktree add worktree side
'
test_rev_parse toplevel false false true '' .git "$ROOT/.git"
@@ -88,6 +104,45 @@ test_rev_parse -C work -g ../repo.git -b t 'GIT_DIR=../repo.git, core.bare = tru
test_rev_parse -C work -g ../repo.git -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
+test_expect_success 'rev-parse --path-format=absolute' '
+ test_one "." "$ROOT/.git" --path-format=absolute --git-dir &&
+ test_one "." "$ROOT/.git" --path-format=absolute --git-common-dir &&
+ test_one "sub/dir" "$ROOT/.git" --path-format=absolute --git-dir &&
+ test_one "sub/dir" "$ROOT/.git" --path-format=absolute --git-common-dir &&
+ test_one "worktree" "$ROOT/.git/worktrees/worktree" --path-format=absolute --git-dir &&
+ test_one "worktree" "$ROOT/.git" --path-format=absolute --git-common-dir &&
+ test_one "." "$ROOT" --path-format=absolute --show-toplevel &&
+ test_one "." "$ROOT/.git/objects" --path-format=absolute --git-path objects &&
+ test_one "." "$ROOT/.git/objects/foo/bar/baz" --path-format=absolute --git-path objects/foo/bar/baz
+'
+
+test_expect_success 'rev-parse --path-format=relative' '
+ test_one "." ".git" --path-format=relative --git-dir &&
+ test_one "." ".git" --path-format=relative --git-common-dir &&
+ test_one "sub/dir" "../../.git" --path-format=relative --git-dir &&
+ test_one "sub/dir" "../../.git" --path-format=relative --git-common-dir &&
+ test_one "worktree" "../.git/worktrees/worktree" --path-format=relative --git-dir &&
+ test_one "worktree" "../.git" --path-format=relative --git-common-dir &&
+ test_one "." "./" --path-format=relative --show-toplevel &&
+ test_one "." ".git/objects" --path-format=relative --git-path objects &&
+ test_one "." ".git/objects/foo/bar/baz" --path-format=relative --git-path objects/foo/bar/baz
+'
+
+test_expect_success '--path-format=relative does not affect --absolute-git-dir' '
+ git rev-parse --path-format=relative --absolute-git-dir >actual &&
+ echo "$ROOT/.git" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--path-format can change in the middle of the command line' '
+ git rev-parse --path-format=absolute --git-dir --path-format=relative --git-path objects/foo/bar >actual &&
+ cat >expect <<-EOF &&
+ $ROOT/.git
+ .git/objects/foo/bar
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success 'git-common-dir from worktree root' '
echo .git >expect &&
git rev-parse --git-common-dir >actual &&
diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 18fa6cf40d..cc889d7a84 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh
@@ -48,7 +48,7 @@ test_expect_success 'blob and tree' '
test_expect_success 'warn ambiguity when no candidate matches type hint' '
test_must_fail git rev-parse --verify 000000000^{commit} 2>actual &&
- test_i18ngrep "short SHA1 000000000 is ambiguous" actual
+ test_i18ngrep "short object ID 000000000 is ambiguous" actual
'
test_expect_success 'disambiguate tree-ish' '
diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh
index 1fe468bfe8..f73741886b 100755
--- a/t/t2406-worktree-repair.sh
+++ b/t/t2406-worktree-repair.sh
@@ -104,6 +104,16 @@ test_expect_success 'repo not found; .git not file' '
test_i18ngrep ".git is not a file" err
'
+test_expect_success 'repo not found; .git not referencing repo' '
+ test_when_finished "rm -rf side not-a-repo && git worktree prune" &&
+ git worktree add --detach side &&
+ sed s,\.git/worktrees/side$,not-a-repo, side/.git >side/.newgit &&
+ mv side/.newgit side/.git &&
+ mkdir not-a-repo &&
+ test_must_fail git worktree repair side 2>err &&
+ test_i18ngrep ".git file does not reference a repository" err
+'
+
test_expect_success 'repo not found; .git file broken' '
test_when_finished "rm -rf orig moved && git worktree prune" &&
git worktree add --detach orig &&
@@ -176,4 +186,20 @@ test_expect_success 'repair multiple gitdir files' '
test_must_be_empty err
'
+test_expect_success 'repair moved main and linked worktrees' '
+ test_when_finished "rm -rf main side mainmoved sidemoved" &&
+ test_create_repo main &&
+ test_commit -C main init &&
+ git -C main worktree add --detach ../side &&
+ sed "s,side/\.git$,sidemoved/.git," \
+ main/.git/worktrees/side/gitdir >expect-gitdir &&
+ sed "s,main/.git/worktrees/side$,mainmoved/.git/worktrees/side," \
+ side/.git >expect-gitfile &&
+ mv main mainmoved &&
+ mv side sidemoved &&
+ git -C mainmoved worktree repair ../sidemoved &&
+ test_cmp expect-gitdir mainmoved/.git/worktrees/side/gitdir &&
+ test_cmp expect-gitfile sidemoved/.git
+'
+
test_done
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 3ec3e1d730..0af3b85d17 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -306,7 +306,9 @@ test_expect_success 'git branch --list -v with --abbrev' '
git branch -v --list --no-abbrev t >actual.noabbrev &&
git branch -v --list --abbrev=0 t >actual.0abbrev &&
+ git -c core.abbrev=no branch -v --list t >actual.noabbrev-conf &&
test_cmp actual.noabbrev actual.0abbrev &&
+ test_cmp actual.noabbrev actual.noabbrev-conf &&
git branch -v --list --abbrev=36 t >actual.36abbrev &&
# how many hexdigits are used?
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index d696aa4e52..86bfeb271e 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -12,10 +12,29 @@ test_description='git mktag: tag object verify test'
# given in the expect.pat file.
check_verify_failure () {
- expect="$2"
+ test_expect_success "$1" "
+ test_must_fail env GIT_TEST_GETTEXT_POISON=false \
+ git mktag <tag.sig 2>message &&
+ grep '$2' message &&
+ if test '$3' != '--no-strict'
+ then
+ test_must_fail env GIT_TEST_GETTEXT_POISON=false \
+ git mktag --no-strict <tag.sig 2>message.no-strict &&
+ grep '$2' message.no-strict
+ fi
+ "
+}
+
+test_expect_mktag_success() {
test_expect_success "$1" '
- ( test_must_fail git mktag <tag.sig 2>message ) &&
- grep "$expect" message
+ git hash-object -t tag -w --stdin <tag.sig >expected &&
+ git fsck --strict &&
+
+ git mktag <tag.sig >hash &&
+ test_cmp expected hash &&
+ test_when_finished "git update-ref -d refs/tags/mytag $(cat hash)" &&
+ git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) &&
+ git fsck --strict
'
}
@@ -23,10 +42,24 @@ check_verify_failure () {
# first create a commit, so we have a valid object/type
# for the tag.
test_expect_success 'setup' '
- echo Hello >A &&
- git update-index --add A &&
- git commit -m "Initial commit" &&
- head=$(git rev-parse --verify HEAD)
+ test_commit A &&
+ test_commit B &&
+ head=$(git rev-parse --verify HEAD) &&
+ head_parent=$(git rev-parse --verify HEAD~) &&
+ tree=$(git rev-parse HEAD^{tree}) &&
+ blob=$(git rev-parse --verify HEAD:B.t)
+'
+
+test_expect_success 'basic usage' '
+ cat >tag.sig <<-EOF &&
+ object $head
+ type commit
+ tag mytag
+ tagger T A Gger <tagger@example.com> 1206478233 -0500
+ EOF
+ git mktag <tag.sig &&
+ git mktag --end-of-options <tag.sig &&
+ test_expect_code 129 git mktag --unknown-option
'
############################################################
@@ -37,33 +70,33 @@ too short for a tag
EOF
check_verify_failure 'Tag object length check' \
- '^error: .*size wrong.*$'
+ '^error:.* missingObject:' 'strict'
############################################################
# 2. object line label check
cat >tag.sig <<EOF
-xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
+xxxxxx $head
type tag
tag mytag
tagger . <> 0 +0000
EOF
-check_verify_failure '"object" line label check' '^error: char0: .*"object "$'
+check_verify_failure '"object" line label check' '^error:.* missingObject:'
############################################################
-# 3. object line SHA1 check
+# 3. object line hash check
cat >tag.sig <<EOF
-object zz9e9b33986b1c2670fff52c5067603117b3e895
+object $(echo $head | tr 0-9a-f z)
type tag
tag mytag
tagger . <> 0 +0000
EOF
-check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
+check_verify_failure '"object" line check' '^error:.* badObjectSha1:'
############################################################
# 4. type line label check
@@ -76,7 +109,7 @@ tagger . <> 0 +0000
EOF
-check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$'
+check_verify_failure '"type" line label check' '^error:.* missingTypeEntry:'
############################################################
# 5. type line eol check
@@ -84,7 +117,7 @@ check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$'
echo "object $head" >tag.sig
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
-check_verify_failure '"type" line eol check' '^error: char.*: .*"\\n"$'
+check_verify_failure '"type" line eol check' '^error:.* unterminatedHeader:'
############################################################
# 6. tag line label check #1
@@ -98,7 +131,7 @@ tagger . <> 0 +0000
EOF
check_verify_failure '"tag" line label check #1' \
- '^error: char.*: no "tag " found$'
+ '^error:.* missingTagEntry:'
############################################################
# 7. tag line label check #2
@@ -110,7 +143,7 @@ tag
EOF
check_verify_failure '"tag" line label check #2' \
- '^error: char.*: no "tag " found$'
+ '^error:.* badType:'
############################################################
# 8. type line type-name length check
@@ -122,21 +155,83 @@ tag mytag
EOF
check_verify_failure '"type" line type-name length check' \
- '^error: char.*: type too long$'
+ '^error:.* badType:'
############################################################
-# 9. verify object (SHA1/type) check
+# 9. verify object (hash/type) check
cat >tag.sig <<EOF
object $(test_oid deadbeef)
+type tag
+tag mytag
+tagger . <> 0 +0000
+
+EOF
+
+check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \
+ '^fatal: could not read tagged object'
+
+cat >tag.sig <<EOF
+object $head
type tagggg
tag mytag
tagger . <> 0 +0000
EOF
-check_verify_failure 'verify object (SHA1/type) check' \
- '^error: char7: could not verify object.*$'
+check_verify_failure 'verify object (hash/type) check -- made-up type, valid object' \
+ '^error:.* badType:'
+
+cat >tag.sig <<EOF
+object $(test_oid deadbeef)
+type tagggg
+tag mytag
+tagger . <> 0 +0000
+
+EOF
+
+check_verify_failure 'verify object (hash/type) check -- made-up type, nonexisting object' \
+ '^error:.* badType:'
+
+cat >tag.sig <<EOF
+object $head
+type tree
+tag mytag
+tagger . <> 0 +0000
+
+EOF
+
+check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
+ '^fatal: object.*tagged as.*tree.*but is.*commit'
+
+############################################################
+# 9.5. verify object (hash/type) check -- replacement
+
+test_expect_success 'setup replacement of commit -> commit and tree -> blob' '
+ git replace $head_parent $head &&
+ git replace -f $tree $blob
+'
+
+cat >tag.sig <<EOF
+object $head_parent
+type commit
+tag mytag
+tagger . <> 0 +0000
+
+EOF
+
+test_expect_mktag_success 'tag to a commit replaced by another commit'
+
+cat >tag.sig <<EOF
+object $tree
+type tree
+tag mytag
+tagger . <> 0 +0000
+
+EOF
+
+check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
+ '^fatal: object.*tagged as.*tree.*but is.*blob'
############################################################
# 10. verify tag-name check
@@ -150,7 +245,7 @@ tagger . <> 0 +0000
EOF
check_verify_failure 'verify tag-name check' \
- '^error: char.*: could not verify tag name$'
+ '^error:.* badTagName:' '--no-strict'
############################################################
# 11. tagger line label check #1
@@ -164,7 +259,7 @@ This is filler
EOF
check_verify_failure '"tagger" line label check #1' \
- '^error: char.*: could not find "tagger "$'
+ '^error:.* missingTaggerEntry:' '--no-strict'
############################################################
# 12. tagger line label check #2
@@ -179,10 +274,10 @@ This is filler
EOF
check_verify_failure '"tagger" line label check #2' \
- '^error: char.*: could not find "tagger "$'
+ '^error:.* missingTaggerEntry:' '--no-strict'
############################################################
-# 13. disallow missing tag author name
+# 13. allow missing tag author name like fsck
cat >tag.sig <<EOF
object $head
@@ -193,8 +288,7 @@ tagger <> 0 +0000
This is filler
EOF
-check_verify_failure 'disallow missing tag author name' \
- '^error: char.*: missing tagger name$'
+test_expect_mktag_success 'allow missing tag author name'
############################################################
# 14. disallow missing tag author name
@@ -209,7 +303,7 @@ tagger T A Gger <
EOF
check_verify_failure 'disallow malformed tagger' \
- '^error: char.*: malformed tagger field$'
+ '^error:.* badEmail:' '--no-strict'
############################################################
# 15. allow empty tag email
@@ -222,12 +316,10 @@ tagger T A Gger <> 0 +0000
EOF
-test_expect_success \
- 'allow empty tag email' \
- 'git mktag <tag.sig >.git/refs/tags/mytag 2>message'
+test_expect_mktag_success 'allow empty tag email'
############################################################
-# 16. disallow spaces in tag email
+# 16. allow spaces in tag email like fsck
cat >tag.sig <<EOF
object $head
@@ -237,8 +329,7 @@ tagger T A Gger <tag ger@example.com> 0 +0000
EOF
-check_verify_failure 'disallow spaces in tag email' \
- '^error: char.*: malformed tagger field$'
+test_expect_mktag_success 'allow spaces in tag email like fsck'
############################################################
# 17. disallow missing tag timestamp
@@ -252,7 +343,7 @@ tagger T A Gger <tagger@example.com>__
EOF
check_verify_failure 'disallow missing tag timestamp' \
- '^error: char.*: missing tag timestamp$'
+ '^error:.* badDate:'
############################################################
# 18. detect invalid tag timestamp1
@@ -266,7 +357,7 @@ tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
EOF
check_verify_failure 'detect invalid tag timestamp1' \
- '^error: char.*: missing tag timestamp$'
+ '^error:.* badDate:'
############################################################
# 19. detect invalid tag timestamp2
@@ -280,7 +371,7 @@ tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500
EOF
check_verify_failure 'detect invalid tag timestamp2' \
- '^error: char.*: malformed tag timestamp$'
+ '^error:.* badDate:'
############################################################
# 20. detect invalid tag timezone1
@@ -294,7 +385,7 @@ tagger T A Gger <tagger@example.com> 1206478233 GMT
EOF
check_verify_failure 'detect invalid tag timezone1' \
- '^error: char.*: malformed tag timezone$'
+ '^error:.* badTimezone:'
############################################################
# 21. detect invalid tag timezone2
@@ -308,10 +399,10 @@ tagger T A Gger <tagger@example.com> 1206478233 + 30
EOF
check_verify_failure 'detect invalid tag timezone2' \
- '^error: char.*: malformed tag timezone$'
+ '^error:.* badTimezone:'
############################################################
-# 22. detect invalid tag timezone3
+# 22. allow invalid tag timezone3 (the maximum is -1200/+1400)
cat >tag.sig <<EOF
object $head
@@ -321,8 +412,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -1430
EOF
-check_verify_failure 'detect invalid tag timezone3' \
- '^error: char.*: malformed tag timezone$'
+test_expect_mktag_success 'allow invalid tag timezone'
############################################################
# 23. detect invalid header entry
@@ -337,10 +427,41 @@ this line should not be here
EOF
check_verify_failure 'detect invalid header entry' \
- '^error: char.*: trailing garbage in tag header$'
+ '^error:.* extraHeaderEntry:' '--no-strict'
-############################################################
-# 24. create valid tag
+test_expect_success 'invalid header entry config & fsck' '
+ test_must_fail git mktag <tag.sig &&
+ git mktag --no-strict <tag.sig &&
+
+ test_must_fail git -c fsck.extraHeaderEntry=error mktag <tag.sig &&
+ test_must_fail git -c fsck.extraHeaderEntry=error mktag --no-strict <tag.sig &&
+
+ test_must_fail git -c fsck.extraHeaderEntry=warn mktag <tag.sig &&
+ git -c fsck.extraHeaderEntry=warn mktag --no-strict <tag.sig &&
+
+ git -c fsck.extraHeaderEntry=ignore mktag <tag.sig &&
+ git -c fsck.extraHeaderEntry=ignore mktag --no-strict <tag.sig &&
+
+ git fsck &&
+ env GIT_TEST_GETTEXT_POISON=false \
+ git -c fsck.extraHeaderEntry=warn fsck 2>err &&
+ grep "warning .*extraHeaderEntry:" err &&
+ test_must_fail env GIT_TEST_GETTEXT_POISON=false \
+ git -c fsck.extraHeaderEntry=error 2>err fsck &&
+ grep "error .* extraHeaderEntry:" err
+'
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 -0500
+
+
+this line comes after an extra newline
+EOF
+
+test_expect_mktag_success 'allow extra newlines at start of body'
cat >tag.sig <<EOF
object $head
@@ -350,16 +471,27 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
EOF
-test_expect_success \
- 'create valid tag' \
- 'git mktag <tag.sig >.git/refs/tags/mytag 2>message'
+test_expect_mktag_success 'allow a blank line before an empty body (1)'
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 -0500
+EOF
+
+test_expect_mktag_success 'allow no blank line before an empty body (2)'
############################################################
-# 25. check mytag
+# 24. create valid tag
-test_expect_success \
- 'check mytag' \
- 'git tag -l | grep mytag'
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 -0500
+EOF
+test_expect_mktag_success 'create valid tag object'
test_done
diff --git a/t/t4058-diff-duplicates.sh b/t/t4058-diff-duplicates.sh
index c24ee175ef..54614b814d 100755
--- a/t/t4058-diff-duplicates.sh
+++ b/t/t4058-diff-duplicates.sh
@@ -1,5 +1,14 @@
#!/bin/sh
+# NOTICE:
+# This testsuite does a number of diffs and checks that the output match.
+# However, it is a "garbage in, garbage out" situation; the trees have
+# duplicate entries for individual paths, and it results in diffs that do
+# not make much sense. As such, it is not clear that the diffs are
+# "correct". The primary purpose of these tests was to verify that
+# diff-tree does not segfault, but there is perhaps some value in ensuring
+# that the diff output isn't wildly unreasonable.
+
test_description='test tree diff when trees have duplicate entries'
. ./test-lib.sh
@@ -57,7 +66,16 @@ test_expect_success 'create trees with duplicate entries' '
git tag two $outer_two
'
-test_expect_success 'diff-tree between trees' '
+test_expect_success 'create tree without duplicate entries' '
+ blob_one=$(echo one | git hash-object -w --stdin) &&
+ outer_three=$(make_tree \
+ 100644 renamed $blob_one
+ ) &&
+ git tag three $outer_three
+'
+
+test_expect_success 'diff-tree between duplicate trees' '
+ # See NOTICE at top of file
{
printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
@@ -71,9 +89,101 @@ test_expect_success 'diff-tree between trees' '
'
test_expect_success 'diff-tree with renames' '
- # same expectation as above, since we disable rename detection
+ # See NOTICE at top of file.
git diff-tree -M -r --no-abbrev one two >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'diff-tree FROM duplicate tree' '
+ # See NOTICE at top of file.
+ {
+ printf ":100644 000000 $blob_one $ZERO_OID D\touter/inner\n" &&
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+ printf ":000000 100644 $ZERO_OID $blob_one A\trenamed\n"
+ } >expect &&
+ git diff-tree -r --no-abbrev one three >actual &&
test_cmp expect actual
'
+test_expect_success 'diff-tree FROM duplicate tree, with renames' '
+ # See NOTICE at top of file.
+ {
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+ printf ":100644 100644 $blob_one $blob_one R100\touter/inner\trenamed\n"
+ } >expect &&
+ git diff-tree -M -r --no-abbrev one three >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'create a few commits' '
+ git commit-tree -m "Duplicate Entries" two^{tree} >commit_id &&
+ git branch base $(cat commit_id) &&
+
+ git commit-tree -p $(cat commit_id) -m "Just one" three^{tree} >up &&
+ git branch update $(cat up) &&
+
+ git commit-tree -p $(cat up) -m "Back to weird" two^{tree} >final &&
+ git branch final $(cat final) &&
+
+ rm commit_id up final
+'
+
+test_expect_failure 'git read-tree does not segfault' '
+ test_when_finished rm .git/index.lock &&
+ test_might_fail git read-tree --reset base
+'
+
+test_expect_failure 'reset --hard does not segfault' '
+ test_when_finished rm .git/index.lock &&
+ git checkout base &&
+ test_might_fail git reset --hard
+'
+
+test_expect_failure 'git diff HEAD does not segfault' '
+ git checkout base &&
+ GIT_TEST_CHECK_CACHE_TREE=false &&
+ git reset --hard &&
+ test_might_fail git diff HEAD
+'
+
+test_expect_failure 'can switch to another branch when status is empty' '
+ git clean -ffdqx &&
+ git status --porcelain -uno >actual &&
+ test_must_be_empty actual &&
+ git checkout update
+'
+
+test_expect_success 'forcibly switch to another branch, verify status empty' '
+ git checkout -f update &&
+ git status --porcelain -uno >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'fast-forward from non-duplicate entries to duplicate' '
+ git merge final
+'
+
+test_expect_failure 'clean status, switch branches, status still clean' '
+ git status --porcelain -uno >actual &&
+ test_must_be_empty actual &&
+ git checkout base &&
+ git status --porcelain -uno >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'switch to base branch and force status to be clean' '
+ git checkout base &&
+ GIT_TEST_CHECK_CACHE_TREE=false git reset --hard &&
+ git status --porcelain -uno >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_failure 'fast-forward from duplicate entries to non-duplicate' '
+ git merge update
+'
+
test_done
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/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 204c149d5a..749bc1431a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -605,6 +605,12 @@ test_expect_success 'pretty format %(trailers) shows trailers' '
test_cmp expect actual
'
+test_expect_success 'pretty format %(trailers:) enables no options' '
+ git log --no-walk --pretty="%(trailers:)" >actual &&
+ # "expect" the same as the test above
+ test_cmp expect actual
+'
+
test_expect_success '%(trailers:only) shows only "key: value" trailers' '
git log --no-walk --pretty="%(trailers:only)" >actual &&
{
@@ -709,19 +715,101 @@ test_expect_success '%(trailers:key) without value is error' '
test_cmp expect actual
'
+test_expect_success '%(trailers:keyonly) shows only keys' '
+ git log --no-walk --pretty="format:%(trailers:keyonly)" >actual &&
+ test_write_lines \
+ "Signed-off-by" \
+ "Acked-by" \
+ "[ v2 updated patch description ]" \
+ "Signed-off-by" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '%(trailers:key=foo,keyonly) shows only key' '
+ git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly)" >actual &&
+ echo "Acked-by" >expect &&
+ test_cmp expect actual
+'
+
test_expect_success '%(trailers:key=foo,valueonly) shows only value' '
git log --no-walk --pretty="format:%(trailers:key=Acked-by,valueonly)" >actual &&
echo "A U Thor <author@example.com>" >expect &&
test_cmp expect actual
'
+test_expect_success '%(trailers:valueonly) shows only values' '
+ git log --no-walk --pretty="format:%(trailers:valueonly)" >actual &&
+ test_write_lines \
+ "A U Thor <author@example.com>" \
+ "A U Thor <author@example.com>" \
+ "[ v2 updated patch description ]" \
+ "A U Thor" \
+ " <author@example.com>" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '%(trailers:key=foo,keyonly,valueonly) shows nothing' '
+ git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly,valueonly)" >actual &&
+ echo >expect &&
+ test_cmp expect actual
+'
+
test_expect_success 'pretty format %(trailers:separator) changes separator' '
+ git log --no-walk --pretty=format:"X%(trailers:separator=%x00)X" >actual &&
+ (
+ printf "XSigned-off-by: A U Thor <author@example.com>\0" &&
+ printf "Acked-by: A U Thor <author@example.com>\0" &&
+ printf "[ v2 updated patch description ]\0" &&
+ printf "Signed-off-by: A U Thor\n <author@example.com>X"
+ ) >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'pretty format %(trailers:separator=X,unfold) changes separator' '
git log --no-walk --pretty=format:"X%(trailers:separator=%x00,unfold)X" >actual &&
- printf "XSigned-off-by: A U Thor <author@example.com>\0Acked-by: A U Thor <author@example.com>\0[ v2 updated patch description ]\0Signed-off-by: A U Thor <author@example.com>X" >expect &&
+ (
+ printf "XSigned-off-by: A U Thor <author@example.com>\0" &&
+ printf "Acked-by: A U Thor <author@example.com>\0" &&
+ printf "[ v2 updated patch description ]\0" &&
+ printf "Signed-off-by: A U Thor <author@example.com>X"
+ ) >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'pretty format %(trailers:key_value_separator) changes key-value separator' '
+ git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00)X" >actual &&
+ (
+ printf "XSigned-off-by\0A U Thor <author@example.com>\n" &&
+ printf "Acked-by\0A U Thor <author@example.com>\n" &&
+ printf "[ v2 updated patch description ]\n" &&
+ printf "Signed-off-by\0A U Thor\n <author@example.com>\nX"
+ ) >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'pretty format %(trailers:key_value_separator,unfold) changes key-value separator' '
+ git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00,unfold)X" >actual &&
+ (
+ printf "XSigned-off-by\0A U Thor <author@example.com>\n" &&
+ printf "Acked-by\0A U Thor <author@example.com>\n" &&
+ printf "[ v2 updated patch description ]\n" &&
+ printf "Signed-off-by\0A U Thor <author@example.com>\nX"
+ ) >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'pretty format %(trailers:separator,key_value_separator) changes both separators' '
+ git log --no-walk --pretty=format:"%(trailers:separator=%x00,key_value_separator=%x00%x00,unfold)" >actual &&
+ (
+ printf "Signed-off-by\0\0A U Thor <author@example.com>\0" &&
+ printf "Acked-by\0\0A U Thor <author@example.com>\0" &&
+ printf "[ v2 updated patch description ]\0" &&
+ printf "Signed-off-by\0\0A U Thor <author@example.com>"
+ ) >expect &&
test_cmp expect actual
'
-test_expect_success 'pretty format %(trailers) combining separator/key/valueonly' '
+test_expect_success 'pretty format %(trailers) combining separator/key/keyonly/valueonly' '
git commit --allow-empty -F - <<-\EOF &&
Important fix
@@ -748,6 +836,13 @@ test_expect_success 'pretty format %(trailers) combining separator/key/valueonly
"Does not close any tickets" \
"Another fix #567, #890" \
"Important fix #1234" >expect &&
+ test_cmp expect actual &&
+
+ git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,keyonly)" HEAD~3.. >actual &&
+ test_write_lines \
+ "Does not close any tickets" \
+ "Another fix Closes, Closes" \
+ "Important fix Closes" >expect &&
test_cmp expect actual
'
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 1d40fcad39..3a2c9d2d8e 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -20,84 +20,172 @@ has_any () {
grep -Ff "$1" "$2"
}
+# To ensure the logic for "maximal commits" is exercised, make
+# the repository a bit more complicated.
+#
+# other second
+# * *
+# (99 commits) (99 commits)
+# * *
+# |\ /|
+# | * octo-other octo-second * |
+# |/|\_________ ____________/|\|
+# | \ \/ __________/ |
+# | | ________/\ / |
+# * |/ * merge-right *
+# | _|__________/ \____________ |
+# |/ | \|
+# (l1) * * merge-left * (r1)
+# | / \________________________ |
+# |/ \|
+# (l2) * * (r2)
+# \___________________________ |
+# \|
+# * (base)
+#
+# We only push bits down the first-parent history, which
+# makes some of these commits unimportant!
+#
+# The important part for the maximal commit algorithm is how
+# the bitmasks are extended. Assuming starting bit positions
+# for second (bit 0) and other (bit 1), the bitmasks at the
+# end should be:
+#
+# second: 1 (maximal, selected)
+# other: 01 (maximal, selected)
+# (base): 11 (maximal)
+#
+# This complicated history was important for a previous
+# version of the walk that guarantees never walking a
+# commit multiple times. That goal might be important
+# again, so preserve this complicated case. For now, this
+# test will guarantee that the bitmaps are computed
+# correctly, even with the repeat calculations.
+
test_expect_success 'setup repo with moderate-sized history' '
- test_commit_bulk --id=file 100 &&
+ test_commit_bulk --id=file 10 &&
+ git branch -M second &&
git checkout -b other HEAD~5 &&
test_commit_bulk --id=side 10 &&
- git checkout master &&
- bitmaptip=$(git rev-parse master) &&
+
+ # add complicated history setup, including merges and
+ # ambiguous merge-bases
+
+ git checkout -b merge-left other~2 &&
+ git merge second~2 -m "merge-left" &&
+
+ git checkout -b merge-right second~1 &&
+ git merge other~1 -m "merge-right" &&
+
+ git checkout -b octo-second second &&
+ git merge merge-left merge-right -m "octopus-second" &&
+
+ git checkout -b octo-other other &&
+ git merge merge-left merge-right -m "octopus-other" &&
+
+ git checkout other &&
+ git merge octo-other -m "pull octopus" &&
+
+ git checkout second &&
+ git merge octo-second -m "pull octopus" &&
+
+ # Remove these branches so they are not selected
+ # as bitmap tips
+ git branch -D merge-left &&
+ git branch -D merge-right &&
+ git branch -D octo-other &&
+ git branch -D octo-second &&
+
+ # add padding to make these merges less interesting
+ # and avoid having them selected for bitmaps
+ test_commit_bulk --id=file 100 &&
+ git checkout other &&
+ test_commit_bulk --id=side 100 &&
+ git checkout second &&
+
+ bitmaptip=$(git rev-parse second) &&
blob=$(echo tagged-blob | git hash-object -w --stdin) &&
git tag tagged-blob $blob &&
git config repack.writebitmaps true
'
test_expect_success 'full repack creates bitmaps' '
- git repack -ad &&
+ GIT_TRACE2_EVENT_NESTING=4 GIT_TRACE2_EVENT="$(pwd)/trace" \
+ git repack -ad &&
ls .git/objects/pack/ | grep bitmap >output &&
- test_line_count = 1 output
+ test_line_count = 1 output &&
+ grep "\"key\":\"num_selected_commits\",\"value\":\"106\"" trace &&
+ grep "\"key\":\"num_maximal_commits\",\"value\":\"107\"" trace
'
test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
git rev-list --test-bitmap HEAD
'
-rev_list_tests() {
- state=$1
-
- test_expect_success "counting commits via bitmap ($state)" '
- git rev-list --count HEAD >expect &&
- git rev-list --use-bitmap-index --count HEAD >actual &&
+rev_list_tests_head () {
+ test_expect_success "counting commits via bitmap ($state, $branch)" '
+ git rev-list --count $branch >expect &&
+ git rev-list --use-bitmap-index --count $branch >actual &&
test_cmp expect actual
'
- test_expect_success "counting partial commits via bitmap ($state)" '
- git rev-list --count HEAD~5..HEAD >expect &&
- git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
+ test_expect_success "counting partial commits via bitmap ($state, $branch)" '
+ git rev-list --count $branch~5..$branch >expect &&
+ git rev-list --use-bitmap-index --count $branch~5..$branch >actual &&
test_cmp expect actual
'
- test_expect_success "counting commits with limit ($state)" '
- git rev-list --count -n 1 HEAD >expect &&
- git rev-list --use-bitmap-index --count -n 1 HEAD >actual &&
+ test_expect_success "counting commits with limit ($state, $branch)" '
+ git rev-list --count -n 1 $branch >expect &&
+ git rev-list --use-bitmap-index --count -n 1 $branch >actual &&
test_cmp expect actual
'
- test_expect_success "counting non-linear history ($state)" '
- git rev-list --count other...master >expect &&
- git rev-list --use-bitmap-index --count other...master >actual &&
+ test_expect_success "counting non-linear history ($state, $branch)" '
+ git rev-list --count other...second >expect &&
+ git rev-list --use-bitmap-index --count other...second >actual &&
test_cmp expect actual
'
- test_expect_success "counting commits with limiting ($state)" '
- git rev-list --count HEAD -- 1.t >expect &&
- git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
+ test_expect_success "counting commits with limiting ($state, $branch)" '
+ git rev-list --count $branch -- 1.t >expect &&
+ git rev-list --use-bitmap-index --count $branch -- 1.t >actual &&
test_cmp expect actual
'
- test_expect_success "counting objects via bitmap ($state)" '
- git rev-list --count --objects HEAD >expect &&
- git rev-list --use-bitmap-index --count --objects HEAD >actual &&
+ test_expect_success "counting objects via bitmap ($state, $branch)" '
+ git rev-list --count --objects $branch >expect &&
+ git rev-list --use-bitmap-index --count --objects $branch >actual &&
test_cmp expect actual
'
- test_expect_success "enumerate commits ($state)" '
- git rev-list --use-bitmap-index HEAD >actual &&
- git rev-list HEAD >expect &&
+ test_expect_success "enumerate commits ($state, $branch)" '
+ git rev-list --use-bitmap-index $branch >actual &&
+ git rev-list $branch >expect &&
test_bitmap_traversal --no-confirm-bitmaps expect actual
'
- test_expect_success "enumerate --objects ($state)" '
- git rev-list --objects --use-bitmap-index HEAD >actual &&
- git rev-list --objects HEAD >expect &&
+ test_expect_success "enumerate --objects ($state, $branch)" '
+ git rev-list --objects --use-bitmap-index $branch >actual &&
+ git rev-list --objects $branch >expect &&
test_bitmap_traversal expect actual
'
- test_expect_success "bitmap --objects handles non-commit objects ($state)" '
- git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
+ test_expect_success "bitmap --objects handles non-commit objects ($state, $branch)" '
+ git rev-list --objects --use-bitmap-index $branch tagged-blob >actual &&
grep $blob actual
'
}
+rev_list_tests () {
+ state=$1
+
+ for branch in "second" "other"
+ do
+ rev_list_tests_head
+ done
+}
+
rev_list_tests 'full bitmap'
test_expect_success 'clone from bitmapped repository' '
@@ -128,7 +216,7 @@ test_expect_success 'setup further non-bitmapped commits' '
rev_list_tests 'partial bitmap'
test_expect_success 'fetch (partial bitmap)' '
- git --git-dir=clone.git fetch origin master:master &&
+ git --git-dir=clone.git fetch origin second:second &&
git rev-parse HEAD >expect &&
git --git-dir=clone.git rev-parse HEAD >actual &&
test_cmp expect actual
@@ -230,7 +318,7 @@ test_expect_success 'full repack, reusing previous bitmaps' '
'
test_expect_success 'fetch (full bitmap)' '
- git --git-dir=clone.git fetch origin master:master &&
+ git --git-dir=clone.git fetch origin second:second &&
git rev-parse HEAD >expect &&
git --git-dir=clone.git rev-parse HEAD >actual &&
test_cmp expect actual
@@ -343,7 +431,20 @@ test_expect_success 'pack reuse respects --incremental' '
test_must_be_empty actual
'
-test_expect_success 'truncated bitmap fails gracefully' '
+test_expect_success 'truncated bitmap fails gracefully (ewah)' '
+ test_config pack.writebitmaphashcache false &&
+ git repack -ad &&
+ git rev-list --use-bitmap-index --count --all >expect &&
+ bitmap=$(ls .git/objects/pack/*.bitmap) &&
+ test_when_finished "rm -f $bitmap" &&
+ test_copy_bytes 256 <$bitmap >$bitmap.tmp &&
+ mv -f $bitmap.tmp $bitmap &&
+ git rev-list --use-bitmap-index --count --all >actual 2>stderr &&
+ test_cmp expect actual &&
+ test_i18ngrep corrupt.ewah.bitmap stderr
+'
+
+test_expect_success 'truncated bitmap fails gracefully (cache)' '
git repack -ad &&
git rev-list --use-bitmap-index --count --all >expect &&
bitmap=$(ls .git/objects/pack/*.bitmap) &&
@@ -352,7 +453,7 @@ test_expect_success 'truncated bitmap fails gracefully' '
mv -f $bitmap.tmp $bitmap &&
git rev-list --use-bitmap-index --count --all >actual 2>stderr &&
test_cmp expect actual &&
- test_i18ngrep corrupt stderr
+ test_i18ngrep corrupted.bitmap.index stderr
'
# have_delta <obj> <expected_base>
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/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/t6050-replace.sh b/t/t6050-replace.sh
index c80dc10b8f..0dbe086118 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -129,7 +129,7 @@ tagger T A Gger <> 0 +0000
EOF
test_expect_success 'tag replaced commit' '
- git mktag <tag.sig >.git/refs/tags/mytag 2>message
+ git mktag <tag.sig >.git/refs/tags/mytag
'
test_expect_success '"git fsck" works' '
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/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
index 6774e9d86f..52e8ccc933 100755
--- a/t/t7601-merge-pull-config.sh
+++ b/t/t7601-merge-pull-config.sh
@@ -29,11 +29,8 @@ test_expect_success 'setup' '
test_expect_success 'pull.rebase not set' '
git reset --hard c0 &&
- git -c color.advice=always pull . c1 2>err &&
- test_decode_color <err >decoded &&
- test_i18ngrep "<YELLOW>hint: " decoded &&
- test_i18ngrep "Pulling without specifying how to reconcile" decoded
-
+ git pull . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
'
test_expect_success 'pull.rebase not set and pull.ff=true' '
@@ -87,6 +84,65 @@ test_expect_success 'pull.rebase not set and --ff-only given' '
test_i18ngrep ! "Pulling without specifying how to reconcile" err
'
+test_expect_success 'pull.rebase not set (not-fast-forward)' '
+ git reset --hard c2 &&
+ git -c color.advice=always pull . c1 2>err &&
+ test_decode_color <err >decoded &&
+ test_i18ngrep "<YELLOW>hint: " decoded &&
+ test_i18ngrep "Pulling without specifying how to reconcile" decoded
+'
+
+test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' '
+ git reset --hard c2 &&
+ test_config pull.ff true &&
+ git pull . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and pull.ff=false (not-fast-forward)' '
+ git reset --hard c2 &&
+ test_config pull.ff false &&
+ git pull . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' '
+ git reset --hard c2 &&
+ test_config pull.ff only &&
+ test_must_fail git pull . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' '
+ git reset --hard c2 &&
+ git pull --rebase . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --no-rebase given (not-fast-forward)' '
+ git reset --hard c2 &&
+ git pull --no-rebase . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' '
+ git reset --hard c2 &&
+ git pull --ff . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --no-ff given (not-fast-forward)' '
+ git reset --hard c2 &&
+ git pull --no-ff . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
+test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' '
+ git reset --hard c2 &&
+ test_must_fail git pull --ff-only . c1 2>err &&
+ test_i18ngrep ! "Pulling without specifying how to reconcile" err
+'
+
test_expect_success 'merge c1 with c2' '
git reset --hard c1 &&
test -f c0.c &&
diff --git a/t/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/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 99bf0c7582..1074009cc0 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -7,6 +7,19 @@ test_description='git maintenance builtin'
GIT_TEST_COMMIT_GRAPH=0
GIT_TEST_MULTI_PACK_INDEX=0
+test_lazy_prereq XMLLINT '
+ xmllint --version
+'
+
+test_xmllint () {
+ if test_have_prereq XMLLINT
+ then
+ xmllint --noout "$@"
+ else
+ true
+ fi
+}
+
test_expect_success 'help text' '
test_expect_code 129 git maintenance -h 2>err &&
test_i18ngrep "usage: git maintenance <subcommand>" err &&
@@ -419,7 +432,7 @@ test_expect_success !MINGW 'register and unregister with regex metacharacters' '
'
test_expect_success 'start from empty cron table' '
- GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance start &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start &&
# start registers the repo
git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
@@ -430,19 +443,19 @@ test_expect_success 'start from empty cron table' '
'
test_expect_success 'stop from existing schedule' '
- GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop &&
# stop does not unregister the repo
git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
# Operation is idempotent
- GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop &&
test_must_be_empty cron.txt
'
test_expect_success 'start preserves existing schedule' '
echo "Important information!" >cron.txt &&
- GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance start &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start &&
grep "Important information!" cron.txt
'
@@ -457,11 +470,94 @@ test_expect_success 'magic markers are correct' '
test_expect_success 'stop preserves surrounding schedule' '
echo "Crucial information!" >>cron.txt &&
- GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop &&
grep "Important information!" cron.txt &&
grep "Crucial information!" cron.txt
'
+test_expect_success 'start and stop macOS maintenance' '
+ # ensure $HOME can be compared against hook arguments on all platforms
+ pfx=$(cd "$HOME" && pwd) &&
+
+ write_script print-args <<-\EOF &&
+ echo $* | sed "s:gui/[0-9][0-9]*:gui/[UID]:" >>args
+ EOF
+
+ rm -f args &&
+ GIT_TEST_MAINT_SCHEDULER=launchctl:./print-args git maintenance start &&
+
+ # start registers the repo
+ git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
+
+ ls "$HOME/Library/LaunchAgents" >actual &&
+ cat >expect <<-\EOF &&
+ org.git-scm.git.daily.plist
+ org.git-scm.git.hourly.plist
+ org.git-scm.git.weekly.plist
+ EOF
+ test_cmp expect actual &&
+
+ rm -f expect &&
+ for frequency in hourly daily weekly
+ do
+ PLIST="$pfx/Library/LaunchAgents/org.git-scm.git.$frequency.plist" &&
+ test_xmllint "$PLIST" &&
+ grep schedule=$frequency "$PLIST" &&
+ echo "bootout gui/[UID] $PLIST" >>expect &&
+ echo "bootstrap gui/[UID] $PLIST" >>expect || return 1
+ done &&
+ test_cmp expect args &&
+
+ rm -f args &&
+ GIT_TEST_MAINT_SCHEDULER=launchctl:./print-args git maintenance stop &&
+
+ # stop does not unregister the repo
+ git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
+
+ printf "bootout gui/[UID] $pfx/Library/LaunchAgents/org.git-scm.git.%s.plist\n" \
+ hourly daily weekly >expect &&
+ test_cmp expect args &&
+ ls "$HOME/Library/LaunchAgents" >actual &&
+ test_line_count = 0 actual
+'
+
+test_expect_success 'start and stop Windows maintenance' '
+ write_script print-args <<-\EOF &&
+ echo $* >>args
+ while test $# -gt 0
+ do
+ case "$1" in
+ /xml) shift; xmlfile=$1; break ;;
+ *) shift ;;
+ esac
+ done
+ test -z "$xmlfile" || cp "$xmlfile" "$xmlfile.xml"
+ EOF
+
+ rm -f args &&
+ GIT_TEST_MAINT_SCHEDULER="schtasks:./print-args" git maintenance start &&
+
+ # start registers the repo
+ git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
+
+ for frequency in hourly daily weekly
+ do
+ grep "/create /tn Git Maintenance ($frequency) /f /xml" args &&
+ file=$(ls .git/schedule_${frequency}*.xml) &&
+ test_xmllint "$file" || return 1
+ done &&
+
+ rm -f args &&
+ GIT_TEST_MAINT_SCHEDULER="schtasks:./print-args" git maintenance stop &&
+
+ # stop does not unregister the repo
+ git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
+
+ printf "/delete /tn Git Maintenance (%s) /f\n" \
+ hourly daily weekly >expect &&
+ test_cmp expect args
+'
+
test_expect_success 'register preserves existing strategy' '
git config maintenance.strategy none &&
git maintenance register &&
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index a1c4f1f6d4..c4a7758409 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2380,4 +2380,24 @@ test_expect_success 'sourcing the completion script clears cached --options' '
verbose test -z "$__gitcomp_builtin_notes_edit"
'
+test_expect_success '__git_complete' '
+ unset -f __git_wrap__git_main &&
+
+ __git_complete foo __git_main &&
+ __git_have_func __git_wrap__git_main &&
+ unset -f __git_wrap__git_main &&
+
+ __git_complete gf _git_fetch &&
+ __git_have_func __git_wrap_git_fetch &&
+
+ __git_complete foo git &&
+ __git_have_func __git_wrap__git_main &&
+ unset -f __git_wrap__git_main &&
+
+ __git_complete gd git_diff &&
+ __git_have_func __git_wrap_git_diff &&
+
+ test_must_fail __git_complete ga missing
+'
+
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.
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 9fa7c1d0f6..03c1c0836f 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1713,7 +1713,8 @@ test_lazy_prereq REBASE_P '
'
# Ensure that no test accidentally triggers a Git command
-# that runs 'crontab', affecting a user's cron schedule.
-# Tests that verify the cron integration must set this locally
+# that runs the actual maintenance scheduler, affecting a user's
+# system permanently.
+# Tests that verify the scheduler integration must set this locally
# to avoid errors.
-GIT_TEST_CRONTAB="exit 1"
+GIT_TEST_MAINT_SCHEDULER="none:exit 1"