diff options
Diffstat (limited to 't')
64 files changed, 3033 insertions, 1248 deletions
@@ -418,7 +418,8 @@ Don't: dies in an unexpected way (e.g. segfault). On the other hand, don't use test_must_fail for running regular - platform commands; just use '! cmd'. + platform commands; just use '! cmd'. We are not in the business + of verifying that the world given to us sanely works. - use perl without spelling it as "$PERL_PATH". This is to help our friends on Windows where the platform Perl often adds CR before diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh index cd2baef383..db2ef22e8f 100755 --- a/t/lib-gpg.sh +++ b/t/lib-gpg.sh @@ -12,20 +12,43 @@ else say "Your version of gpg (1.0.6) is too buggy for testing" ;; *) - # key generation info: gpg --homedir t/lib-gpg --gen-key - # Type DSA and Elgamal, size 2048 bits, no expiration date. - # Name and email: C O Mitter <committer@example.com> + # Available key info: + # * Type DSA and Elgamal, size 2048 bits, no expiration date, + # name and email: C O Mitter <committer@example.com> + # * Type RSA, size 2048 bits, no expiration date, + # name and email: Eris Discordia <discord@example.net> # No password given, to enable non-interactive operation. - cp -R "$TEST_DIRECTORY"/lib-gpg ./gpghome - chmod 0700 gpghome - chmod 0600 gpghome/* - GNUPGHOME="$(pwd)/gpghome" - export GNUPGHOME + # To generate new key: + # gpg --homedir /tmp/gpghome --gen-key + # To write armored exported key to keyring: + # gpg --homedir /tmp/gpghome --export-secret-keys \ + # --armor 0xDEADBEEF >> lib-gpg/keyring.gpg + # gpg --homedir /tmp/gpghome --export \ + # --armor 0xDEADBEEF >> lib-gpg/keyring.gpg + # To export ownertrust: + # gpg --homedir /tmp/gpghome --export-ownertrust \ + # > lib-gpg/ownertrust + mkdir ./gpghome && + chmod 0700 ./gpghome && + GNUPGHOME="$(pwd)/gpghome" && + export GNUPGHOME && + gpg --homedir "${GNUPGHOME}" 2>/dev/null --import \ + "$TEST_DIRECTORY"/lib-gpg/keyring.gpg && + gpg --homedir "${GNUPGHOME}" 2>/dev/null --import-ownertrust \ + "$TEST_DIRECTORY"/lib-gpg/ownertrust && + gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null 2>&1 \ + --sign -u committer@example.com && test_set_prereq GPG ;; esac fi +if test_have_prereq GPG && + echo | gpg --homedir "${GNUPGHOME}" -b --rfc1991 >/dev/null 2>&1 +then + test_set_prereq RFC1991 +fi + sanitize_pgp() { perl -ne ' /^-----END PGP/ and $in_pgp = 0; diff --git a/t/lib-gpg/keyring.gpg b/t/lib-gpg/keyring.gpg new file mode 100644 index 0000000000..d4754a1f19 --- /dev/null +++ b/t/lib-gpg/keyring.gpg @@ -0,0 +1,142 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: GnuPG v1 + +lQG7BEZnyykRBACzCPjIpTYNL7Y2tQqlEGTTDlvZcWNLjF5f7ZzuyOqNOidLUgFD +36qch1LZLSZkShdR3Gae+bsolyjxrlFuFP0eXRPMtqK20aLw7WZvPFpEV1ThMne+ +PRJjYrvghWw3L0VVIAIZ8GXwrVBuU99uEjHEI0ojYloOvFc2jVPgSaoBvwCg48Tj +fol2foSoJa7XUu9yAL8szg8D/RUsTzNF+I9hSRHl7MYKFMYoKEY9BDgrgAujp7YY +8qdGsiUb0Ggyzp2kRjZFt4lpcvKhGfHn5GEjmtk+fRbD5qPfMqKFW+T0NPfYlYmL +JJ4fs4qZ8Lx7x6iG6X51u+YNwsQuIGjMCC3CeNi3F7or651kkNYASbaQ1NROkCIN +NudyA/0aasvoZUoNJAc2cP5Ifs6WhXMWLfMR2p2XbfKwKNYneec60usnSComcKqh +sJVk0Gytvr3FOYVhRkXnKAbx+0W2urFP8OFVBTEKO6Ts2VygWGgneQYoHnqzwlUE +yjOjlr+lyf7u2s/KAxpKA6jnttEdRZAmzWkhuox1wwAUkr27/QAAn3TEzKR1pxxR ++R3dHuFpnnfatMIDC5O0IkMgTyBNaXR0ZXIgPGNvbW1pdHRlckBleGFtcGxlLmNv +bT6IXgQTEQIAHgUCRmfLKQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAAKCRATtvUe +zd5DDXQdAKC92f+wOrTkbmPEf+u+qA/Gv6BxQwCfQ128JXCi3MpMB8tI2Kmo15tY +gnmdAj0ERmfLThAIAM65eT9T6+gg0fJn+Qxhs3FFDPjxK6AOBS3SieWWmXO6stZZ +plvb7r2+sXYp8HMHntnOX3TRPolIx1dsdkv3W3w8yUzf9Lmo2XMPsZ3/isWdEbOI +A0rO3B1xwbQO7vEoWHeB7uyYIF6YsIH0pMqxkImciwB1tnJPB9OxqPHlD/HyyHr2 +voj6nmEGaPQWj8/dkfyenXm6XmNZUZL/slk6tRhNwv4cW3QQLh39nbiz9rqvZMKF +XX8wkY4FdQkJjCGwqzG+7yJcyHvem29/iq//jRLZgdiN8BwV3MCTJyDp8/Wb/d9y +jZcUm1RdtwRiwfhfQ+zmpyspm7OxINfH65rf7f8ABA0IALRiMRs/eOD59jrYXmPS +ZQUbiALlbJJtuP2c9N3WZ5OgrhDiAW+SDIN+hgDynJ9b7C2dE3xNaud4zaXAAF44 +J4J0bAo2ZtZoJajw+GXwaZfh4Z7nPNHwEcbFD4/uXPCj9jPkcLOJqGmUY1aXdygo +t3Hn5U/zo8JxPQ83YbJQhkzAOZ/HGowLNqKgGkLLHn1X9qay0CxlfTQeEN5RZyl3 +b4qRzGgGALFvoheyZIUw1TbjRpbn3kqlJooEQY02VwXFXfLI/LwzglilH6sSckvs +0WHKLZ+0L6b3CgJHN2RsZ7QxwCBi1aemsvr65FeEXp/AYxaG5duUbsugG8PgoJ06 +bsEAAVQNQO3cXWpuiJ/nNLLnWuPunBKJUlurkBdf2GD+m+muF0VpwDchhqqbTO4e +FqOISQQYEQIACQUCRmfLTgIbDAAKCRATtvUezd5DDcHsAKDQcoAtDWJFupVRqleB +Cezx4Q2khACcCs+/LtE8Lb9hC+2cvr3uH5p82AI= +=aEiU +-----END PGP PRIVATE KEY BLOCK----- +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: GnuPG v1 + +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 +=hieJ +-----END PGP PRIVATE KEY BLOCK----- +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1 + +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 +=iYv/ +-----END PGP PUBLIC KEY BLOCK----- diff --git a/t/lib-gpg/ownertrust b/t/lib-gpg/ownertrust new file mode 100644 index 0000000000..b3e3c4f1cd --- /dev/null +++ b/t/lib-gpg/ownertrust @@ -0,0 +1,4 @@ +# List of assigned trustvalues, created Thu 11 Dec 2014 01:26:28 PM CET +# (Use "gpg --import-ownertrust" to restore them) +73D758744BE721698EC54E8713B6F51ECDDE430D:6: +D4BE22311AD3131E5EDA29A461092E85B7227189:3: diff --git a/t/lib-gpg/pubring.gpg b/t/lib-gpg/pubring.gpg Binary files differdeleted file mode 100644 index 1a3c2d487c..0000000000 --- a/t/lib-gpg/pubring.gpg +++ /dev/null diff --git a/t/lib-gpg/random_seed b/t/lib-gpg/random_seed Binary files differdeleted file mode 100644 index 95d249f15f..0000000000 --- a/t/lib-gpg/random_seed +++ /dev/null diff --git a/t/lib-gpg/secring.gpg b/t/lib-gpg/secring.gpg Binary files differdeleted file mode 100644 index 82dca8f80b..0000000000 --- a/t/lib-gpg/secring.gpg +++ /dev/null diff --git a/t/lib-gpg/trustdb.gpg b/t/lib-gpg/trustdb.gpg Binary files differdeleted file mode 100644 index 4879ae9a84..0000000000 --- a/t/lib-gpg/trustdb.gpg +++ /dev/null diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 7713dd2609..03a4c2ee84 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -69,6 +69,7 @@ LockFile accept.lock PassEnv GIT_VALGRIND PassEnv GIT_VALGRIND_OPTIONS PassEnv GNUPGHOME +PassEnv ASAN_OPTIONS Alias /dumb/ www/ Alias /auth/dumb/ www/auth/dumb/ diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh index 51845491bb..cd220e378e 100644 --- a/t/lib-terminal.sh +++ b/t/lib-terminal.sh @@ -1,7 +1,7 @@ # Helpers for terminal output tests. # Catch tests which should depend on TTY but forgot to. There's no need -# to aditionally check that the TTY prereq is set here. If the test declared +# to additionally check that the TTY prereq is set here. If the test declared # it and we are running the test, then it must have been set. test_terminal () { if ! test_declared_prereq TTY diff --git a/t/t0006-date.sh b/t/t0006-date.sh index e53cf6d36d..fac0986134 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -82,4 +82,7 @@ check_approxidate 'Jun 6, 5AM' '2009-06-06 05:00:00' check_approxidate '5AM Jun 6' '2009-06-06 05:00:00' check_approxidate '6AM, June 7, 2009' '2009-06-07 06:00:00' +check_approxidate '2008-12-01' '2008-12-01 19:20:00' +check_approxidate '2009-12-01' '2009-12-01 19:20:00' + test_done diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index 2a4a6c1226..452320df83 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -55,16 +55,41 @@ create_gitattributes () { esac } +check_warning () { + case "$1" in + LF_CRLF) grep "LF will be replaced by CRLF" $2;; + CRLF_LF) grep "CRLF will be replaced by LF" $2;; + '') + >expect + grep "will be replaced by" $2 >actual + test_cmp expect actual + ;; + *) false ;; + esac +} + create_file_in_repo () { crlf=$1 attr=$2 + lfname=$3 + crlfname=$4 + lfmixcrlf=$5 + lfmixcr=$6 + crlfnul=$7 create_gitattributes "$attr" && + pfx=crlf_${crlf}_attr_${attr} for f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul do - pfx=crlf_${crlf}_attr_${attr}_$f.txt && - cp $f $pfx && git -c core.autocrlf=$crlf add $pfx + fname=${pfx}_$f.txt && + cp $f $fname && + git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" done && - git commit -m "core.autocrlf $crlf" + git commit -m "core.autocrlf $crlf" && + check_warning "$lfname" ${pfx}_LF.err && + check_warning "$crlfname" ${pfx}_CRLF.err && + check_warning "$lfmixcrlf" ${pfx}_CRLF_mix_LF.err && + check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err && + check_warning "$crlfnul" ${pfx}_CRLF_nul.err } check_files_in_repo () { @@ -140,22 +165,47 @@ test_expect_success 'setup master' ' ' -test_expect_success 'create files' ' - create_file_in_repo false "" && - create_file_in_repo true "" && - create_file_in_repo input "" && - create_file_in_repo false "auto" && - create_file_in_repo true "auto" && - create_file_in_repo input "auto" && +warn_LF_CRLF="LF will be replaced by CRLF" +warn_CRLF_LF="CRLF will be replaced by LF" + +test_expect_success 'add files empty attr' ' + create_file_in_repo false "" "" "" "" "" "" && + create_file_in_repo true "" "LF_CRLF" "" "LF_CRLF" "" "" && + create_file_in_repo input "" "" "CRLF_LF" "CRLF_LF" "" "" +' + +test_expect_success 'add files attr=auto' ' + create_file_in_repo false "auto" "" "CRLF_LF" "CRLF_LF" "" "" && + create_file_in_repo true "auto" "LF_CRLF" "" "LF_CRLF" "" "" && + create_file_in_repo input "auto" "" "CRLF_LF" "CRLF_LF" "" "" +' + +test_expect_success 'add files attr=text' ' + create_file_in_repo false "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && + create_file_in_repo true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && + create_file_in_repo input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" +' + +test_expect_success 'add files attr=-text' ' + create_file_in_repo false "-text" "" "" "" "" "" && + create_file_in_repo true "-text" "" "" "" "" "" && + create_file_in_repo input "-text" "" "" "" "" "" +' + +test_expect_success 'add files attr=lf' ' + create_file_in_repo false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && + create_file_in_repo true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && + create_file_in_repo input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" +' - create_file_in_repo false "text" && - create_file_in_repo true "text" && - create_file_in_repo input "text" && +test_expect_success 'add files attr=crlf' ' + create_file_in_repo false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && + create_file_in_repo true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && + create_file_in_repo input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" +' - create_file_in_repo false "-text" && - create_file_in_repo true "-text" && - create_file_in_repo input "-text" && +test_expect_success 'create files cleanup' ' rm -f *.txt && git reset --hard ' diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index 0333dd9875..29e91d861c 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -432,4 +432,10 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual ' +test_expect_success 'avoid SP-HT sequence in commented line' ' + printf "#\tone\n#\n# two\n" >expect && + printf "\tone\n\ntwo\n" | git stripspace -c >actual && + test_cmp expect actual +' + test_done diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 6b3cedcf24..988c3925d5 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -64,7 +64,7 @@ test_expect_success "setup case tests" ' git checkout -f master ' -$test_case 'rename (case change)' ' +test_expect_success 'rename (case change)' ' git mv camelcase CamelCase && git commit -m "rename" ' diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 067f4c6e52..601d02d71f 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -22,7 +22,7 @@ generate_expected_cache_tree_rec () { # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux # We want to count only foo because it's the only direct child subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) && - subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 {++c} END {print c}') && + subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') && entries=$(git ls-files|wc -l) && printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" && for subtree in $subtrees diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index 57ea5a10c5..d7ef44b4a2 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -289,4 +289,13 @@ test_expect_success 'http paths can be part of context' ' EOF ' +test_expect_success 'helpers can abort the process' ' + test_must_fail git \ + -c credential.helper="!f() { echo quit=1; }; f" \ + -c credential.helper="verbatim foo bar" \ + credential fill >stdout && + >expect && + test_cmp expect stdout +' + test_done diff --git a/t/t1050-large.sh b/t/t1050-large.sh index f5a9119290..f9f3d1391f 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -9,10 +9,10 @@ test_expect_success setup ' # clone does not allow us to pass core.bigfilethreshold to # new repos, so set core.bigfilethreshold globally git config --global core.bigfilethreshold 200k && - echo X | dd of=large1 bs=1k seek=2000 && - echo X | dd of=large2 bs=1k seek=2000 && - echo X | dd of=large3 bs=1k seek=2000 && - echo Y | dd of=huge bs=1k seek=2500 && + printf "%2000000s" X >large1 && + cp large1 large2 && + cp large1 large3 && + printf "%2500000s" Y >huge && GIT_ALLOC_LIMIT=1500k && export GIT_ALLOC_LIMIT ' @@ -61,7 +61,7 @@ test_expect_success 'checkout a large file' ' large1=$(git rev-parse :large1) && git update-index --add --cacheinfo 100644 $large1 another && git checkout another && - cmp large1 another ;# this must not be test_cmp + test_cmp large1 another ' test_expect_success 'packsize limit' ' @@ -162,7 +162,7 @@ test_expect_success 'pack-objects with large loose object' ' test_create_repo packed && mv pack-* packed/.git/objects/pack && GIT_DIR=packed/.git git cat-file blob $SHA1 >actual && - cmp huge actual + test_cmp huge actual ' test_expect_success 'tar achiving' ' diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index de42d21c92..7eecfb836a 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -111,7 +111,18 @@ do done +test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' ' + rm -f .git/info/refs && + test_unconfig core.sharedrepository && + umask 002 && + git update-server-info && + echo "-rw-rw-r--" >expect && + modebits .git/info/refs >actual && + test_cmp expect actual +' + test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' + umask 077 && git config core.sharedRepository group && git reflog expire --all && actual="$(ls -l .git/logs/refs/heads/master)" && diff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh index fdc257e66f..3c6791e6be 100755 --- a/t/t1307-config-blob.sh +++ b/t/t1307-config-blob.sh @@ -67,4 +67,13 @@ test_expect_success 'parse errors in blobs are properly attributed' ' grep "HEAD:config" err ' +test_expect_success 'can parse blob ending with CR' ' + printf "[some]key = value\\r" >config && + git add config && + git commit -m CR && + echo value >expect && + git config --blob=HEAD:config some.key >actual && + test_cmp expect actual +' + test_done diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 7b4707b776..6805b9e6bb 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -619,6 +619,52 @@ test_expect_success 'stdin update/create/verify combination works' ' test_must_fail git rev-parse --verify -q $c ' +test_expect_success 'stdin verify succeeds for correct value' ' + git rev-parse $m >expect && + echo "verify $m $m" >stdin && + git update-ref --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + +test_expect_success 'stdin verify succeeds for missing reference' ' + echo "verify refs/heads/missing $Z" >stdin && + git update-ref --stdin <stdin && + test_must_fail git rev-parse --verify -q refs/heads/missing +' + +test_expect_success 'stdin verify treats no value as missing' ' + echo "verify refs/heads/missing" >stdin && + git update-ref --stdin <stdin && + test_must_fail git rev-parse --verify -q refs/heads/missing +' + +test_expect_success 'stdin verify fails for wrong value' ' + git rev-parse $m >expect && + echo "verify $m $m~1" >stdin && + test_must_fail git update-ref --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + +test_expect_success 'stdin verify fails for mistaken null value' ' + git rev-parse $m >expect && + echo "verify $m $Z" >stdin && + test_must_fail git update-ref --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + +test_expect_success 'stdin verify fails for mistaken empty value' ' + M=$(git rev-parse $m) && + test_when_finished "git update-ref $m $M" && + git rev-parse $m >expect && + echo "verify $m" >stdin && + test_must_fail git update-ref --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + test_expect_success 'stdin update refs works with identity updates' ' cat >stdin <<-EOF && update $a $m $m @@ -938,6 +984,52 @@ test_expect_success 'stdin -z update/create/verify combination works' ' test_must_fail git rev-parse --verify -q $c ' +test_expect_success 'stdin -z verify succeeds for correct value' ' + git rev-parse $m >expect && + printf $F "verify $m" "$m" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z verify succeeds for missing reference' ' + printf $F "verify refs/heads/missing" "$Z" >stdin && + git update-ref -z --stdin <stdin && + test_must_fail git rev-parse --verify -q refs/heads/missing +' + +test_expect_success 'stdin -z verify treats no value as missing' ' + printf $F "verify refs/heads/missing" "" >stdin && + git update-ref -z --stdin <stdin && + test_must_fail git rev-parse --verify -q refs/heads/missing +' + +test_expect_success 'stdin -z verify fails for wrong value' ' + git rev-parse $m >expect && + printf $F "verify $m" "$m~1" >stdin && + test_must_fail git update-ref -z --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z verify fails for mistaken null value' ' + git rev-parse $m >expect && + printf $F "verify $m" "$Z" >stdin && + test_must_fail git update-ref -z --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z verify fails for mistaken empty value' ' + M=$(git rev-parse $m) && + test_when_finished "git update-ref $m $M" && + git rev-parse $m >expect && + printf $F "verify $m" "" >stdin && + test_must_fail git update-ref -z --stdin <stdin && + git rev-parse $m >actual && + test_cmp expect actual +' + test_expect_success 'stdin -z update refs works with identity updates' ' printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin && git update-ref -z --stdin <stdin && diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 8cf446165e..779d4e3829 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -287,4 +287,34 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' ' test_cmp expect actual ' +# Triggering the bug detected by this test requires a newline to fall +# exactly BUFSIZ-1 bytes from the end of the file. We don't know +# what that value is, since it's platform dependent. However, if +# we choose some value N, we also catch any D which divides N evenly +# (since we will read backwards in chunks of D). So we choose 8K, +# which catches glibc (with an 8K BUFSIZ) and *BSD (1K). +# +# Each line is 114 characters, so we need 75 to still have a few before the +# last 8K. The 89-character padding on the final entry lines up our +# newline exactly. +test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' ' + git checkout -b reflogskip && + z38=00000000000000000000000000000000000000 && + ident="abc <xyz> 0000000001 +0000" && + for i in $(test_seq 1 75); do + printf "$z38%02d $z38%02d %s\t" $i $(($i+1)) "$ident" && + if test $i = 75; then + for j in $(test_seq 1 89); do + printf X + done + else + printf X + fi && + printf "\n" + done >.git/logs/refs/heads/reflogskip && + git rev-parse reflogskip@{73} >actual && + echo ${z38}03 >expect && + test_cmp expect actual +' + test_done diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index d00b70f99d..cfb32b6242 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -229,8 +229,12 @@ test_expect_success 'tag with incorrect tag name & missing tagger' ' echo $tag >.git/refs/tags/wrong && test_when_finished "git update-ref -d refs/tags/wrong" && git fsck --tags 2>out && - grep "invalid .tag. name" out && - grep "expected .tagger. line" out + + cat >expect <<-EOF && + warning in tag $tag: invalid '\''tag'\'' name: wrong name format + warning in tag $tag: invalid format - expected '\''tagger'\'' line + EOF + test_cmp expect out ' test_expect_success 'tag with bad tagger' ' @@ -345,6 +349,21 @@ dot-backslash-case .\\\\.GIT\\\\foobar dotgit-case-backslash .git\\\\foobar EOF +test_expect_success 'fsck allows .Ňit' ' + ( + git init not-dotgit && + cd not-dotgit && + echo content >file && + git add file && + git commit -m base && + blob=$(git rev-parse :file) && + printf "100644 blob $blob\t.\\305\\207it" >tree && + tree=$(git mktree <tree) && + git fsck 2>err && + test_line_count = 0 err + ) +' + # create a static test repo which is broken by omitting # one particular object ($1, which is looked up via rev-parse # in the new repository). diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh index f171a5578b..a12afe93f3 100755 --- a/t/t2004-checkout-cache-temp.sh +++ b/t/t2004-checkout-cache-temp.sh @@ -10,202 +10,212 @@ rather than the tracked path.' . ./test-lib.sh -test_expect_success \ -'preparation' ' -mkdir asubdir && -echo tree1path0 >path0 && -echo tree1path1 >path1 && -echo tree1path3 >path3 && -echo tree1path4 >path4 && -echo tree1asubdir/path5 >asubdir/path5 && -git update-index --add path0 path1 path3 path4 asubdir/path5 && -t1=$(git write-tree) && -rm -f path* .merge_* out .git/index && -echo tree2path0 >path0 && -echo tree2path1 >path1 && -echo tree2path2 >path2 && -echo tree2path4 >path4 && -git update-index --add path0 path1 path2 path4 && -t2=$(git write-tree) && -rm -f path* .merge_* out .git/index && -echo tree2path0 >path0 && -echo tree3path1 >path1 && -echo tree3path2 >path2 && -echo tree3path3 >path3 && -git update-index --add path0 path1 path2 path3 && -t3=$(git write-tree)' - -test_expect_success \ -'checkout one stage 0 to temporary file' ' -rm -f path* .merge_* out .git/index && -git read-tree $t1 && -git checkout-index --temp -- path1 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path1 && -p=$(cut "-d " -f1 out) && -test -f $p && -test $(cat $p) = tree1path1' - -test_expect_success \ -'checkout all stage 0 to temporary files' ' -rm -f path* .merge_* out .git/index && -git read-tree $t1 && -git checkout-index -a --temp >out && -test_line_count = 5 out && -for f in path0 path1 path3 path4 asubdir/path5 -do - test $(grep $f out | cut "-d " -f2) = $f && - p=$(grep $f out | cut "-d " -f1) && +test_expect_success 'setup' ' + mkdir asubdir && + echo tree1path0 >path0 && + echo tree1path1 >path1 && + echo tree1path3 >path3 && + echo tree1path4 >path4 && + echo tree1asubdir/path5 >asubdir/path5 && + git update-index --add path0 path1 path3 path4 asubdir/path5 && + t1=$(git write-tree) && + rm -f path* .merge_* actual .git/index && + echo tree2path0 >path0 && + echo tree2path1 >path1 && + echo tree2path2 >path2 && + echo tree2path4 >path4 && + git update-index --add path0 path1 path2 path4 && + t2=$(git write-tree) && + rm -f path* .merge_* actual .git/index && + echo tree2path0 >path0 && + echo tree3path1 >path1 && + echo tree3path2 >path2 && + echo tree3path3 >path3 && + git update-index --add path0 path1 path2 path3 && + t3=$(git write-tree) +' + +test_expect_success 'checkout one stage 0 to temporary file' ' + rm -f path* .merge_* actual .git/index && + git read-tree $t1 && + git checkout-index --temp -- path1 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path1 && + p=$(cut "-d " -f1 actual) && test -f $p && - test $(cat $p) = tree1$f -done' - -test_expect_success \ -'prepare 3-way merge' ' -rm -f path* .merge_* out .git/index && -git read-tree -m $t1 $t2 $t3' - -test_expect_success \ -'checkout one stage 2 to temporary file' ' -rm -f path* .merge_* out && -git checkout-index --stage=2 --temp -- path1 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path1 && -p=$(cut "-d " -f1 out) && -test -f $p && -test $(cat $p) = tree2path1' - -test_expect_success \ -'checkout all stage 2 to temporary files' ' -rm -f path* .merge_* out && -git checkout-index --all --stage=2 --temp >out && -test_line_count = 3 out && -for f in path1 path2 path4 -do - test $(grep $f out | cut "-d " -f2) = $f && - p=$(grep $f out | cut "-d " -f1) && + test $(cat $p) = tree1path1 +' + +test_expect_success 'checkout all stage 0 to temporary files' ' + rm -f path* .merge_* actual .git/index && + git read-tree $t1 && + git checkout-index -a --temp >actual && + test_line_count = 5 actual && + for f in path0 path1 path3 path4 asubdir/path5 + do + test $(grep $f actual | cut "-d " -f2) = $f && + p=$(grep $f actual | cut "-d " -f1) && + test -f $p && + test $(cat $p) = tree1$f + done +' + +test_expect_success 'setup 3-way merge' ' + rm -f path* .merge_* actual .git/index && + git read-tree -m $t1 $t2 $t3 +' + +test_expect_success 'checkout one stage 2 to temporary file' ' + rm -f path* .merge_* actual && + git checkout-index --stage=2 --temp -- path1 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path1 && + p=$(cut "-d " -f1 actual) && test -f $p && - test $(cat $p) = tree2$f -done' - -test_expect_success \ -'checkout all stages/one file to nothing' ' -rm -f path* .merge_* out && -git checkout-index --stage=all --temp -- path0 >out && -test_line_count = 0 out' - -test_expect_success \ -'checkout all stages/one file to temporary files' ' -rm -f path* .merge_* out && -git checkout-index --stage=all --temp -- path1 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path1 && -cut "-d " -f1 out | (read s1 s2 s3 && -test -f $s1 && -test -f $s2 && -test -f $s3 && -test $(cat $s1) = tree1path1 && -test $(cat $s2) = tree2path1 && -test $(cat $s3) = tree3path1)' - -test_expect_success \ -'checkout some stages/one file to temporary files' ' -rm -f path* .merge_* out && -git checkout-index --stage=all --temp -- path2 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path2 && -cut "-d " -f1 out | (read s1 s2 s3 && -test $s1 = . && -test -f $s2 && -test -f $s3 && -test $(cat $s2) = tree2path2 && -test $(cat $s3) = tree3path2)' - -test_expect_success \ -'checkout all stages/all files to temporary files' ' -rm -f path* .merge_* out && -git checkout-index -a --stage=all --temp >out && -test_line_count = 5 out' - -test_expect_success \ -'-- path0: no entry' ' -test x$(grep path0 out | cut "-d " -f2) = x' - -test_expect_success \ -'-- path1: all 3 stages' ' -test $(grep path1 out | cut "-d " -f2) = path1 && -grep path1 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test -f $s2 && -test -f $s3 && -test $(cat $s1) = tree1path1 && -test $(cat $s2) = tree2path1 && -test $(cat $s3) = tree3path1)' - -test_expect_success \ -'-- path2: no stage 1, have stage 2 and 3' ' -test $(grep path2 out | cut "-d " -f2) = path2 && -grep path2 out | cut "-d " -f1 | (read s1 s2 s3 && -test $s1 = . && -test -f $s2 && -test -f $s3 && -test $(cat $s2) = tree2path2 && -test $(cat $s3) = tree3path2)' - -test_expect_success \ -'-- path3: no stage 2, have stage 1 and 3' ' -test $(grep path3 out | cut "-d " -f2) = path3 && -grep path3 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test $s2 = . && -test -f $s3 && -test $(cat $s1) = tree1path3 && -test $(cat $s3) = tree3path3)' - -test_expect_success \ -'-- path4: no stage 3, have stage 1 and 3' ' -test $(grep path4 out | cut "-d " -f2) = path4 && -grep path4 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test -f $s2 && -test $s3 = . && -test $(cat $s1) = tree1path4 && -test $(cat $s2) = tree2path4)' - -test_expect_success \ -'-- asubdir/path5: no stage 2 and 3 have stage 1' ' -test $(grep asubdir/path5 out | cut "-d " -f2) = asubdir/path5 && -grep asubdir/path5 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test $s2 = . && -test $s3 = . && -test $(cat $s1) = tree1asubdir/path5)' - -test_expect_success \ -'checkout --temp within subdir' ' -(cd asubdir && - git checkout-index -a --stage=all >out && - test_line_count = 1 out && - test $(grep path5 out | cut "-d " -f2) = path5 && - grep path5 out | cut "-d " -f1 | (read s1 s2 s3 && - test -f ../$s1 && - test $s2 = . && - test $s3 = . && - test $(cat ../$s1) = tree1asubdir/path5) -)' - -test_expect_success \ -'checkout --temp symlink' ' -rm -f path* .merge_* out .git/index && -test_ln_s_add b a && -t4=$(git write-tree) && -rm -f .git/index && -git read-tree $t4 && -git checkout-index --temp -a >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = a && -p=$(cut "-d " -f1 out) && -test -f $p && -test $(cat $p) = b' + test $(cat $p) = tree2path1 +' + +test_expect_success 'checkout all stage 2 to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index --all --stage=2 --temp >actual && + test_line_count = 3 actual && + for f in path1 path2 path4 + do + test $(grep $f actual | cut "-d " -f2) = $f && + p=$(grep $f actual | cut "-d " -f1) && + test -f $p && + test $(cat $p) = tree2$f + done +' + +test_expect_success 'checkout all stages/one file to nothing' ' + rm -f path* .merge_* actual && + git checkout-index --stage=all --temp -- path0 >actual && + test_line_count = 0 actual +' + +test_expect_success 'checkout all stages/one file to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index --stage=all --temp -- path1 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path1 && + cut "-d " -f1 actual | (read s1 s2 s3 && + test -f $s1 && + test -f $s2 && + test -f $s3 && + test $(cat $s1) = tree1path1 && + test $(cat $s2) = tree2path1 && + test $(cat $s3) = tree3path1) +' + +test_expect_success 'checkout some stages/one file to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index --stage=all --temp -- path2 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path2 && + cut "-d " -f1 actual | (read s1 s2 s3 && + test $s1 = . && + test -f $s2 && + test -f $s3 && + test $(cat $s2) = tree2path2 && + test $(cat $s3) = tree3path2) +' + +test_expect_success 'checkout all stages/all files to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index -a --stage=all --temp >actual && + test_line_count = 5 actual +' + +test_expect_success '-- path0: no entry' ' + test x$(grep path0 actual | cut "-d " -f2) = x +' + +test_expect_success '-- path1: all 3 stages' ' + test $(grep path1 actual | cut "-d " -f2) = path1 && + grep path1 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test -f $s2 && + test -f $s3 && + test $(cat $s1) = tree1path1 && + test $(cat $s2) = tree2path1 && + test $(cat $s3) = tree3path1) +' + +test_expect_success '-- path2: no stage 1, have stage 2 and 3' ' + test $(grep path2 actual | cut "-d " -f2) = path2 && + grep path2 actual | cut "-d " -f1 | (read s1 s2 s3 && + test $s1 = . && + test -f $s2 && + test -f $s3 && + test $(cat $s2) = tree2path2 && + test $(cat $s3) = tree3path2) +' + +test_expect_success '-- path3: no stage 2, have stage 1 and 3' ' + test $(grep path3 actual | cut "-d " -f2) = path3 && + grep path3 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test $s2 = . && + test -f $s3 && + test $(cat $s1) = tree1path3 && + test $(cat $s3) = tree3path3) +' + +test_expect_success '-- path4: no stage 3, have stage 1 and 3' ' + test $(grep path4 actual | cut "-d " -f2) = path4 && + grep path4 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test -f $s2 && + test $s3 = . && + test $(cat $s1) = tree1path4 && + test $(cat $s2) = tree2path4) +' + +test_expect_success '-- asubdir/path5: no stage 2 and 3 have stage 1' ' + test $(grep asubdir/path5 actual | cut "-d " -f2) = asubdir/path5 && + grep asubdir/path5 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test $s2 = . && + test $s3 = . && + test $(cat $s1) = tree1asubdir/path5) +' + +test_expect_success 'checkout --temp within subdir' ' + ( + cd asubdir && + git checkout-index -a --stage=all >actual && + test_line_count = 1 actual && + test $(grep path5 actual | cut "-d " -f2) = path5 && + grep path5 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f ../$s1 && + test $s2 = . && + test $s3 = . && + test $(cat ../$s1) = tree1asubdir/path5) + ) +' + +test_expect_success 'checkout --temp symlink' ' + rm -f path* .merge_* actual .git/index && + test_ln_s_add path7 path6 && + git checkout-index --temp -a >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path6 && + p=$(cut "-d " -f1 actual) && + test -f $p && + test $(cat $p) = path7 +' + +test_expect_success 'emit well-formed relative path' ' + rm -f path* .merge_* actual .git/index && + >path0123456789 && + git update-index --add path0123456789 && + ( + cd asubdir && + git checkout-index --temp -- ../path0123456789 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = ../path0123456789 + ) +' test_done diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh index 6ecb559465..468a000e4b 100755 --- a/t/t2024-checkout-dwim.sh +++ b/t/t2024-checkout-dwim.sh @@ -185,4 +185,22 @@ test_expect_success 'checkout <branch> -- succeeds, even if a file with the same test_branch_upstream spam repo_c spam ' +test_expect_success 'loosely defined local base branch is reported correctly' ' + + git checkout master && + git branch strict && + git branch loose && + git commit --allow-empty -m "a bit more" && + + test_config branch.strict.remote . && + test_config branch.loose.remote . && + test_config branch.strict.merge refs/heads/master && + test_config branch.loose.merge master && + + git checkout strict | sed -e "s/strict/BRANCHNAME/g" >expect && + git checkout loose | sed -e "s/loose/BRANCHNAME/g" >actual && + + test_cmp expect actual +' + test_done diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh index 1bafb9098c..dfe02f4818 100755 --- a/t/t2107-update-index-basic.sh +++ b/t/t2107-update-index-basic.sh @@ -65,4 +65,19 @@ test_expect_success '--cacheinfo mode,sha1,path (new syntax)' ' test_cmp expect actual ' +test_expect_success '.lock files cleaned up' ' + mkdir cleanup && + ( + cd cleanup && + mkdir worktree && + git init repo && + cd repo && + git config core.worktree ../../worktree && + # --refresh triggers late setup_work_tree, + # active_cache_changed is zero, rollback_lock_file fails + git update-index --refresh && + ! test -f .git/index.lock + ) +' + test_done diff --git a/t/t3102-ls-tree-wildcards.sh b/t/t3102-ls-tree-wildcards.sh index c286854485..4d4b02e760 100755 --- a/t/t3102-ls-tree-wildcards.sh +++ b/t/t3102-ls-tree-wildcards.sh @@ -12,11 +12,25 @@ test_expect_success 'setup' ' ' test_expect_success 'ls-tree a[a] matches literally' ' - cat >expected <<EOF && -100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a[a]/three -EOF + cat >expect <<-\EOF && + 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a[a]/three + EOF git ls-tree -r HEAD "a[a]" >actual && - test_cmp expected actual + test_cmp expect actual +' + +test_expect_success 'ls-tree outside prefix' ' + cat >expect <<-\EOF && + 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ../a[a]/three + EOF + ( cd aa && git ls-tree -r HEAD "../a[a]"; ) >actual && + test_cmp expect actual +' + +test_expect_failure 'ls-tree does not yet support negated pathspec' ' + git ls-files ":(exclude)a" "a*" >expect && + git ls-tree --name-only -r HEAD ":(exclude)a" "a*" >actual && + test_cmp expect actual ' test_done diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 432921b6b8..ddea49808d 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -97,6 +97,20 @@ test_expect_success 'git branch -m o/o o should fail when o/p exists' ' test_must_fail git branch -m o/o o ' +test_expect_success 'git branch -m o/q o/p should fail when o/p exists' ' + git branch o/q && + test_must_fail git branch -m o/q o/p +' + +test_expect_success 'git branch -M o/q o/p should work when o/p exists' ' + git branch -M o/q o/p +' + +test_expect_success 'git branch -m -f o/q o/p should work when o/p exists' ' + git branch o/q && + git branch -m -f o/q o/p +' + test_expect_success 'git branch -m q r/q should fail when r exists' ' git branch q && git branch r && diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index cfd67ff3df..8cffd35fb0 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -7,28 +7,22 @@ test_description='Test commit notes' . ./test-lib.sh -cat > fake_editor.sh << \EOF -#!/bin/sh -echo "$MSG" > "$1" -echo "$MSG" >& 2 +write_script fake_editor <<\EOF +echo "$MSG" >"$1" +echo "$MSG" >&2 EOF -chmod a+x fake_editor.sh -GIT_EDITOR=./fake_editor.sh +GIT_EDITOR=./fake_editor export GIT_EDITOR +indent=" " + test_expect_success 'cannot annotate non-existing HEAD' ' test_must_fail env MSG=3 git notes add ' -test_expect_success setup ' - : > a1 && - git add a1 && - test_tick && - git commit -m 1st && - : > a2 && - git add a2 && - test_tick && - git commit -m 2nd +test_expect_success 'setup' ' + test_commit 1st && + test_commit 2nd ' test_expect_success 'need valid notes ref' ' @@ -50,206 +44,186 @@ test_expect_success 'handle empty notes gracefully' ' ' test_expect_success 'show non-existent notes entry with %N' ' - for l in A B - do - echo "$l" - done >expect && - git show -s --format='A%n%NB' >output && - test_cmp expect output + test_write_lines A B >expect && + git show -s --format="A%n%NB" >actual && + test_cmp expect actual ' test_expect_success 'create notes' ' - git config core.notesRef refs/notes/commits && MSG=b4 git notes add && - test ! -f .git/NOTES_EDITMSG && - test 1 = $(git ls-tree refs/notes/commits | wc -l) && - test b4 = $(git notes show) && + test_path_is_missing .git/NOTES_EDITMSG && + git ls-tree -r refs/notes/commits >actual && + test_line_count = 1 actual && + test "b4" = "$(git notes show)" && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'show notes entry with %N' ' - for l in A b4 B - do - echo "$l" - done >expect && - git show -s --format='A%n%NB' >output && - test_cmp expect output + test_write_lines A b4 B >expect && + git show -s --format="A%n%NB" >actual && + test_cmp expect actual ' -cat >expect <<EOF -d423f8c refs/notes/commits@{0}: notes: Notes added by 'git notes add' -EOF - test_expect_success 'create reflog entry' ' - git reflog show refs/notes/commits >output && - test_cmp expect output + cat <<-EOF >expect && + a1d8fa6 refs/notes/commits@{0}: notes: Notes added by '\''git notes add'\'' + EOF + git reflog show refs/notes/commits >actual && + test_cmp expect actual ' test_expect_success 'edit existing notes' ' MSG=b3 git notes edit && - test ! -f .git/NOTES_EDITMSG && - test 1 = $(git ls-tree refs/notes/commits | wc -l) && - test b3 = $(git notes show) && + test_path_is_missing .git/NOTES_EDITMSG && + git ls-tree -r refs/notes/commits >actual && + test_line_count = 1 actual && + test "b3" = "$(git notes show)" && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'cannot "git notes add -m" where notes already exists' ' test_must_fail git notes add -m "b2" && - test ! -f .git/NOTES_EDITMSG && - test 1 = $(git ls-tree refs/notes/commits | wc -l) && - test b3 = $(git notes show) && + test_path_is_missing .git/NOTES_EDITMSG && + git ls-tree -r refs/notes/commits >actual && + test_line_count = 1 actual && + test "b3" = "$(git notes show)" && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'can overwrite existing note with "git notes add -f -m"' ' git notes add -f -m "b1" && - test ! -f .git/NOTES_EDITMSG && - test 1 = $(git ls-tree refs/notes/commits | wc -l) && - test b1 = $(git notes show) && + test_path_is_missing .git/NOTES_EDITMSG && + git ls-tree -r refs/notes/commits >actual && + test_line_count = 1 actual && + test "b1" = "$(git notes show)" && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'add w/no options on existing note morphs into edit' ' MSG=b2 git notes add && - test ! -f .git/NOTES_EDITMSG && - test 1 = $(git ls-tree refs/notes/commits | wc -l) && - test b2 = $(git notes show) && + test_path_is_missing .git/NOTES_EDITMSG && + git ls-tree -r refs/notes/commits >actual && + test_line_count = 1 actual && + test "b2" = "$(git notes show)" && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'can overwrite existing note with "git notes add -f"' ' MSG=b1 git notes add -f && - test ! -f .git/NOTES_EDITMSG && - test 1 = $(git ls-tree refs/notes/commits | wc -l) && - test b1 = $(git notes show) && + test_path_is_missing .git/NOTES_EDITMSG && + git ls-tree -r refs/notes/commits >actual && + test_line_count = 1 actual && + test "b1" = "$(git notes show)" && git show HEAD^ && test_must_fail git notes show HEAD^ ' -cat > expect << EOF -commit 268048bfb8a1fb38e703baceb8ab235421bf80c5 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:14:13 2005 -0700 - - 2nd +test_expect_success 'show notes' ' + cat >expect <<-EOF && + commit 7a4ca6ee52a974a66cbaa78e33214535dff1d691 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:14:13 2005 -0700 -Notes: - b1 -EOF + ${indent}2nd -test_expect_success 'show notes' ' + Notes: + ${indent}b1 + EOF ! (git cat-file commit HEAD | grep b1) && - git log -1 > output && - test_cmp expect output -' - -test_expect_success 'create multi-line notes (setup)' ' - : > a3 && - git add a3 && - test_tick && - git commit -m 3rd && - MSG="b3 -c3c3c3c3 -d3d3d3" git notes add + git log -1 >actual && + test_cmp expect actual ' -cat > expect-multiline << EOF -commit 1584215f1d29c65e99c6c6848626553fdd07fd75 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:15:13 2005 -0700 - - 3rd +test_expect_success 'show multi-line notes' ' + test_commit 3rd && + MSG="b3${LF}c3c3c3c3${LF}d3d3d3" git notes add && + cat >expect-multiline <<-EOF && + commit d07d62e5208f22eb5695e7eb47667dc8b9860290 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:15:13 2005 -0700 -Notes: - b3 - c3c3c3c3 - d3d3d3 -EOF + ${indent}3rd -printf "\n" >> expect-multiline -cat expect >> expect-multiline + Notes: + ${indent}b3 + ${indent}c3c3c3c3 + ${indent}d3d3d3 -test_expect_success 'show multi-line notes' ' - git log -2 > output && - test_cmp expect-multiline output -' -test_expect_success 'create -F notes (setup)' ' - : > a4 && - git add a4 && - test_tick && - git commit -m 4th && - echo "xyzzy" > note5 && - git notes add -F note5 + EOF + cat expect >>expect-multiline && + git log -2 >actual && + test_cmp expect-multiline actual ' -cat > expect-F << EOF -commit 15023535574ded8b1a89052b32673f84cf9582b8 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:16:13 2005 -0700 +test_expect_success 'show -F notes' ' + test_commit 4th && + echo "xyzzy" >note5 && + git notes add -F note5 && + cat >expect-F <<-EOF && + commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:16:13 2005 -0700 - 4th + ${indent}4th -Notes: - xyzzy -EOF + Notes: + ${indent}xyzzy -printf "\n" >> expect-F -cat expect-multiline >> expect-F - -test_expect_success 'show -F notes' ' - git log -3 > output && - test_cmp expect-F output + EOF + cat expect-multiline >>expect-F && + git log -3 >actual && + test_cmp expect-F actual ' test_expect_success 'Re-adding -F notes without -f fails' ' - echo "zyxxy" > note5 && + echo "zyxxy" >note5 && test_must_fail git notes add -F note5 && - git log -3 > output && - test_cmp expect-F output + git log -3 >actual && + test_cmp expect-F actual ' -cat >expect << EOF -commit 15023535574ded8b1a89052b32673f84cf9582b8 -tree e070e3af51011e47b183c33adf9736736a525709 -parent 1584215f1d29c65e99c6c6848626553fdd07fd75 -author A U Thor <author@example.com> 1112912173 -0700 -committer C O Mitter <committer@example.com> 1112912173 -0700 - - 4th -EOF test_expect_success 'git log --pretty=raw does not show notes' ' - git log -1 --pretty=raw >output && - test_cmp expect output + cat >expect <<-EOF && + commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11 + tree 05ac65288c4c4b3b709a020ae94b2ece2f2201ae + parent d07d62e5208f22eb5695e7eb47667dc8b9860290 + author A U Thor <author@example.com> 1112912173 -0700 + committer C O Mitter <committer@example.com> 1112912173 -0700 + + ${indent}4th + EOF + git log -1 --pretty=raw >actual && + test_cmp expect actual ' -cat >>expect <<EOF - -Notes: - xyzzy -EOF test_expect_success 'git log --show-notes' ' - git log -1 --pretty=raw --show-notes >output && - test_cmp expect output + cat >>expect <<-EOF && + + Notes: + ${indent}xyzzy + EOF + git log -1 --pretty=raw --show-notes >actual && + test_cmp expect actual ' test_expect_success 'git log --no-notes' ' - git log -1 --no-notes >output && - ! grep xyzzy output + git log -1 --no-notes >actual && + ! grep xyzzy actual ' test_expect_success 'git format-patch does not show notes' ' - git format-patch -1 --stdout >output && - ! grep xyzzy output + git format-patch -1 --stdout >actual && + ! grep xyzzy actual ' test_expect_success 'git format-patch --show-notes does show notes' ' - git format-patch --show-notes -1 --stdout >output && - grep xyzzy output + git format-patch --show-notes -1 --stdout >actual && + grep xyzzy actual ' for pretty in \ @@ -261,8 +235,8 @@ do ?*) p="$pretty" not=" not" negate="!" ;; esac test_expect_success "git show $pretty does$not show notes" ' - git show $p >output && - eval "$negate grep xyzzy output" + git show $p >actual && + eval "$negate grep xyzzy actual" ' done @@ -271,161 +245,131 @@ test_expect_success 'setup alternate notes ref' ' ' test_expect_success 'git log --notes shows default notes' ' - git log -1 --notes >output && - grep xyzzy output && - ! grep alternate output + git log -1 --notes >actual && + grep xyzzy actual && + ! grep alternate actual ' test_expect_success 'git log --notes=X shows only X' ' - git log -1 --notes=alternate >output && - ! grep xyzzy output && - grep alternate output + git log -1 --notes=alternate >actual && + ! grep xyzzy actual && + grep alternate actual ' test_expect_success 'git log --notes --notes=X shows both' ' - git log -1 --notes --notes=alternate >output && - grep xyzzy output && - grep alternate output + git log -1 --notes --notes=alternate >actual && + grep xyzzy actual && + grep alternate actual ' test_expect_success 'git log --no-notes resets default state' ' git log -1 --notes --notes=alternate \ --no-notes --notes=alternate \ - >output && - ! grep xyzzy output && - grep alternate output + >actual && + ! grep xyzzy actual && + grep alternate actual ' test_expect_success 'git log --no-notes resets ref list' ' git log -1 --notes --notes=alternate \ --no-notes --notes \ - >output && - grep xyzzy output && - ! grep alternate output -' - -test_expect_success 'create -m notes (setup)' ' - : > a5 && - git add a5 && - test_tick && - git commit -m 5th && - git notes add -m spam -m "foo -bar -baz" -' - -whitespace=" " -cat > expect-m << EOF -commit bd1753200303d0a0344be813e504253b3d98e74d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:17:13 2005 -0700 - - 5th - -Notes: - spam -$whitespace - foo - bar - baz -EOF - -printf "\n" >> expect-m -cat expect-F >> expect-m - -test_expect_success 'show -m notes' ' - git log -4 > output && - test_cmp expect-m output + >actual && + grep xyzzy actual && + ! grep alternate actual ' -test_expect_success 'remove note with add -f -F /dev/null (setup)' ' - git notes add -f -F /dev/null -' - -cat > expect-rm-F << EOF -commit bd1753200303d0a0344be813e504253b3d98e74d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:17:13 2005 -0700 - - 5th -EOF - -printf "\n" >> expect-rm-F -cat expect-F >> expect-rm-F - -test_expect_success 'verify note removal with -F /dev/null' ' - git log -4 > output && - test_cmp expect-rm-F output && +test_expect_success 'show -m notes' ' + test_commit 5th && + git notes add -m spam -m "foo${LF}bar${LF}baz" && + cat >expect-m <<-EOF && + commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:17:13 2005 -0700 + + ${indent}5th + + Notes: + ${indent}spam + ${indent} + ${indent}foo + ${indent}bar + ${indent}baz + + EOF + cat expect-F >>expect-m && + git log -4 >actual && + test_cmp expect-m actual +' + +test_expect_success 'remove note with add -f -F /dev/null' ' + git notes add -f -F /dev/null && + cat >expect-rm-F <<-EOF && + commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:17:13 2005 -0700 + + ${indent}5th + + EOF + cat expect-F >>expect-rm-F && + git log -4 >actual && + test_cmp expect-rm-F actual && test_must_fail git notes show ' -test_expect_success 'do not create empty note with -m "" (setup)' ' - git notes add -m "" -' - -test_expect_success 'verify non-creation of note with -m ""' ' - git log -4 > output && - test_cmp expect-rm-F output && +test_expect_success 'do not create empty note with -m ""' ' + git notes add -m "" && + git log -4 >actual && + test_cmp expect-rm-F actual && test_must_fail git notes show ' -cat > expect-combine_m_and_F << EOF -foo - -xyzzy +test_expect_success 'create note with combination of -m and -F' ' + cat >expect-combine_m_and_F <<-EOF && + foo -bar + xyzzy -zyxxy + bar -baz -EOF + zyxxy -test_expect_success 'create note with combination of -m and -F' ' - echo "xyzzy" > note_a && - echo "zyxxy" > note_b && + baz + EOF + echo "xyzzy" >note_a && + echo "zyxxy" >note_b && git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" && - git notes show > output && - test_cmp expect-combine_m_and_F output + git notes show >actual && + test_cmp expect-combine_m_and_F actual ' -test_expect_success 'remove note with "git notes remove" (setup)' ' +test_expect_success 'remove note with "git notes remove"' ' git notes remove HEAD^ && - git notes remove -' - -cat > expect-rm-remove << EOF -commit bd1753200303d0a0344be813e504253b3d98e74d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:17:13 2005 -0700 + git notes remove && + cat >expect-rm-remove <<-EOF && + commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:17:13 2005 -0700 - 5th + ${indent}5th -commit 15023535574ded8b1a89052b32673f84cf9582b8 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:16:13 2005 -0700 + commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:16:13 2005 -0700 - 4th -EOF - -printf "\n" >> expect-rm-remove -cat expect-multiline >> expect-rm-remove + ${indent}4th -test_expect_success 'verify note removal with "git notes remove"' ' - git log -4 > output && - test_cmp expect-rm-remove output && + EOF + cat expect-multiline >>expect-rm-remove && + git log -4 >actual && + test_cmp expect-rm-remove actual && test_must_fail git notes show HEAD^ ' -cat > expect << EOF -c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75 -c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5 -EOF - test_expect_success 'removing non-existing note should not create new commit' ' - git rev-parse --verify refs/notes/commits > before_commit && + git rev-parse --verify refs/notes/commits >before_commit && test_must_fail git notes remove HEAD^ && - git rev-parse --verify refs/notes/commits > after_commit && + git rev-parse --verify refs/notes/commits >after_commit && test_cmp before_commit after_commit ' @@ -505,70 +449,68 @@ test_expect_success 'removing with --stdin --ignore-missing' ' ' test_expect_success 'list notes with "git notes list"' ' - git notes list > output && - test_cmp expect output + cat >expect <<-EOF && + c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691 + c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290 + EOF + git notes list >actual && + test_cmp expect actual ' test_expect_success 'list notes with "git notes"' ' - git notes > output && - test_cmp expect output + git notes >actual && + test_cmp expect actual ' -cat > expect << EOF -c18dc024e14f08d18d14eea0d747ff692d66d6a3 -EOF - test_expect_success 'list specific note with "git notes list <object>"' ' - git notes list HEAD^^ > output && - test_cmp expect output + cat >expect <<-EOF && + c18dc024e14f08d18d14eea0d747ff692d66d6a3 + EOF + git notes list HEAD^^ >actual && + test_cmp expect actual ' -cat > expect << EOF -EOF - test_expect_success 'listing non-existing notes fails' ' - test_must_fail git notes list HEAD > output && - test_cmp expect output + cat >expect <<-EOF && + EOF + test_must_fail git notes list HEAD >actual && + test_cmp expect actual ' -cat > expect << EOF -Initial set of notes - -More notes appended with git notes append -EOF - test_expect_success 'append to existing note with "git notes append"' ' + cat >expect <<-EOF && + Initial set of notes + + More notes appended with git notes append + EOF git notes add -m "Initial set of notes" && git notes append -m "More notes appended with git notes append" && - git notes show > output && - test_cmp expect output + git notes show >actual && + test_cmp expect actual ' -cat > expect_list << EOF -c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75 -c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5 -4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d -EOF - test_expect_success '"git notes list" does not expand to "git notes list HEAD"' ' - git notes list > output && - test_cmp expect_list output + cat >expect_list <<-EOF && + c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691 + 4b6ad22357cc8a1296720574b8d2fbc22fab0671 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290 + EOF + git notes list >actual && + test_cmp expect_list actual ' test_expect_success 'appending empty string does not change existing note' ' git notes append -m "" && - git notes show > output && - test_cmp expect output + git notes show >actual && + test_cmp expect actual ' test_expect_success 'git notes append == add when there is no existing note' ' git notes remove HEAD && test_must_fail git notes list HEAD && - git notes append -m "Initial set of notes - -More notes appended with git notes append" && - git notes show > output && - test_cmp expect output + git notes append -m "Initial set of notes${LF}${LF}More notes appended with git notes append" && + git notes show >actual && + test_cmp expect actual ' test_expect_success 'appending empty string to non-existing note does not create note' ' @@ -579,229 +521,208 @@ test_expect_success 'appending empty string to non-existing note does not create ' test_expect_success 'create other note on a different notes ref (setup)' ' - : > a6 && - git add a6 && - test_tick && - git commit -m 6th && - GIT_NOTES_REF="refs/notes/other" git notes add -m "other note" -' + test_commit 6th && + GIT_NOTES_REF="refs/notes/other" git notes add -m "other note" && + cat >expect-not-other <<-EOF && + commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:18:13 2005 -0700 -cat > expect-other << EOF -commit 387a89921c73d7ed72cd94d179c1c7048ca47756 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:18:13 2005 -0700 - - 6th - -Notes (other): - other note -EOF + ${indent}6th + EOF + cp expect-not-other expect-other && + cat >>expect-other <<-EOF -cat > expect-not-other << EOF -commit 387a89921c73d7ed72cd94d179c1c7048ca47756 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:18:13 2005 -0700 - - 6th -EOF + Notes (other): + ${indent}other note + EOF +' test_expect_success 'Do not show note on other ref by default' ' - git log -1 > output && - test_cmp expect-not-other output + git log -1 >actual && + test_cmp expect-not-other actual ' test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' ' - GIT_NOTES_REF="refs/notes/other" git log -1 > output && - test_cmp expect-other output + GIT_NOTES_REF="refs/notes/other" git log -1 >actual && + test_cmp expect-other actual ' test_expect_success 'Do show note when ref is given in core.notesRef config' ' - git config core.notesRef "refs/notes/other" && - git log -1 > output && - test_cmp expect-other output + test_config core.notesRef "refs/notes/other" && + git log -1 >actual && + test_cmp expect-other actual ' test_expect_success 'Do not show note when core.notesRef is overridden' ' - GIT_NOTES_REF="refs/notes/wrong" git log -1 > output && - test_cmp expect-not-other output + test_config core.notesRef "refs/notes/other" && + GIT_NOTES_REF="refs/notes/wrong" git log -1 >actual && + test_cmp expect-not-other actual ' -cat > expect-both << EOF -commit 387a89921c73d7ed72cd94d179c1c7048ca47756 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:18:13 2005 -0700 - - 6th +test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' ' + cat >expect-both <<-EOF && + commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:18:13 2005 -0700 -Notes: - order test + ${indent}6th -Notes (other): - other note + Notes: + ${indent}order test -commit bd1753200303d0a0344be813e504253b3d98e74d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:17:13 2005 -0700 + Notes (other): + ${indent}other note - 5th + commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:17:13 2005 -0700 -Notes: - replacement for deleted note -EOF + ${indent}5th -test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' ' + Notes: + ${indent}replacement for deleted note + EOF GIT_NOTES_REF=refs/notes/commits git notes add \ -m"replacement for deleted note" HEAD^ && GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" && - git config --unset core.notesRef && - git config notes.displayRef "refs/notes/*" && - git log -2 > output && - test_cmp expect-both output + test_unconfig core.notesRef && + test_config notes.displayRef "refs/notes/*" && + git log -2 >actual && + test_cmp expect-both actual ' test_expect_success 'core.notesRef is implicitly in notes.displayRef' ' - git config core.notesRef refs/notes/commits && - git config notes.displayRef refs/notes/other && - git log -2 > output && - test_cmp expect-both output + test_config core.notesRef refs/notes/commits && + test_config notes.displayRef refs/notes/other && + git log -2 >actual && + test_cmp expect-both actual ' test_expect_success 'notes.displayRef can be given more than once' ' - git config --unset core.notesRef && - git config notes.displayRef refs/notes/commits && + test_unconfig core.notesRef && + test_config notes.displayRef refs/notes/commits && git config --add notes.displayRef refs/notes/other && - git log -2 > output && - test_cmp expect-both output + git log -2 >actual && + test_cmp expect-both actual ' -cat > expect-both-reversed << EOF -commit 387a89921c73d7ed72cd94d179c1c7048ca47756 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:18:13 2005 -0700 - - 6th +test_expect_success 'notes.displayRef respects order' ' + cat >expect-both-reversed <<-EOF && + commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:18:13 2005 -0700 -Notes (other): - other note + ${indent}6th -Notes: - order test -EOF + Notes (other): + ${indent}other note -test_expect_success 'notes.displayRef respects order' ' - git config core.notesRef refs/notes/other && - git config --unset-all notes.displayRef && - git config notes.displayRef refs/notes/commits && - git log -1 > output && - test_cmp expect-both-reversed output + Notes: + ${indent}order test + EOF + test_config core.notesRef refs/notes/other && + test_config notes.displayRef refs/notes/commits && + git log -1 >actual && + test_cmp expect-both-reversed actual ' test_expect_success 'GIT_NOTES_DISPLAY_REF works' ' - git config --unset-all core.notesRef && - git config --unset-all notes.displayRef && GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \ - git log -2 > output && - test_cmp expect-both output + git log -2 >actual && + test_cmp expect-both actual ' -cat > expect-none << EOF -commit 387a89921c73d7ed72cd94d179c1c7048ca47756 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:18:13 2005 -0700 - - 6th +test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' ' + cat >expect-none <<-EOF && + commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:18:13 2005 -0700 -commit bd1753200303d0a0344be813e504253b3d98e74d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:17:13 2005 -0700 + ${indent}6th - 5th -EOF + commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:17:13 2005 -0700 -test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' ' - git config notes.displayRef "refs/notes/*" && - GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output && - test_cmp expect-none output + ${indent}5th + EOF + test_config notes.displayRef "refs/notes/*" && + GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 >actual && + test_cmp expect-none actual ' test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' ' - GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output && - test_cmp expect-both output + GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 >actual && + test_cmp expect-both actual ' -cat > expect-commits << EOF -commit 387a89921c73d7ed72cd94d179c1c7048ca47756 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:18:13 2005 -0700 - - 6th +test_expect_success '--no-standard-notes' ' + cat >expect-commits <<-EOF && + commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:18:13 2005 -0700 -Notes: - order test -EOF + ${indent}6th -test_expect_success '--no-standard-notes' ' - git log --no-standard-notes --show-notes=commits -1 > output && - test_cmp expect-commits output + Notes: + ${indent}order test + EOF + git log --no-standard-notes --show-notes=commits -1 >actual && + test_cmp expect-commits actual ' test_expect_success '--standard-notes' ' + test_config notes.displayRef "refs/notes/*" && git log --no-standard-notes --show-notes=commits \ - --standard-notes -2 > output && - test_cmp expect-both output + --standard-notes -2 >actual && + test_cmp expect-both actual ' test_expect_success '--show-notes=ref accumulates' ' git log --show-notes=other --show-notes=commits \ - --no-standard-notes -1 > output && - test_cmp expect-both-reversed output + --no-standard-notes -1 >actual && + test_cmp expect-both-reversed actual ' test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' ' - git config core.notesRef refs/notes/other && - echo "Note on a tree" > expect && + test_config core.notesRef refs/notes/other && + echo "Note on a tree" >expect && git notes add -m "Note on a tree" HEAD: && - git notes show HEAD: > actual && + git notes show HEAD: >actual && test_cmp expect actual && - echo "Note on a blob" > expect && + echo "Note on a blob" >expect && filename=$(git ls-tree --name-only HEAD | head -n1) && git notes add -m "Note on a blob" HEAD:$filename && - git notes show HEAD:$filename > actual && + git notes show HEAD:$filename >actual && test_cmp expect actual && - echo "Note on a tag" > expect && + echo "Note on a tag" >expect && git tag -a -m "This is an annotated tag" foobar HEAD^ && git notes add -m "Note on a tag" foobar && - git notes show foobar > actual && + git notes show foobar >actual && test_cmp expect actual ' -cat > expect << EOF -commit 2ede89468182a62d0bde2583c736089bcf7d7e92 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:19:13 2005 -0700 - - 7th +test_expect_success 'create note from other note with "git notes add -C"' ' + cat >expect <<-EOF && + commit fb01e0ca8c33b6cc0c6451dde747f97df567cb5c + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:19:13 2005 -0700 -Notes (other): - other note -EOF + ${indent}7th -test_expect_success 'create note from other note with "git notes add -C"' ' - : > a7 && - git add a7 && - test_tick && - git commit -m 7th && + Notes: + ${indent}order test + EOF + test_commit 7th && git notes add -C $(git notes list HEAD^) && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual && test "$(git notes list HEAD)" = "$(git notes list HEAD^)" ' test_expect_success 'create note from non-existing note with "git notes add -C" fails' ' - : > a8 && - git add a8 && - test_tick && - git commit -m 8th && + test_commit 8th && test_must_fail git notes add -C deadbeef && test_must_fail git notes list HEAD ' @@ -814,405 +735,386 @@ test_expect_success 'create note from non-blob with "git notes add -C" fails' ' test_must_fail git notes list HEAD ' -cat > expect << EOF -commit 80d796defacd5db327b7a4e50099663902fbdc5c -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:20:13 2005 -0700 - - 8th +test_expect_success 'create note from blob with "git notes add -C" reuses blob id' ' + cat >expect <<-EOF && + commit 9a4c31c7f722b5d517e92c64e932dd751e1413bf + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:20:13 2005 -0700 -Notes (other): - This is a blob object -EOF + ${indent}8th -test_expect_success 'create note from blob with "git notes add -C" reuses blob id' ' + Notes: + ${indent}This is a blob object + EOF blob=$(echo "This is a blob object" | git hash-object -w --stdin) && git notes add -C $blob && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual && test "$(git notes list HEAD)" = "$blob" ' -cat > expect << EOF -commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:21:13 2005 -0700 - - 9th +test_expect_success 'create note from other note with "git notes add -c"' ' + cat >expect <<-EOF && + commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:21:13 2005 -0700 -Notes (other): - yet another note -EOF + ${indent}9th -test_expect_success 'create note from other note with "git notes add -c"' ' - : > a9 && - git add a9 && - test_tick && - git commit -m 9th && + Notes: + ${indent}yet another note + EOF + test_commit 9th && MSG="yet another note" git notes add -c $(git notes list HEAD^^) && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual ' test_expect_success 'create note from non-existing note with "git notes add -c" fails' ' - : > a10 && - git add a10 && - test_tick && - git commit -m 10th && + test_commit 10th && test_must_fail env MSG="yet another note" git notes add -c deadbeef && test_must_fail git notes list HEAD ' -cat > expect << EOF -commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:21:13 2005 -0700 - - 9th - -Notes (other): - yet another note -$whitespace - yet another note -EOF - test_expect_success 'append to note from other note with "git notes append -C"' ' + cat >expect <<-EOF && + commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:21:13 2005 -0700 + + ${indent}9th + + Notes: + ${indent}yet another note + ${indent} + ${indent}yet another note + EOF git notes append -C $(git notes list HEAD^) HEAD^ && - git log -1 HEAD^ > actual && + git log -1 HEAD^ >actual && test_cmp expect actual ' -cat > expect << EOF -commit ffed603236bfa3891c49644257a83598afe8ae5a -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:22:13 2005 -0700 +test_expect_success 'create note from other note with "git notes append -c"' ' + cat >expect <<-EOF && + commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:22:13 2005 -0700 - 10th + ${indent}10th -Notes (other): - other note -EOF - -test_expect_success 'create note from other note with "git notes append -c"' ' + Notes: + ${indent}other note + EOF MSG="other note" git notes append -c $(git notes list HEAD^) && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual ' -cat > expect << EOF -commit ffed603236bfa3891c49644257a83598afe8ae5a -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:22:13 2005 -0700 - - 10th - -Notes (other): - other note -$whitespace - yet another note -EOF - test_expect_success 'append to note from other note with "git notes append -c"' ' + cat >expect <<-EOF && + commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:22:13 2005 -0700 + + ${indent}10th + + Notes: + ${indent}other note + ${indent} + ${indent}yet another note + EOF MSG="yet another note" git notes append -c $(git notes list HEAD) && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual ' -cat > expect << EOF -commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:23:13 2005 -0700 - - 11th - -Notes (other): - other note -$whitespace - yet another note -EOF - test_expect_success 'copy note with "git notes copy"' ' - : > a11 && - git add a11 && - test_tick && - git commit -m 11th && + cat >expect <<-EOF && + commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:23:13 2005 -0700 + + ${indent}11th + + Notes: + ${indent}other note + ${indent} + ${indent}yet another note + EOF + test_commit 11th && git notes copy HEAD^ HEAD && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual && test "$(git notes list HEAD)" = "$(git notes list HEAD^)" ' test_expect_success 'prevent overwrite with "git notes copy"' ' test_must_fail git notes copy HEAD~2 HEAD && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual && test "$(git notes list HEAD)" = "$(git notes list HEAD^)" ' -cat > expect << EOF -commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:23:13 2005 -0700 - - 11th - -Notes (other): - yet another note -$whitespace - yet another note -EOF - test_expect_success 'allow overwrite with "git notes copy -f"' ' + cat >expect <<-EOF && + commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:23:13 2005 -0700 + + ${indent}11th + + Notes: + ${indent}yet another note + ${indent} + ${indent}yet another note + EOF git notes copy -f HEAD~2 HEAD && - git log -1 > actual && + git log -1 >actual && test_cmp expect actual && test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" ' test_expect_success 'cannot copy note from object without notes' ' - : > a12 && - git add a12 && - test_tick && - git commit -m 12th && - : > a13 && - git add a13 && - test_tick && - git commit -m 13th && + test_commit 12th && + test_commit 13th && test_must_fail git notes copy HEAD^ HEAD ' -cat > expect << EOF -commit e5d4fb5698d564ab8c73551538ecaf2b0c666185 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:25:13 2005 -0700 - - 13th +test_expect_success 'git notes copy --stdin' ' + cat >expect <<-EOF && + commit e871aa61182b1d95d0a6fb75445d891722863b6b + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:25:13 2005 -0700 -Notes (other): - yet another note -$whitespace - yet another note + ${indent}13th -commit 7038787dfe22a14c3867ce816dbba39845359719 -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:24:13 2005 -0700 + Notes: + ${indent}yet another note + ${indent} + ${indent}yet another note - 12th + commit 65e263ded02ae4e8839bc151095113737579dc12 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:24:13 2005 -0700 -Notes (other): - other note -$whitespace - yet another note -EOF + ${indent}12th -test_expect_success 'git notes copy --stdin' ' + Notes: + ${indent}other note + ${indent} + ${indent}yet another note + EOF (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \ echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | git notes copy --stdin && - git log -2 > output && - test_cmp expect output && + git log -2 >actual && + test_cmp expect actual && test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" && test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)" ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 - - 15th +test_expect_success 'git notes copy --for-rewrite (unconfigured)' ' + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 -commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:26:13 2005 -0700 + ${indent}15th - 14th -EOF + commit 07c85d77059393ed0154b8c96906547a59dfcddd + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:26:13 2005 -0700 -test_expect_success 'git notes copy --for-rewrite (unconfigured)' ' + ${indent}14th + EOF test_commit 14th && test_commit 15th && (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \ echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | git notes copy --for-rewrite=foo && - git log -2 > output && - test_cmp expect output + git log -2 >actual && + test_cmp expect actual ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 - - 15th - -Notes (other): - yet another note -$whitespace - yet another note - -commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:26:13 2005 -0700 - - 14th - -Notes (other): - other note -$whitespace - yet another note -EOF - test_expect_success 'git notes copy --for-rewrite (enabled)' ' - git config notes.rewriteMode overwrite && - git config notes.rewriteRef "refs/notes/*" && + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 + + ${indent}15th + + Notes: + ${indent}yet another note + ${indent} + ${indent}yet another note + + commit 07c85d77059393ed0154b8c96906547a59dfcddd + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:26:13 2005 -0700 + + ${indent}14th + + Notes: + ${indent}other note + ${indent} + ${indent}yet another note + EOF + test_config notes.rewriteMode overwrite && + test_config notes.rewriteRef "refs/notes/*" && (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \ echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | git notes copy --for-rewrite=foo && - git log -2 > output && - test_cmp expect output + git log -2 >actual && + test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (disabled)' ' - git config notes.rewrite.bar false && + test_config notes.rewrite.bar false && echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) | git notes copy --for-rewrite=bar && - git log -2 > output && - test_cmp expect output + git log -2 >actual && + test_cmp expect actual ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 - - 15th +test_expect_success 'git notes copy --for-rewrite (overwrite)' ' + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 -Notes (other): - a fresh note -EOF + ${indent}15th -test_expect_success 'git notes copy --for-rewrite (overwrite)' ' + Notes: + ${indent}a fresh note + EOF git notes add -f -m"a fresh note" HEAD^ && + test_config notes.rewriteMode overwrite && + test_config notes.rewriteRef "refs/notes/*" && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (ignore)' ' - git config notes.rewriteMode ignore && + test_config notes.rewriteMode ignore && + test_config notes.rewriteRef "refs/notes/*" && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 - - 15th - -Notes (other): - a fresh note -$whitespace - another fresh note -EOF - test_expect_success 'git notes copy --for-rewrite (append)' ' + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 + + ${indent}15th + + Notes: + ${indent}a fresh note + ${indent} + ${indent}another fresh note + EOF git notes add -f -m"another fresh note" HEAD^ && - git config notes.rewriteMode concatenate && + test_config notes.rewriteMode concatenate && + test_config notes.rewriteRef "refs/notes/*" && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 - - 15th - -Notes (other): - a fresh note -$whitespace - another fresh note -$whitespace - append 1 -$whitespace - append 2 -EOF - test_expect_success 'git notes copy --for-rewrite (append two to one)' ' + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 + + ${indent}15th + + Notes: + ${indent}a fresh note + ${indent} + ${indent}another fresh note + ${indent} + ${indent}append 1 + ${indent} + ${indent}append 2 + EOF git notes add -f -m"append 1" HEAD^ && git notes add -f -m"append 2" HEAD^^ && + test_config notes.rewriteMode concatenate && + test_config notes.rewriteRef "refs/notes/*" && (echo $(git rev-parse HEAD^) $(git rev-parse HEAD); echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) | git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (append empty)' ' git notes remove HEAD^ && + test_config notes.rewriteMode concatenate && + test_config notes.rewriteRef "refs/notes/*" && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 - - 15th - -Notes (other): - replacement note 1 -EOF - test_expect_success 'GIT_NOTES_REWRITE_MODE works' ' + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 + + ${indent}15th + + Notes: + ${indent}replacement note 1 + EOF + test_config notes.rewriteMode concatenate && + test_config notes.rewriteRef "refs/notes/*" && git notes add -f -m"replacement note 1" HEAD^ && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' -cat > expect << EOF -commit 37a0d4cba38afef96ba54a3ea567e6dac575700b -Author: A U Thor <author@example.com> -Date: Thu Apr 7 15:27:13 2005 -0700 +test_expect_success 'GIT_NOTES_REWRITE_REF works' ' + cat >expect <<-EOF && + commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + Author: A U Thor <author@example.com> + Date: Thu Apr 7 15:27:13 2005 -0700 - 15th + ${indent}15th -Notes (other): - replacement note 2 -EOF - -test_expect_success 'GIT_NOTES_REWRITE_REF works' ' - git config notes.rewriteMode overwrite && + Notes: + ${indent}replacement note 2 + EOF git notes add -f -m"replacement note 2" HEAD^ && - git config --unset-all notes.rewriteRef && + test_config notes.rewriteMode overwrite && + test_unconfig notes.rewriteRef && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \ git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' ' - git config notes.rewriteRef refs/notes/other && git notes add -f -m"replacement note 3" HEAD^ && + test_config notes.rewriteMode overwrite && + test_config notes.rewriteRef refs/notes/other && echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo && - git log -1 > output && - test_cmp expect output + git log -1 >actual && + test_cmp expect actual ' test_expect_success 'git notes copy diagnoses too many or too few parameters' ' @@ -1221,13 +1123,13 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' ' ' test_expect_success 'git notes get-ref (no overrides)' ' - git config --unset core.notesRef && + test_unconfig core.notesRef && sane_unset GIT_NOTES_REF && test "$(git notes get-ref)" = "refs/notes/commits" ' test_expect_success 'git notes get-ref (core.notesRef)' ' - git config core.notesRef refs/notes/foo && + test_config core.notesRef refs/notes/foo && test "$(git notes get-ref)" = "refs/notes/foo" ' @@ -1239,4 +1141,51 @@ test_expect_success 'git notes get-ref (--ref)' ' test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz" ' +test_expect_success 'setup testing of empty notes' ' + test_unconfig core.notesRef && + test_commit 16th && + empty_blob=$(git hash-object -w /dev/null) && + echo "$empty_blob" >expect_empty +' + +while read cmd +do + test_expect_success "'git notes $cmd' removes empty note" " + test_might_fail git notes remove HEAD && + MSG= git notes $cmd && + test_must_fail git notes list HEAD + " + + test_expect_success "'git notes $cmd --allow-empty' stores empty note" " + test_might_fail git notes remove HEAD && + MSG= git notes $cmd --allow-empty && + git notes list HEAD >actual && + test_cmp expect_empty actual + " +done <<\EOF +add +add -F /dev/null +add -m "" +add -c "$empty_blob" +add -C "$empty_blob" +append +append -F /dev/null +append -m "" +append -c "$empty_blob" +append -C "$empty_blob" +edit +EOF + +test_expect_success 'empty notes are displayed by git log' ' + test_commit 17th && + git log -1 >expect && + cat >>expect <<-EOF && + + Notes: + EOF + git notes add -C "$empty_blob" --allow-empty && + git log -1 >actual && + test_cmp expect actual +' + test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 8197ed29a9..a31f7e0430 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1039,4 +1039,11 @@ test_expect_success 'short SHA-1 collide' ' ) ' +test_expect_success 'respect core.abbrev' ' + git config core.abbrev 12 && + set_cat_todo_editor && + test_must_fail git rebase -i HEAD~4 >todo-list && + test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list) +' + test_done diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 223b98433c..7c5ad08626 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -351,19 +351,45 @@ test_expect_success 'commit after failed cherry-pick does not add duplicated -s' test_expect_success 'commit after failed cherry-pick adds -s at the right place' ' pristine_detach initial && test_must_fail git cherry-pick picked && + git commit -a -s && - pwd && - cat <<EOF > expected && -picked -Signed-off-by: C O Mitter <committer@example.com> + # Do S-o-b and Conflicts appear in the right order? + cat <<-\EOF >expect && + Signed-off-by: C O Mitter <committer@example.com> + # Conflicts: + EOF + grep -e "^# Conflicts:" -e '^Signed-off-by' <.git/COMMIT_EDITMSG >actual && + test_cmp expect actual && + + cat <<-\EOF >expected && + picked -Conflicts: - foo -EOF + Signed-off-by: C O Mitter <committer@example.com> + EOF - git show -s --pretty=format:%B > actual && + git show -s --pretty=format:%B >actual && test_cmp expected actual ' +test_expect_success 'commit --amend -s places the sign-off at the right place' ' + pristine_detach initial && + test_must_fail git cherry-pick picked && + + # emulate old-style conflicts block + mv .git/MERGE_MSG .git/MERGE_MSG+ && + sed -e "/^# Conflicts:/,\$s/^# *//" <.git/MERGE_MSG+ >.git/MERGE_MSG && + + git commit -a && + git commit --amend -s && + + # Do S-o-b and Conflicts appear in the right order? + cat <<-\EOF >expect && + Signed-off-by: C O Mitter <committer@example.com> + Conflicts: + EOF + grep -e "^Conflicts:" -e '^Signed-off-by' <.git/COMMIT_EDITMSG >actual && + test_cmp expect actual +' + test_done diff --git a/t/t3700-add.sh b/t/t3700-add.sh index fe274e2fb1..f7ff1f555d 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -91,6 +91,13 @@ test_expect_success 'error out when attempting to add ignored ones without -f' ' ! (git ls-files | grep "\\.ig") ' +test_expect_success 'error out when attempting to add ignored ones but add others' ' + touch a.if && + test_must_fail git add a.?? && + ! (git ls-files | grep "\\.ig") && + (git ls-files | grep a.if) +' + test_expect_success 'add ignored ones with -f' ' git add -f a.?? && git ls-files --error-unmatch a.ig @@ -311,7 +318,6 @@ cat >expect.err <<\EOF The following paths are ignored by one of your .gitignore files: ignored-file Use -f if you really want to add them. -fatal: no files added EOF cat >expect.out <<\EOF add 'track-this' diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh index 27e98a8f9d..8920464896 100755 --- a/t/t4008-diff-break-rewrite.sh +++ b/t/t4008-diff-break-rewrite.sh @@ -123,10 +123,10 @@ test_expect_success \ 'git diff-index -B -M "$tree" >current' # file0 changed from regular to symlink. file1 is very close to the preimage of file0. -# because we break file0, file1 can become a rename of it. +# the change does not make file0 disappear, so file1 is denoted as a copy of file0 cat >expected <<\EOF :100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0 -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 R file0 file1 +:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 C file0 file1 EOF test_expect_success \ diff --git a/t/t4023-diff-rename-typechange.sh b/t/t4023-diff-rename-typechange.sh index 55d549fcf4..8c9823765e 100755 --- a/t/t4023-diff-rename-typechange.sh +++ b/t/t4023-diff-rename-typechange.sh @@ -76,7 +76,8 @@ test_expect_success 'moves and renames' ' git diff-tree three four -r --name-status -B -M | sort >actual && { - echo "R100 foo bar" + # see -B -M (#6) in t4008 + echo "C100 foo bar" echo "T100 foo" } | sort >expect && test_cmp expect actual diff --git a/t/t4026-color.sh b/t/t4026-color.sh index 63e423838f..4d20feacfe 100755 --- a/t/t4026-color.sh +++ b/t/t4026-color.sh @@ -45,14 +45,33 @@ test_expect_success 'fg bg attr...' ' color "blue bold dim ul blink reverse" "[1;2;4;5;7;34m" ' +# note that nobold and nodim are the same code (22) +test_expect_success 'attr negation' ' + color "nobold nodim noul noblink noreverse" "[22;24;25;27m" +' + test_expect_success 'long color specification' ' color "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m" ' +test_expect_success 'absurdly long color specification' ' + color \ + "#ffffff #ffffff bold nobold dim nodim ul noul blink noblink reverse noreverse" \ + "[1;2;4;5;7;22;24;25;27;38;2;255;255;255;48;2;255;255;255m" +' + +test_expect_success '0-7 are aliases for basic ANSI color names' ' + color "0 7" "[30;47m" +' + test_expect_success '256 colors' ' color "254 bold 255" "[1;38;5;254;48;5;255m" ' +test_expect_success '24-bit colors' ' + color "#ff00ff black" "[38;2;255;0;255;40m" +' + test_expect_success '"normal" yields no color at all"' ' color "normal black" "[40m" ' diff --git a/t/t4122-apply-symlink-inside.sh b/t/t4122-apply-symlink-inside.sh index 70b3a06e1d..1814647663 100755 --- a/t/t4122-apply-symlink-inside.sh +++ b/t/t4122-apply-symlink-inside.sh @@ -3,17 +3,10 @@ test_description='apply to deeper directory without getting fooled with symlink' . ./test-lib.sh -lecho () { - for l_ - do - echo "$l_" - done -} - test_expect_success setup ' mkdir -p arch/i386/boot arch/x86_64 && - lecho 1 2 3 4 5 >arch/i386/boot/Makefile && + test_write_lines 1 2 3 4 5 >arch/i386/boot/Makefile && test_ln_s_add ../i386/boot arch/x86_64/boot && git add . && test_tick && @@ -22,7 +15,7 @@ test_expect_success setup ' rm arch/x86_64/boot && mkdir arch/x86_64/boot && - lecho 2 3 4 5 6 >arch/x86_64/boot/Makefile && + test_write_lines 2 3 4 5 6 >arch/x86_64/boot/Makefile && git add . && test_tick && git commit -a -m second && diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh new file mode 100755 index 0000000000..0ffe33fbef --- /dev/null +++ b/t/t4138-apply-ws-expansion.sh @@ -0,0 +1,121 @@ +#!/bin/sh +# +# Copyright (C) 2015 Kyle J. McKay +# + +test_description='git apply test patches with whitespace expansion.' + +. ./test-lib.sh + +test_expect_success setup ' + # + ## create test-N, patchN.patch, expect-N files + # + + # test 1 + printf "\t%s\n" 1 2 3 4 5 6 >before && + printf "\t%s\n" 1 2 3 >after && + printf "%64s\n" a b c >>after && + printf "\t%s\n" 4 5 6 >>after && + git diff --no-index before after | + sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch && + printf "%64s\n" 1 2 3 4 5 6 >test-1 && + printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 && + + # test 2 + printf "\t%s\n" a b c d e f >before && + printf "\t%s\n" a b c >after && + n=10 && + x=1 && + while test $x -lt $n + do + printf "%63s%d\n" "" $x >>after + x=$(( $x + 1 )) + done && + printf "\t%s\n" d e f >>after && + git diff --no-index before after | + sed -e "s/before/test-2/" -e "s/after/test-2/" >patch2.patch && + printf "%64s\n" a b c d e f >test-2 && + printf "%64s\n" a b c >expect-2 && + x=1 && + while test $x -lt $n + do + printf "%63s%d\n" "" $x >>expect-2 + x=$(( $x + 1 )) + done && + printf "%64s\n" d e f >>expect-2 && + + # test 3 + printf "\t%s\n" a b c d e f >before && + printf "\t%s\n" a b c >after && + n=100 && + x=0 && + while test $x -lt $n + do + printf "%63s%02d\n" "" $x >>after + x=$(( $x + 1 )) + done && + printf "\t%s\n" d e f >>after && + git diff --no-index before after | + sed -e "s/before/test-3/" -e "s/after/test-3/" >patch3.patch && + printf "%64s\n" a b c d e f >test-3 && + printf "%64s\n" a b c >expect-3 && + x=0 && + while test $x -lt $n + do + printf "%63s%02d\n" "" $x >>expect-3 + x=$(( $x + 1 )) + done && + printf "%64s\n" d e f >>expect-3 && + + # test 4 + >before && + x=0 && + while test $x -lt 50 + do + printf "\t%02d\n" $x >>before + x=$(( $x + 1 )) + done && + cat before >after && + printf "%64s\n" a b c >>after && + while test $x -lt 100 + do + printf "\t%02d\n" $x >>before + printf "\t%02d\n" $x >>after + x=$(( $x + 1 )) + done && + git diff --no-index before after | + sed -e "s/before/test-4/" -e "s/after/test-4/" >patch4.patch && + >test-4 && + x=0 && + while test $x -lt 50 + do + printf "%63s%02d\n" "" $x >>test-4 + x=$(( $x + 1 )) + done && + cat test-4 >expect-4 && + printf "%64s\n" a b c >>expect-4 && + while test $x -lt 100 + do + printf "%63s%02d\n" "" $x >>test-4 + printf "%63s%02d\n" "" $x >>expect-4 + x=$(( $x + 1 )) + done && + + git config core.whitespace tab-in-indent,tabwidth=63 && + git config apply.whitespace fix + +' + +# Note that `patch` can successfully apply all patches when run +# with the --ignore-whitespace option. + +for t in 1 2 3 4 +do + test_expect_success 'apply with ws expansion (t=$t)' ' + git apply patch$t.patch && + test_cmp test-$t expect-$t + ' +done + +test_done diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 5edb79a058..306e6f39ac 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -85,6 +85,7 @@ test_expect_success setup ' git format-patch --stdout first >patch1 && { + echo "Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru>" && echo "X-Fake-Field: Line One" && echo "X-Fake-Field: Line Two" && echo "X-Fake-Field: Line Three" && @@ -536,4 +537,26 @@ test_expect_success 'am empty-file does not infloop' ' test_i18ncmp expected actual ' +test_expect_success 'am --message-id really adds the message id' ' + rm -fr .git/rebase-apply && + git reset --hard && + git checkout HEAD^ && + git am --message-id patch1.eml && + test_path_is_missing .git/rebase-apply && + git cat-file commit HEAD | tail -n1 >actual && + grep Message-Id patch1.eml >expected && + test_cmp expected actual +' + +test_expect_success 'am --message-id -s signs off after the message id' ' + rm -fr .git/rebase-apply && + git reset --hard && + git checkout HEAD^ && + git am -s --message-id patch1.eml && + test_path_is_missing .git/rebase-apply && + git cat-file commit HEAD | tail -n2 | head -n1 >actual && + grep Message-Id patch1.eml >expected && + test_cmp expected actual +' + test_done diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 99ab7ca21f..5f2b290d2b 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -212,6 +212,21 @@ test_expect_success 'log --grep' ' test_cmp expect actual ' +cat > expect << EOF +second +initial +EOF +test_expect_success 'log --invert-grep --grep' ' + git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual && + test_cmp expect actual +' + +test_expect_success 'log --invert-grep --grep -i' ' + echo initial >expect && + git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual && + test_cmp expect actual +' + test_expect_success 'log --grep option parsing' ' echo second >expect && git log -1 --pretty="tformat:%s" --grep sec >actual && diff --git a/t/t4255-am-submodule.sh b/t/t4255-am-submodule.sh index 8bde7dbb6d..0ba8194403 100755 --- a/t/t4255-am-submodule.sh +++ b/t/t4255-am-submodule.sh @@ -18,4 +18,76 @@ am_3way () { KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 test_submodule_switch "am_3way" +test_expect_success 'setup diff.submodule' ' + test_commit one && + INITIAL=$(git rev-parse HEAD) && + + git init submodule && + ( + cd submodule && + test_commit two && + git rev-parse HEAD >../initial-submodule + ) && + git submodule add ./submodule && + git commit -m first && + + ( + cd submodule && + test_commit three && + git rev-parse HEAD >../first-submodule + ) && + git add submodule && + git commit -m second && + SECOND=$(git rev-parse HEAD) && + + ( + cd submodule && + git mv two.t four.t && + git commit -m "second submodule" && + git rev-parse HEAD >../second-submodule + ) && + test_commit four && + git add submodule && + git commit --amend --no-edit && + THIRD=$(git rev-parse HEAD) && + git submodule update --init +' + +run_test() { + START_COMMIT=$1 && + EXPECT=$2 && + # Abort any merges in progress: the previous + # test may have failed, and we should clean up. + test_might_fail git am --abort && + git reset --hard $START_COMMIT && + rm -f *.patch && + git format-patch -1 && + git reset --hard $START_COMMIT^ && + git submodule update && + git am *.patch && + git submodule update && + git -C submodule rev-parse HEAD >actual && + test_cmp $EXPECT actual +} + +test_expect_success 'diff.submodule unset' ' + test_unconfig diff.submodule && + run_test $SECOND first-submodule +' + +test_expect_success 'diff.submodule unset with extra file' ' + test_unconfig diff.submodule && + run_test $THIRD second-submodule +' + +test_expect_success 'diff.submodule=log' ' + test_config diff.submodule log && + run_test $SECOND first-submodule +' + +test_expect_success 'diff.submodule=log with extra file' ' + test_config diff.submodule log && + run_test $THIRD second-submodule +' + test_done diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index d01bbdc968..4b68bbafbe 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -101,7 +101,7 @@ test_expect_success \ ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten && echo long filename >a/four$hundred && mkdir a/bin && - cp /bin/sh a/bin && + test-genrandom "frotz" 500000 >a/bin/sh && printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 && printf "A not substituted O" >a/substfile2 && if test_have_prereq SYMLINKS; then diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 9e1ad1ca21..60df10f46a 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -35,6 +35,10 @@ do then check_mailinfo $mail --no-inbody-headers fi + if test -f "$TEST_DIRECTORY"/t5100/msg$mail--message-id + then + check_mailinfo $mail --message-id + fi ' done diff --git a/t/t5100/info0012--message-id b/t/t5100/info0012--message-id new file mode 100644 index 0000000000..ac1216ff75 --- /dev/null +++ b/t/t5100/info0012--message-id @@ -0,0 +1,5 @@ +Author: Dmitriy Blinov +Email: bda@mnsspb.ru +Subject: Изменён список пакетов необходимых для сборки +Date: Wed, 12 Nov 2008 17:54:41 +0300 + diff --git a/t/t5100/msg0012--message-id b/t/t5100/msg0012--message-id new file mode 100644 index 0000000000..376e26e9ae --- /dev/null +++ b/t/t5100/msg0012--message-id @@ -0,0 +1,8 @@ +textlive-* исправлены на texlive-* +docutils заменён на python-docutils + +Действительно, оказалось, что rest2web вытягивает за собой +python-docutils. В то время как сам rest2web не нужен. + +Signed-off-by: Dmitriy Blinov <bda@mnsspb.ru> +Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru> diff --git a/t/t5100/patch0012--message-id b/t/t5100/patch0012--message-id new file mode 100644 index 0000000000..36a0b68161 --- /dev/null +++ b/t/t5100/patch0012--message-id @@ -0,0 +1,30 @@ +--- + howto/build_navy.txt | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/howto/build_navy.txt b/howto/build_navy.txt +index 3fd3afb..0ee807e 100644 +--- a/howto/build_navy.txt ++++ b/howto/build_navy.txt +@@ -119,8 +119,8 @@ + - libxv-dev + - libusplash-dev + - latex-make +- - textlive-lang-cyrillic +- - textlive-latex-extra ++ - texlive-lang-cyrillic ++ - texlive-latex-extra + - dia + - python-pyrex + - libtool +@@ -128,7 +128,7 @@ + - sox + - cython + - imagemagick +- - docutils ++ - python-docutils + + #. на машине dinar: добавить свой открытый ssh-ключ в authorized_keys2 пользователя ddev + #. на своей машине: отредактировать /etc/sudoers (команда ``visudo``) примерно следующим образом:: +-- +1.5.6.5 diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index e32e46dee1..0794d33dad 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -253,4 +253,12 @@ test_expect_success 'prune .git/shallow' ' test_path_is_missing .git/shallow ' +test_expect_success 'prune: handle alternate object database' ' + test_create_repo A && + git -C A commit --allow-empty -m "initial commit" && + git clone --shared A B && + git -C B commit --allow-empty -m "next commit" && + git -C B prune +' + test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 0736bcbcd5..04cea97f87 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -76,8 +76,7 @@ test_expect_success 'refuse pushing rewound head without --force' ' test "$victim_head" = "$pushed_head" ' -test_expect_success \ - 'push can be used to delete a ref' ' +test_expect_success 'push can be used to delete a ref' ' ( cd victim && git branch extra master ) && git send-pack ./victim :extra master && ( cd victim && @@ -196,19 +195,6 @@ rewound_push_setup() { ) } -rewound_push_succeeded() { - cmp ../parent/.git/refs/heads/master .git/refs/heads/master -} - -rewound_push_failed() { - if rewound_push_succeeded - then - false - else - true - fi -} - test_expect_success 'pushing explicit refspecs respects forcing' ' rewound_push_setup && parent_orig=$(cd parent && git rev-parse --verify master) && diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index ac79dd915d..17c6330f98 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -1113,4 +1113,9 @@ test_extra_arg set-url origin newurl oldurl # prune takes any number of args # update takes any number of args +test_expect_success 'add remote matching the "insteadOf" URL' ' + git config url.xyz@example.com.insteadOf backup && + git remote add backup xyz@example.com +' + test_done diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index f4da20aa9b..e4436c1700 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1330,4 +1330,171 @@ test_expect_success 'fetch into bare respects core.logallrefupdates' ' ) ' +test_expect_success 'receive.denyCurrentBranch = updateInstead' ' + git push testrepo master && + ( + cd testrepo && + git reset --hard && + git config receive.denyCurrentBranch updateInstead + ) && + test_commit third path2 && + + # Try pushing into a repository with pristine working tree + git push testrepo master && + ( + cd testrepo && + git update-index -q --refresh && + git diff-files --quiet -- && + git diff-index --quiet --cached HEAD -- && + test third = "$(cat path2)" && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) && + + # Try pushing into a repository with working tree needing a refresh + ( + cd testrepo && + git reset --hard HEAD^ && + test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && + test-chmtime +100 path1 + ) && + git push testrepo master && + ( + cd testrepo && + git update-index -q --refresh && + git diff-files --quiet -- && + git diff-index --quiet --cached HEAD -- && + test_cmp ../path1 path1 && + test third = "$(cat path2)" && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) && + + # Update what is to be pushed + test_commit fourth path2 && + + # Try pushing into a repository with a dirty working tree + # (1) the working tree updated + ( + cd testrepo && + echo changed >path1 + ) && + test_must_fail git push testrepo master && + ( + cd testrepo && + test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && + git diff --quiet --cached && + test changed = "$(cat path1)" + ) && + + # (2) the index updated + ( + cd testrepo && + echo changed >path1 && + git add path1 + ) && + test_must_fail git push testrepo master && + ( + cd testrepo && + test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && + git diff --quiet && + test changed = "$(cat path1)" + ) && + + # Introduce a new file in the update + test_commit fifth path3 && + + # (3) the working tree has an untracked file that would interfere + ( + cd testrepo && + git reset --hard && + echo changed >path3 + ) && + test_must_fail git push testrepo master && + ( + cd testrepo && + test $(git -C .. rev-parse HEAD^^) = $(git rev-parse HEAD) && + git diff --quiet && + git diff --quiet --cached && + test changed = "$(cat path3)" + ) && + + # (4) the target changes to what gets pushed but it still is a change + ( + cd testrepo && + git reset --hard && + echo fifth >path3 && + git add path3 + ) && + test_must_fail git push testrepo master && + ( + cd testrepo && + test $(git -C .. rev-parse HEAD^^) = $(git rev-parse HEAD) && + git diff --quiet && + test fifth = "$(cat path3)" + ) + +' + +test_expect_success 'updateInstead with push-to-checkout hook' ' + rm -fr testrepo && + git init testrepo && + ( + cd testrepo && + git pull .. master && + git reset --hard HEAD^^ && + git tag initial && + git config receive.denyCurrentBranch updateInstead && + write_script .git/hooks/push-to-checkout <<-\EOF + echo >&2 updating from $(git rev-parse HEAD) + echo >&2 updating to "$1" + + git update-index -q --refresh && + git read-tree -u -m HEAD "$1" || { + status=$? + echo >&2 read-tree failed + exit $status + } + EOF + ) && + + # Try pushing into a pristine + git push testrepo master && + ( + cd testrepo && + git diff --quiet && + git diff HEAD --quiet && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) && + + # Try pushing into a repository with conflicting change + ( + cd testrepo && + git reset --hard initial && + echo conflicting >path2 + ) && + test_must_fail git push testrepo master && + ( + cd testrepo && + test $(git rev-parse initial) = $(git rev-parse HEAD) && + test conflicting = "$(cat path2)" && + git diff-index --quiet --cached HEAD + ) && + + # Try pushing into a repository with unrelated change + ( + cd testrepo && + git reset --hard initial && + echo unrelated >path1 && + echo irrelevant >path5 && + git add path5 + ) && + git push testrepo master && + ( + cd testrepo && + test "$(cat path1)" = unrelated && + test "$(cat path5)" = irrelevant && + test "$(git diff --name-only --cached HEAD)" = path5 && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) +' + test_done diff --git a/t/t5527-fetch-odd-refs.sh b/t/t5527-fetch-odd-refs.sh index edea9f957e..207899a99f 100755 --- a/t/t5527-fetch-odd-refs.sh +++ b/t/t5527-fetch-odd-refs.sh @@ -26,4 +26,37 @@ test_expect_success 'suffix ref is ignored during fetch' ' test_cmp expect actual ' +test_expect_success 'try to create repo with absurdly long refname' ' + ref240=$_z40/$_z40/$_z40/$_z40/$_z40/$_z40 && + ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 && + git init long && + ( + cd long && + test_commit long && + test_commit master + ) && + if git -C long update-ref refs/heads/$ref1440 long; then + test_set_prereq LONG_REF + else + echo >&2 "long refs not supported" + fi +' + +test_expect_success LONG_REF 'fetch handles extremely long refname' ' + git fetch long refs/heads/*:refs/remotes/long/* && + cat >expect <<-\EOF && + long + master + EOF + git for-each-ref --format="%(subject)" refs/remotes/long >actual && + test_cmp expect actual +' + +test_expect_success LONG_REF 'push handles extremely long refname' ' + git push long :refs/heads/$ref1440 && + git -C long for-each-ref --format="%(subject)" refs/heads >actual && + echo master >expect && + test_cmp expect actual +' + test_done diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh new file mode 100755 index 0000000000..3480b33007 --- /dev/null +++ b/t/t5543-atomic-push.sh @@ -0,0 +1,194 @@ +#!/bin/sh + +test_description='pushing to a repository using the atomic push option' + +. ./test-lib.sh + +mk_repo_pair () { + rm -rf workbench upstream && + test_create_repo upstream && + test_create_repo workbench && + ( + cd upstream && + git config receive.denyCurrentBranch warn + ) && + ( + cd workbench && + git remote add up ../upstream + ) +} + +# Compare the ref ($1) in upstream with a ref value from workbench ($2) +# i.e. test_refs second HEAD@{2} +test_refs () { + test $# = 2 && + git -C upstream rev-parse --verify "$1" >expect && + git -C workbench rev-parse --verify "$2" >actual && + test_cmp expect actual +} + +test_expect_success 'atomic push works for a single branch' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git push --mirror up && + test_commit two && + git push --atomic up master + ) && + test_refs master master +' + +test_expect_success 'atomic push works for two branches' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git branch second && + git push --mirror up && + test_commit two && + git checkout second && + test_commit three && + git push --atomic up master second + ) && + test_refs master master && + test_refs second second +' + +test_expect_success 'atomic push works in combination with --mirror' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second && + test_commit two && + git push --atomic --mirror up + ) && + test_refs master master && + test_refs second second +' + +test_expect_success 'atomic push works in combination with --force' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git branch second master && + test_commit two_a && + git checkout second && + test_commit two_b && + test_commit three_b && + test_commit four && + git push --mirror up && + # The actual test is below + git checkout master && + test_commit three_a && + git checkout second && + git reset --hard HEAD^ && + git push --force --atomic up master second + ) && + test_refs master master && + test_refs second second +' + +# set up two branches where master can be pushed but second can not +# (non-fast-forward). Since second can not be pushed the whole operation +# will fail and leave master untouched. +test_expect_success 'atomic push fails if one branch fails' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second master && + test_commit two && + test_commit three && + test_commit four && + git push --mirror up && + git reset --hard HEAD~2 && + test_commit five && + git checkout master && + test_commit six && + test_must_fail git push --atomic --all up + ) && + test_refs master HEAD@{7} && + test_refs second HEAD@{4} +' + +test_expect_success 'atomic push fails if one tag fails remotely' ' + # prepare the repo + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second master && + test_commit two && + git push --mirror up + ) && + # a third party modifies the server side: + ( + cd upstream && + git checkout second && + git tag test_tag second + ) && + # see if we can now push both branches. + ( + cd workbench && + git checkout master && + test_commit three && + git checkout second && + test_commit four && + git tag test_tag && + test_must_fail git push --tags --atomic up master second + ) && + test_refs master HEAD@{3} && + test_refs second HEAD@{1} +' + +test_expect_success 'atomic push obeys update hook preventing a branch to be pushed' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second master && + test_commit two && + git push --mirror up + ) && + ( + cd upstream && + HOOKDIR="$(git rev-parse --git-dir)/hooks" && + HOOK="$HOOKDIR/update" && + mkdir -p "$HOOKDIR" && + write_script "$HOOK" <<-\EOF + # only allow update to master from now on + test "$1" = "refs/heads/master" + EOF + ) && + ( + cd workbench && + git checkout master && + test_commit three && + git checkout second && + test_commit four && + test_must_fail git push --atomic up master second + ) && + test_refs master HEAD@{3} && + test_refs second HEAD@{1} +' + +test_expect_success 'atomic push is not advertised if configured' ' + mk_repo_pair && + ( + cd upstream + git config receive.advertiseatomic 0 + ) && + ( + cd workbench && + test_commit one && + git push --mirror up && + test_commit two && + test_must_fail git push --atomic up master + ) && + test_refs master HEAD@{1} +' + +test_done diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index ac71418a1b..2731ad4cea 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -165,6 +165,24 @@ test_expect_success 'fetch notices corrupt idx' ' ) ' +test_expect_success 'fetch can handle previously-fetched .idx files' ' + git checkout --orphan branch1 && + echo base >file && + git add file && + git commit -m base && + git --bare init "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git && + git push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch1 && + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d && + git checkout -b branch2 branch1 && + echo b2 >>file && + git commit -a -m b2 && + git push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch2 && + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d && + git --bare init clone_packed_branches.git && + git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 && + git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2 +' + test_expect_success 'did not use upload-pack service' ' grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act : >exp @@ -196,5 +214,47 @@ test_expect_success 'reencoding is robust to whitespace oddities' ' grep "this is the error message" stderr ' +check_language () { + case "$2" in + '') + >expect + ;; + ?*) + echo "Accept-Language: $1" >expect + ;; + esac && + GIT_CURL_VERBOSE=1 \ + LANGUAGE=$2 \ + git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 && + tr -d '\015' <output | + sort -u | + sed -ne '/^Accept-Language:/ p' >actual && + test_cmp expect actual +} + +test_expect_success 'git client sends Accept-Language based on LANGUAGE' ' + check_language "ko-KR, *;q=0.9" ko_KR.UTF-8' + +test_expect_success 'git client sends Accept-Language correctly with unordinary LANGUAGE' ' + check_language "ko-KR, *;q=0.9" "ko_KR:" && + check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR::en_US" && + check_language "ko-KR, *;q=0.9" ":::ko_KR" && + check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR!!:en_US" && + check_language "ko-KR, ja-JP;q=0.9, *;q=0.8" "ko_KR en_US:ja_JP"' + +test_expect_success 'git client sends Accept-Language with many preferred languages' ' + check_language "ko-KR, en-US;q=0.9, fr-CA;q=0.8, de;q=0.7, sr;q=0.6, \ +ja;q=0.5, zh;q=0.4, sv;q=0.3, pt;q=0.2, *;q=0.1" \ + ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt && + check_language "ko-KR, en-US;q=0.99, fr-CA;q=0.98, de;q=0.97, sr;q=0.96, \ +ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \ + ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt:nb +' + +test_expect_success 'git client does not send an empty Accept-Language' ' + GIT_CURL_VERBOSE=1 LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr && + ! grep "^Accept-Language:" stderr +' + stop_httpd test_done diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh index 6537911a43..3e783fc450 100755 --- a/t/t5700-clone-reference.sh +++ b/t/t5700-clone-reference.sh @@ -198,4 +198,21 @@ test_expect_success 'clone using repo pointed at by gitfile as reference' ' test_cmp expected "$base_dir/O/.git/objects/info/alternates" ' +test_expect_success 'clone and dissociate from reference' ' + git init P && + ( + cd P && test_commit one + ) && + git clone P Q && + ( + cd Q && test_commit two + ) && + git clone --no-local --reference=P Q R && + git clone --no-local --reference=P --dissociate Q S && + # removing the reference P would corrupt R but not S + rm -fr P && + test_must_fail git -C R fsck && + git -C S fsck +' + test_done diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 2419407546..c9d3ed14c3 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -281,4 +281,28 @@ test_expect_success 'push messages' ' ) ' +test_expect_success 'fetch HEAD' ' + (cd server && + git checkout master && + echo more >>file && + git commit -a -m more + ) && + (cd local && + git fetch origin HEAD + ) && + compare_refs server HEAD local FETCH_HEAD +' + +test_expect_success 'fetch url' ' + (cd server && + git checkout master && + echo more >>file && + git commit -a -m more + ) && + (cd local && + git fetch "testgit::${PWD}/../server" + ) && + compare_refs server HEAD local FETCH_HEAD +' + test_done diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 3758961765..190ee903cf 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -69,7 +69,8 @@ test_expect_success 'works in subdirectory' ' cp new1.txt dir/a.txt && cp orig.txt dir/o.txt && cp new2.txt dir/b.txt && - ( cd dir && git merge-file a.txt o.txt b.txt ) + ( cd dir && git merge-file a.txt o.txt b.txt ) && + test_path_is_missing a.txt ' cp new1.txt test.txt diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 064f5cefeb..e6abe65d5c 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -779,4 +779,13 @@ test_expect_success 'bisect log: only skip commits left' ' git bisect reset ' +test_expect_success '"git bisect bad HEAD" behaves as "git bisect bad"' ' + git checkout parallel && + git bisect start HEAD $HASH1 && + git bisect good HEAD && + git bisect bad HEAD && + test "$HASH6" = $(git rev-parse --verify HEAD) && + git bisect reset +' + test_done diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index bda354c1c4..c66bf7981c 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -334,6 +334,19 @@ test_expect_success 'Check that :track[short] cannot be used with other atoms' ' test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null ' +test_expect_success 'Check that :track[short] works when upstream is invalid' ' + cat >expected <<-\EOF && + + + EOF + test_when_finished "git config branch.master.merge refs/heads/master" && + git config branch.master.merge refs/heads/does-not-exist && + git for-each-ref \ + --format="%(upstream:track)$LF%(upstream:trackshort)" \ + refs/heads >actual && + test_cmp expected actual +' + cat >expected <<EOF $(git rev-parse --short HEAD) EOF diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 796e9f79ea..35c805a44e 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1081,7 +1081,7 @@ test_expect_success GPG \ get_tag_header rfc1991-signed-tag $commit commit $time >expect echo "RFC1991 signed tag" >>expect echo '-----BEGIN PGP MESSAGE-----' >>expect -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'creating a signed tag with rfc1991' ' echo "rfc1991" >gpghome/gpg.conf && git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit && @@ -1095,7 +1095,7 @@ cp "$1" actual EOF chmod +x fakeeditor -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'reediting a signed tag body omits signature' ' echo "rfc1991" >gpghome/gpg.conf && echo "RFC1991 signed tag" >expect && @@ -1103,13 +1103,13 @@ test_expect_success GPG \ test_cmp expect actual ' -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'verifying rfc1991 signature' ' echo "rfc1991" >gpghome/gpg.conf && git tag -v rfc1991-signed-tag ' -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'list tag with rfc1991 signature' ' echo "rfc1991" >gpghome/gpg.conf && echo "rfc1991-signed-tag RFC1991 signed tag" >expect && @@ -1123,12 +1123,12 @@ test_expect_success GPG \ rm -f gpghome/gpg.conf -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'verifying rfc1991 signature without --rfc1991' ' git tag -v rfc1991-signed-tag ' -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'list tag with rfc1991 signature without --rfc1991' ' echo "rfc1991-signed-tag RFC1991 signed tag" >expect && git tag -l -n1 rfc1991-signed-tag >actual && @@ -1139,7 +1139,7 @@ test_expect_success GPG \ test_cmp expect actual ' -test_expect_success GPG \ +test_expect_success GPG,RFC1991 \ 'reediting a signed tag body omits signature' ' echo "RFC1991 signed tag" >expect && GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit && diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 7c88245031..5811a982f4 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -171,6 +171,23 @@ test_expect_success 'submodule add with ./ in path' ' test_cmp empty untracked ' +test_expect_success 'submodule add with /././ in path' ' + echo "refs/heads/master" >expect && + >empty && + + ( + cd addtest && + git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ && + git submodule init + ) && + + rm -f heads head untracked && + inspect addtest/dotslashdotsubmod/frotz ../../.. && + test_cmp expect heads && + test_cmp expect head && + test_cmp empty untracked +' + test_expect_success 'submodule add with // in path' ' echo "refs/heads/master" >expect && >empty && diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index 1efb88051a..bd0ab46750 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -213,7 +213,7 @@ test_expect_success 'with 2 files arguments' ' ' test_expect_success 'with message that has comments' ' - cat basic_message >>message_with_comments && + cat basic_message >message_with_comments && sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF && # comment @@ -232,12 +232,44 @@ test_expect_success 'with message that has comments' ' Reviewed-by: Johan Cc: Peff + # last comment + EOF cat basic_patch >>expected && git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual && test_cmp expected actual ' +test_expect_success 'with message that has an old style conflict block' ' + cat basic_message >message_with_comments && + sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF && + # comment + + # other comment + Cc: Z + # yet another comment + Reviewed-by: Johan + Reviewed-by: Z + # last comment + + Conflicts: + + EOF + cat basic_message >expected && + cat >>expected <<-\EOF && + # comment + + Reviewed-by: Johan + Cc: Peff + # last comment + + Conflicts: + + EOF + git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual && + test_cmp expected actual +' + test_expect_success 'with commit complex message and trailer args' ' cat complex_message_body >expected && sed -e "s/ Z\$/ /" >>expected <<-\EOF && diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 19a3ced600..af6a3e8904 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -6,35 +6,37 @@ test_description='git send-email' # May be altered later in the test PREREQ="PERL" -test_expect_success $PREREQ \ - 'prepare reference tree' \ - 'echo "1A quick brown fox jumps over the" >file && - echo "lazy dog" >>file && - git add file && - GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' - -test_expect_success $PREREQ \ - 'Setup helper tool' \ - '(echo "#!$SHELL_PATH" - echo shift - echo output=1 - echo "while test -f commandline\$output; do output=\$((\$output+1)); done" - echo for a - echo do - echo " echo \"!\$a!\"" - echo "done >commandline\$output" - echo "cat > msgtxt\$output" - ) >fake.sendmail && - chmod +x ./fake.sendmail && - git add fake.sendmail && - GIT_AUTHOR_NAME="A" git commit -a -m "Second."' - -clean_fake_sendmail() { +test_expect_success $PREREQ 'prepare reference tree' ' + echo "1A quick brown fox jumps over the" >file && + echo "lazy dog" >>file && + git add file && + GIT_AUTHOR_NAME="A" git commit -a -m "Initial." +' + +test_expect_success $PREREQ 'Setup helper tool' ' + write_script fake.sendmail <<-\EOF && + shift + output=1 + while test -f commandline$output + do + output=$(($output+1)) + done + for a + do + echo "!$a!" + done >commandline$output + cat >"msgtxt$output" + EOF + git add fake.sendmail && + GIT_AUTHOR_NAME="A" git commit -a -m "Second." +' + +clean_fake_sendmail () { rm -f commandline* msgtxt* } test_expect_success $PREREQ 'Extract patches' ' - patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` + patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` ' # Test no confirm early to ensure remaining tests will not hang @@ -47,9 +49,9 @@ test_no_confirm () { --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $@ \ - $patches > stdout && + $patches >stdout && test_must_fail grep "Send this email" stdout && - > no_confirm_okay + >no_confirm_okay } # Exit immediately to prevent hang if a no-confirm test fails @@ -82,61 +84,61 @@ test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' ' ' test_expect_success $PREREQ 'Send patches' ' - git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors + git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' test_expect_success $PREREQ 'setup expect' ' -cat >expected <<\EOF -!nobody@example.com! -!author@example.com! -!one@example.com! -!two@example.com! -EOF + cat >expected <<-\EOF + !nobody@example.com! + !author@example.com! + !one@example.com! + !two@example.com! + EOF ' -test_expect_success $PREREQ \ - 'Verify commandline' \ - 'test_cmp expected commandline1' +test_expect_success $PREREQ 'Verify commandline' ' + test_cmp expected commandline1 +' test_expect_success $PREREQ 'Send patches with --envelope-sender' ' - clean_fake_sendmail && - git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors + clean_fake_sendmail && + git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' test_expect_success $PREREQ 'setup expect' ' -cat >expected <<\EOF -!patch@example.com! -!-i! -!nobody@example.com! -!author@example.com! -!one@example.com! -!two@example.com! -EOF + cat >expected <<-\EOF + !patch@example.com! + !-i! + !nobody@example.com! + !author@example.com! + !one@example.com! + !two@example.com! + EOF ' -test_expect_success $PREREQ \ - 'Verify commandline' \ - 'test_cmp expected commandline1' +test_expect_success $PREREQ 'Verify commandline' ' + test_cmp expected commandline1 +' test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' - clean_fake_sendmail && - git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors + clean_fake_sendmail && + git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' test_expect_success $PREREQ 'setup expect' ' -cat >expected <<\EOF -!nobody@example.com! -!-i! -!nobody@example.com! -!author@example.com! -!one@example.com! -!two@example.com! -EOF + cat >expected <<-\EOF + !nobody@example.com! + !-i! + !nobody@example.com! + !author@example.com! + !one@example.com! + !two@example.com! + EOF ' -test_expect_success $PREREQ \ - 'Verify commandline' \ - 'test_cmp expected commandline1' +test_expect_success $PREREQ 'Verify commandline' ' + test_cmp expected commandline1 +' test_expect_success $PREREQ 'setup expect' " cat >expected-show-all-headers <<\EOF @@ -240,6 +242,13 @@ test_expect_success $PREREQ 'non-ascii self name is suppressed' " 'non_ascii_self_suppressed' " +# This name is long enough to force format-patch to split it into multiple +# encoded-words, assuming it uses UTF-8 with the "Q" encoding. +test_expect_success $PREREQ 'long non-ascii self name is suppressed' " + test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \ + 'long_non_ascii_self_suppressed' +" + test_expect_success $PREREQ 'sanitized self name is suppressed' " test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \ 'self_name_sanitized_suppressed' @@ -307,11 +316,9 @@ test_expect_success $PREREQ 'tocmd works' ' clean_fake_sendmail && cp $patches tocmd.patch && echo tocmd--tocmd@example.com >>tocmd.patch && - { - echo "#!$SHELL_PATH" - echo sed -n -e s/^tocmd--//p \"\$1\" - } > tocmd-sed && - chmod +x tocmd-sed && + write_script tocmd-sed <<-\EOF && + sed -n -e "s/^tocmd--//p" "$1" + EOF git send-email \ --from="Example <nobody@example.com>" \ --to-cmd=./tocmd-sed \ @@ -325,11 +332,9 @@ test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch && echo "cccmd-- cccmd@example.com" >>cccmd.patch && - { - echo "#!$SHELL_PATH" - echo sed -n -e s/^cccmd--//p \"\$1\" - } > cccmd-sed && - chmod +x cccmd-sed && + write_script cccmd-sed <<-\EOF && + sed -n -e "s/^cccmd--//p" "$1" + EOF git send-email \ --from="Example <nobody@example.com>" \ --to=nobody@example.com \ @@ -367,7 +372,7 @@ test_expect_success $PREREQ 'Author From: in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^\$/d" < msgtxt1 > msgbody1 && + sed "1,/^\$/d" <msgtxt1 >msgbody1 && grep "From: A <author@example.com>" msgbody1 ' @@ -378,7 +383,7 @@ test_expect_success $PREREQ 'Author From: not in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^\$/d" < msgtxt1 > msgbody1 && + sed "1,/^\$/d" <msgtxt1 >msgbody1 && ! grep "From: A <author@example.com>" msgbody1 ' @@ -459,10 +464,9 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' ' test_expect_success $PREREQ 'setup fake editor' ' - (echo "#!$SHELL_PATH" && - echo "echo fake edit >>\"\$1\"" - ) >fake-editor && - chmod +x fake-editor + write_script fake-editor <<-\EOF + echo fake edit >>"$1" + EOF ' test_set_editor "$(pwd)/fake-editor" @@ -598,8 +602,9 @@ EOF " test_expect_success $PREREQ 'sendemail.cccmd' ' - echo echo cc-cmd@example.com > cccmd && - chmod +x cccmd && + write_script cccmd <<-\EOF && + echo cc-cmd@example.com + EOF git config sendemail.cccmd ./cccmd && test_suppression cccmd ' @@ -792,7 +797,7 @@ test_confirm () { --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - $@ $patches > stdout && + $@ $patches >stdout && grep "Send this email" stdout } @@ -840,7 +845,7 @@ test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - outdir/*.patch < /dev/null + outdir/*.patch </dev/null ret="$?" git config sendemail.confirm ${CONFIRM:-never} test $ret = "0" @@ -855,7 +860,7 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - $patches < /dev/null + $patches </dev/null ret="$?" git config sendemail.confirm ${CONFIRM:-never} test $ret = "0" @@ -891,39 +896,39 @@ test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' clean_fake_sendmail && - (echo "#!$SHELL_PATH" && - echo "echo utf8 body: àéìöú >>\"\$1\"" - ) >fake-editor-utf8 && - chmod +x fake-editor-utf8 && - GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ - git send-email \ - --compose --subject foo \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + write_script fake-editor-utf8 <<-\EOF && + echo "utf8 body: àéìöú" >>"$1" + EOF + GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ + git send-email \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^utf8 body" msgtxt1 && grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 ' test_expect_success $PREREQ '--compose respects user mime type' ' clean_fake_sendmail && - (echo "#!$SHELL_PATH" && - echo "(echo MIME-Version: 1.0" - echo " echo Content-Type: text/plain\\; charset=iso-8859-1" - echo " echo Content-Transfer-Encoding: 8bit" - echo " echo Subject: foo" - echo " echo " - echo " echo utf8 body: àéìöú) >\"\$1\"" - ) >fake-editor-utf8-mime && - chmod +x fake-editor-utf8-mime && - GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ - git send-email \ - --compose --subject foo \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + write_script fake-editor-utf8-mime <<-\EOF && + cat >"$1" <<-\EOM + MIME-Version: 1.0 + Content-Type: text/plain; charset=iso-8859-1 + Content-Transfer-Encoding: 8bit + Subject: foo + + utf8 body: àéìöú + EOM + EOF + GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ + git send-email \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^utf8 body" msgtxt1 && grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 @@ -931,13 +936,13 @@ test_expect_success $PREREQ '--compose respects user mime type' ' test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' clean_fake_sendmail && - GIT_EDITOR="\"$(pwd)/fake-editor\"" \ - git send-email \ - --compose --subject utf8-sübjëct \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + GIT_EDITOR="\"$(pwd)/fake-editor\"" \ + git send-email \ + --compose --subject utf8-sübjëct \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^fake edit" msgtxt1 && grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' @@ -949,9 +954,9 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' ' git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && git format-patch --stdout -1 >funny_name.patch && git send-email --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - funny_name.patch && + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + funny_name.patch && grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1 ' @@ -962,9 +967,9 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' ' git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && git format-patch --stdout -1 >funny_name.patch && git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - funny_name.patch && + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + funny_name.patch && grep "^From: " msgtxt1 >msgfrom && test_line_count = 1 msgfrom ' @@ -972,35 +977,33 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' ' test_expect_success $PREREQ 'sendemail.composeencoding works' ' clean_fake_sendmail && git config sendemail.composeencoding iso-8859-1 && - (echo "#!$SHELL_PATH" && - echo "echo utf8 body: àéìöú >>\"\$1\"" - ) >fake-editor-utf8 && - chmod +x fake-editor-utf8 && - GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ - git send-email \ - --compose --subject foo \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + write_script fake-editor-utf8 <<-\EOF && + echo "utf8 body: àéìöú" >>"$1" + EOF + GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ + git send-email \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^utf8 body" msgtxt1 && grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 ' test_expect_success $PREREQ '--compose-encoding works' ' clean_fake_sendmail && - (echo "#!$SHELL_PATH" && - echo "echo utf8 body: àéìöú >>\"\$1\"" - ) >fake-editor-utf8 && - chmod +x fake-editor-utf8 && - GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ - git send-email \ - --compose-encoding iso-8859-1 \ - --compose --subject foo \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + write_script fake-editor-utf8 <<-\EOF && + echo "utf8 body: àéìöú" >>"$1" + EOF + GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ + git send-email \ + --compose-encoding iso-8859-1 \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^utf8 body" msgtxt1 && grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 ' @@ -1008,38 +1011,37 @@ test_expect_success $PREREQ '--compose-encoding works' ' test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' ' clean_fake_sendmail && git config sendemail.composeencoding iso-8859-1 && - (echo "#!$SHELL_PATH" && - echo "echo utf8 body: àéìöú >>\"\$1\"" - ) >fake-editor-utf8 && - chmod +x fake-editor-utf8 && - GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ - git send-email \ - --compose-encoding iso-8859-2 \ - --compose --subject foo \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + write_script fake-editor-utf8 <<-\EOF && + echo "utf8 body: àéìöú" >>"$1" + EOF + GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ + git send-email \ + --compose-encoding iso-8859-2 \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^utf8 body" msgtxt1 && grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1 ' test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' ' clean_fake_sendmail && - GIT_EDITOR="\"$(pwd)/fake-editor\"" \ - git send-email \ - --compose-encoding iso-8859-2 \ - --compose --subject utf8-sübjëct \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches && + GIT_EDITOR="\"$(pwd)/fake-editor\"" \ + git send-email \ + --compose-encoding iso-8859-2 \ + --compose --subject utf8-sübjëct \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && grep "^fake edit" msgtxt1 && grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' - echo master > master && + echo master >master && git add master && git commit -m"add master" && test_must_fail git send-email --dry-run master 2>errors && @@ -1050,10 +1052,10 @@ test_expect_success $PREREQ 'feed two files' ' rm -fr outdir && git format-patch -2 -o outdir && git send-email \ - --dry-run \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - outdir/000?-*.patch 2>errors >out && + --dry-run \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + outdir/000?-*.patch 2>errors >out && grep "^Subject: " out >subjects && test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" @@ -1197,7 +1199,7 @@ test_expect_success $PREREQ 'To headers from files reset each patch' ' ' test_expect_success $PREREQ 'setup expect' ' -cat >email-using-8bit <<EOF +cat >email-using-8bit <<\EOF From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 Message-Id: <bogus-message-id@example.com> From: author@example.com @@ -1209,9 +1211,7 @@ EOF ' test_expect_success $PREREQ 'setup expect' ' -cat >expected <<EOF -Subject: subject goes here -EOF + echo "Subject: subject goes here" >expected ' test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' ' @@ -1226,11 +1226,11 @@ test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' ' ' test_expect_success $PREREQ 'setup expect' ' -cat >content-type-decl <<EOF -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -EOF + cat >content-type-decl <<-\EOF + MIME-Version: 1.0 + Content-Type: text/plain; charset=UTF-8 + Content-Transfer-Encoding: 8bit + EOF ' test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' @@ -1270,21 +1270,21 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' ' test_expect_success $PREREQ 'setup expect' ' -cat >email-using-8bit <<EOF -From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 -Message-Id: <bogus-message-id@example.com> -From: author@example.com -Date: Sat, 12 Jun 2010 15:53:58 +0200 -Subject: Dieser Betreff enthält auch einen Umlaut! - -Nothing to see here. -EOF + cat >email-using-8bit <<-\EOF + From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 + Message-Id: <bogus-message-id@example.com> + From: author@example.com + Date: Sat, 12 Jun 2010 15:53:58 +0200 + Subject: Dieser Betreff enthält auch einen Umlaut! + + Nothing to see here. + EOF ' test_expect_success $PREREQ 'setup expect' ' -cat >expected <<EOF -Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= -EOF + cat >expected <<-\EOF + Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= + EOF ' test_expect_success $PREREQ '--8bit-encoding also treats subject' ' @@ -1298,6 +1298,163 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' ' test_cmp expected actual ' +test_expect_success $PREREQ 'setup expect' ' + cat >email-using-8bit <<-\EOF + From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 + Message-Id: <bogus-message-id@example.com> + From: A U Thor <author@example.com> + Date: Sat, 12 Jun 2010 15:53:58 +0200 + Content-Type: text/plain; charset=UTF-8 + Subject: Nothing to see here. + + Dieser Betreff enthält auch einen Umlaut! + EOF +' + +test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' ' + clean_fake_sendmail && + git config sendemail.transferEncoding 7bit && + test_must_fail git send-email \ + --transfer-encoding=7bit \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit \ + 2>errors >out && + grep "cannot send message as 7bit" errors && + test -z "$(ls msgtxt*)" +' + +test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' ' + clean_fake_sendmail && + git config sendemail.transferEncoding 8bit + test_must_fail git send-email \ + --transfer-encoding=7bit \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit \ + 2>errors >out && + grep "cannot send message as 7bit" errors && + test -z "$(ls msgtxt*)" +' + +test_expect_success $PREREQ 'sendemail.transferencoding=8bit' ' + clean_fake_sendmail && + git send-email \ + --transfer-encoding=8bit \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit \ + 2>errors >out && + sed '1,/^$/d' msgtxt1 >actual && + sed '1,/^$/d' email-using-8bit >expected && + test_cmp expected actual +' + +test_expect_success $PREREQ 'setup expect' ' + cat >expected <<-\EOF + Dieser Betreff enth=C3=A4lt auch einen Umlaut! + EOF +' + +test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' ' + clean_fake_sendmail && + git send-email \ + --transfer-encoding=quoted-printable \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit \ + 2>errors >out && + sed '1,/^$/d' msgtxt1 >actual && + test_cmp expected actual +' + +test_expect_success $PREREQ 'setup expect' ' + cat >expected <<-\EOF + RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg== + EOF +' + +test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' ' + clean_fake_sendmail && + git send-email \ + --transfer-encoding=base64 \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit \ + 2>errors >out && + sed '1,/^$/d' msgtxt1 >actual && + test_cmp expected actual +' + +test_expect_success $PREREQ 'setup expect' ' + cat >email-using-qp <<-\EOF + From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 + Message-Id: <bogus-message-id@example.com> + From: A U Thor <author@example.com> + Date: Sat, 12 Jun 2010 15:53:58 +0200 + MIME-Version: 1.0 + Content-Transfer-Encoding: quoted-printable + Content-Type: text/plain; charset=UTF-8 + Subject: Nothing to see here. + + Dieser Betreff enth=C3=A4lt auch einen Umlaut! + EOF +' + +test_expect_success $PREREQ 'convert from quoted-printable to base64' ' + clean_fake_sendmail && + git send-email \ + --transfer-encoding=base64 \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-qp \ + 2>errors >out && + sed '1,/^$/d' msgtxt1 >actual && + test_cmp expected actual +' + +test_expect_success $PREREQ 'setup expect' " +tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF +From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 +Message-Id: <bogus-message-id@example.com> +From: A U Thor <author@example.com> +Date: Sat, 12 Jun 2010 15:53:58 +0200 +Content-Type: text/plain; charset=UTF-8 +Subject: Nothing to see here. + +Look, I have a CRLF and an = sign!% +EOF +" + +test_expect_success $PREREQ 'setup expect' ' + cat >expected <<-\EOF + Look, I have a CRLF and an =3D sign!=0D + EOF +' + +test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' ' + clean_fake_sendmail && + git send-email \ + --transfer-encoding=quoted-printable \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-crlf \ + 2>errors >out && + sed '1,/^$/d' msgtxt1 >actual && + test_cmp expected actual +' + +test_expect_success $PREREQ 'setup expect' ' + cat >expected <<-\EOF + TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K + EOF +' + +test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' ' + clean_fake_sendmail && + git send-email \ + --transfer-encoding=base64 \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-crlf \ + 2>errors >out && + sed '1,/^$/d' msgtxt1 >actual && + test_cmp expected actual +' + + # Note that the patches in this test are deliberately out of order; we # want to make sure it works even if the cover-letter is not in the # first mail. @@ -1306,13 +1463,13 @@ test_expect_success $PREREQ 'refusing to send cover letter template' ' rm -fr outdir && git format-patch --cover-letter -2 -o outdir && test_must_fail git send-email \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - outdir/0002-*.patch \ - outdir/0000-*.patch \ - outdir/0001-*.patch \ - 2>errors >out && + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0002-*.patch \ + outdir/0000-*.patch \ + outdir/0001-*.patch \ + 2>errors >out && grep "SUBJECT HERE" errors && test -z "$(ls msgtxt*)" ' @@ -1322,14 +1479,14 @@ test_expect_success $PREREQ '--force sends cover letter template anyway' ' rm -fr outdir && git format-patch --cover-letter -2 -o outdir && git send-email \ - --force \ - --from="Example <nobody@example.com>" \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - outdir/0002-*.patch \ - outdir/0000-*.patch \ - outdir/0001-*.patch \ - 2>errors >out && + --force \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0002-*.patch \ + outdir/0000-*.patch \ + outdir/0001-*.patch \ + 2>errors >out && ! grep "SUBJECT HERE" errors && test -n "$(ls msgtxt*)" ' @@ -1344,15 +1501,15 @@ test_cover_addresses () { mv $cover cover-to-edit.patch && perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" && git send-email \ - --force \ - --from="Example <nobody@example.com>" \ - --no-to --no-cc \ - "$@" \ - --smtp-server="$(pwd)/fake.sendmail" \ - outdir/0000-*.patch \ - outdir/0001-*.patch \ - outdir/0002-*.patch \ - 2>errors >out && + --force \ + --from="Example <nobody@example.com>" \ + --no-to --no-cc \ + "$@" \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0000-*.patch \ + outdir/0001-*.patch \ + outdir/0002-*.patch \ + 2>errors >out && grep "^$header: extra@address.com" msgtxt1 >to1 && grep "^$header: extra@address.com" msgtxt2 >to2 && grep "^$header: extra@address.com" msgtxt3 >to3 && @@ -1385,11 +1542,11 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' ' git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" && git config sendemail.aliasfiletype mailrc && git send-email \ - --from="Example <nobody@example.com>" \ - --to=sbd \ - --smtp-server="$(pwd)/fake.sendmail" \ - outdir/0001-*.patch \ - 2>errors >out && + --from="Example <nobody@example.com>" \ + --to=sbd \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0001-*.patch \ + 2>errors >out && grep "^!somebody@example\.org!$" commandline1 ' @@ -1399,12 +1556,45 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' ' git config --replace-all sendemail.aliasesfile "~/.mailrc" && git config sendemail.aliasfiletype mailrc && git send-email \ - --from="Example <nobody@example.com>" \ - --to=sbd \ - --smtp-server="$(pwd)/fake.sendmail" \ - outdir/0001-*.patch \ - 2>errors >out && + --from="Example <nobody@example.com>" \ + --to=sbd \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0001-*.patch \ + 2>errors >out && grep "^!someone@example\.org!$" commandline1 ' +do_xmailer_test () { + expected=$1 params=$2 && + git format-patch -1 && + git send-email \ + --from="Example <nobody@example.com>" \ + --to=someone@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $params \ + 0001-*.patch \ + 2>errors >out && + { grep '^X-Mailer:' out || :; } >mailer && + test_line_count = $expected mailer +} + +test_expect_success $PREREQ '--[no-]xmailer without any configuration' ' + do_xmailer_test 1 "--xmailer" && + do_xmailer_test 0 "--no-xmailer" +' + +test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' ' + test_config sendemail.xmailer true && + do_xmailer_test 1 "" && + do_xmailer_test 0 "--no-xmailer" && + do_xmailer_test 1 "--xmailer" +' + +test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' ' + test_config sendemail.xmailer false && + do_xmailer_test 0 "" && + do_xmailer_test 0 "--no-xmailer" && + do_xmailer_test 1 "--xmailer" +' + test_done diff --git a/t/t9148-git-svn-propset.sh b/t/t9148-git-svn-propset.sh new file mode 100755 index 0000000000..102639090c --- /dev/null +++ b/t/t9148-git-svn-propset.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# +# Copyright (c) 2014 Alfred Perlstein +# + +test_description='git svn propset tests' + +. ./lib-git-svn.sh + +foo_subdir2="subdir/subdir2/foo_subdir2" + +set -e +mkdir import && +(set -e ; cd import + mkdir subdir + mkdir subdir/subdir2 + touch foo # for 'add props top level' + touch subdir/foo_subdir # for 'add props relative' + touch "$foo_subdir2" # for 'add props subdir' + svn_cmd import -m 'import for git svn' . "$svnrepo" >/dev/null +) +rm -rf import + +test_expect_success 'initialize git svn' ' + git svn init "$svnrepo" + ' + +test_expect_success 'fetch revisions from svn' ' + git svn fetch + ' + +set_props () { + subdir="$1" + file="$2" + shift;shift; + (cd "$subdir" && + while [ $# -gt 0 ] ; do + git svn propset "$1" "$2" "$file" || exit 1 + shift;shift; + done && + echo hello >> "$file" && + git commit -m "testing propset" "$file") +} + +confirm_props () { + subdir="$1" + file="$2" + shift;shift; + (set -e ; cd "svn_project/$subdir" && + while [ $# -gt 0 ] ; do + test "$(svn_cmd propget "$1" "$file")" = "$2" || exit 1 + shift;shift; + done) +} + + +#The current implementation has a restriction: +#svn propset will be taken as a delta for svn dcommit only +#if the file content is also modified +test_expect_success 'add props top level' ' + set_props "." "foo" "svn:keywords" "FreeBSD=%H" && + git svn dcommit && + svn_cmd co "$svnrepo" svn_project && + confirm_props "." "foo" "svn:keywords" "FreeBSD=%H" && + rm -rf svn_project + ' + +test_expect_success 'add multiple props' ' + set_props "." "foo" \ + "svn:keywords" "FreeBSD=%H" fbsd:nokeywords yes && + git svn dcommit && + svn_cmd co "$svnrepo" svn_project && + confirm_props "." "foo" \ + "svn:keywords" "FreeBSD=%H" fbsd:nokeywords yes && + rm -rf svn_project + ' + +test_expect_success 'add props subdir' ' + set_props "." "$foo_subdir2" svn:keywords "FreeBSD=%H" && + git svn dcommit && + svn_cmd co "$svnrepo" svn_project && + confirm_props "." "$foo_subdir2" "svn:keywords" "FreeBSD=%H" && + rm -rf svn_project + ' + +test_expect_success 'add props relative' ' + set_props "subdir/subdir2" "../foo_subdir" \ + svn:keywords "FreeBSD=%H" && + git svn dcommit && + svn_cmd co "$svnrepo" svn_project && + confirm_props "subdir/subdir2" "../foo_subdir" \ + svn:keywords "FreeBSD=%H" && + rm -rf svn_project + ' +test_done diff --git a/t/t9817-git-p4-exclude.sh b/t/t9817-git-p4-exclude.sh new file mode 100755 index 0000000000..aac568eadf --- /dev/null +++ b/t/t9817-git-p4-exclude.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +test_description='git p4 tests for excluded paths during clone and sync' + +. ./lib-git-p4.sh + +test_expect_success 'start p4d' ' + start_p4d +' + +# Create a repo with the structure: +# +# //depot/wanted/foo +# //depot/discard/foo +# +# Check that we can exclude a subdirectory with both +# clone and sync operations. + +test_expect_success 'create exclude repo' ' + ( + cd "$cli" && + mkdir -p wanted discard && + echo wanted >wanted/foo && + echo discard >discard/foo && + p4 add wanted/foo discard/foo && + p4 submit -d "initial revision" + ) +' + +test_expect_success 'check the repo was created correctly' ' + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot/...@all && + ( + cd "$git" && + test_path_is_file wanted/foo && + test_path_is_file discard/foo + ) +' + +test_expect_success 'clone, excluding part of repo' ' + test_when_finished cleanup_git && + git p4 clone -//depot/discard/... --dest="$git" //depot/...@all && + ( + cd "$git" && + test_path_is_file wanted/foo && + test_path_is_missing discard/foo + ) +' + +test_expect_success 'clone, then sync with exclude' ' + test_when_finished cleanup_git && + git p4 clone -//depot/discard/... --dest="$git" //depot/...@all && + ( + cd "$cli" && + p4 edit wanted/foo discard/foo && + date >>wanted/foo && + date >>discard/foo && + p4 submit -d "updating" && + + cd "$git" && + git p4 sync -//depot/discard/... && + test_path_is_file wanted/foo && + test_path_is_missing discard/foo + ) +' + +test_expect_success 'kill p4d' ' + kill_p4d +' + +test_done diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 9150984184..51ecd3e4c1 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -35,6 +35,8 @@ test_expect_success 'setup for prompt tests' ' git commit -m "another b2" file && echo 000 >file && git commit -m "yet another b2" file && + mkdir ignored_dir && + echo "ignored_dir/" >>.gitignore && git checkout master ' @@ -588,4 +590,108 @@ test_expect_success 'prompt - zsh color pc mode' ' test_cmp expected "$actual" ' +test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' ' + printf " (master)" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' ' + printf " (master)" >expected && + ( + cd ignored_dir && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + ( + cd ignored_dir && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' ' + printf " (master)" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' + printf "" >expected && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' ' + printf "BEFORE::AFTER" >expected && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stdout)' ' + printf " (GIT_DIR!)" >expected && + ( + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + cd .git && + __git_ps1 >"$actual" 2>/dev/null + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stderr)' ' + printf "" >expected && + ( + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + cd .git && + __git_ps1 >/dev/null 2>"$actual" + ) && + test_cmp expected "$actual" +' + test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index 79e8a33d04..bb1402de94 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -140,6 +140,9 @@ else } fi +: ${ASAN_OPTIONS=detect_leaks=0} +export ASAN_OPTIONS + # Protect ourselves from common misconfiguration to export # CDPATH into the environment unset CDPATH @@ -181,16 +184,8 @@ export _x05 _x40 _z40 LF u200c # This test checks if command xyzzy does the right thing... # ' # . ./test-lib.sh -[ "x$ORIGINAL_TERM" != "xdumb" ] && ( - TERM=$ORIGINAL_TERM && - export TERM && - [ -t 1 ] && - tput bold >/dev/null 2>&1 && - tput setaf 1 >/dev/null 2>&1 && - tput sgr0 >/dev/null 2>&1 - ) && - color=t +unset color while test "$#" -ne 0 do case "$1" in @@ -255,40 +250,6 @@ then verbose=t fi -if test -n "$color" -then - say_color () { - ( - TERM=$ORIGINAL_TERM - export TERM - case "$1" in - error) - tput bold; tput setaf 1;; # bold red - skip) - tput setaf 4;; # blue - warn) - tput setaf 3;; # brown/yellow - pass) - tput setaf 2;; # green - info) - tput setaf 6;; # cyan - *) - test -n "$quiet" && return;; - esac - shift - printf "%s" "$*" - tput sgr0 - echo - ) - } -else - say_color() { - test -z "$1" && test -n "$quiet" && return - shift - printf "%s\n" "$*" - } -fi - error () { say_color error "error: $*" GIT_EXIT_OK=t @@ -681,7 +642,7 @@ test_done () { then error "Can't use skip_all after running some tests" fi - [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" + test -z "$skip_all" || skip_all=" # SKIP $skip_all" if test $test_external_has_tap -eq 0 then @@ -854,6 +815,52 @@ HOME="$TRASH_DIRECTORY" GNUPGHOME="$HOME/gnupg-home-not-used" export HOME GNUPGHOME +# run the tput tests *after* changing HOME (in case ncurses needs +# ~/.terminfo for $TERM) +test -n "${color+set}" || test "x$ORIGINAL_TERM" != "xdumb" && ( + TERM=$ORIGINAL_TERM && + export TERM && + test -t 1 && + tput bold >/dev/null 2>&1 && + tput setaf 1 >/dev/null 2>&1 && + tput sgr0 >/dev/null 2>&1 + ) && + color=t + +if test -n "$color" +then + say_color () { + ( + TERM=$ORIGINAL_TERM + export TERM + case "$1" in + error) + tput bold; tput setaf 1;; # bold red + skip) + tput setaf 4;; # blue + warn) + tput setaf 3;; # brown/yellow + pass) + tput setaf 2;; # green + info) + tput setaf 6;; # cyan + *) + test -n "$quiet" && return;; + esac + shift + printf "%s" "$*" + tput sgr0 + echo + ) + } +else + say_color() { + test -z "$1" && test -n "$quiet" && return + shift + printf "%s\n" "$*" + } +fi + if test -z "$TEST_NO_CREATE_REPO" then test_create_repo "$TRASH_DIRECTORY" |