t / t5504-fetch-receive-strict.shon commit t/t7003-filter-branch.sh: use the $( ... ) construct for command substitution (9948519)
   1#!/bin/sh
   2
   3test_description='fetch/receive strict mode'
   4. ./test-lib.sh
   5
   6test_expect_success setup '
   7        echo hello >greetings &&
   8        git add greetings &&
   9        git commit -m greetings &&
  10
  11        S=$(git rev-parse :greetings | sed -e "s|^..|&/|") &&
  12        X=$(echo bye | git hash-object -w --stdin | sed -e "s|^..|&/|") &&
  13        mv -f .git/objects/$X .git/objects/$S &&
  14
  15        test_must_fail git fsck
  16'
  17
  18test_expect_success 'fetch without strict' '
  19        rm -rf dst &&
  20        git init dst &&
  21        (
  22                cd dst &&
  23                git config fetch.fsckobjects false &&
  24                git config transfer.fsckobjects false &&
  25                test_must_fail git fetch ../.git master
  26        )
  27'
  28
  29test_expect_success 'fetch with !fetch.fsckobjects' '
  30        rm -rf dst &&
  31        git init dst &&
  32        (
  33                cd dst &&
  34                git config fetch.fsckobjects false &&
  35                git config transfer.fsckobjects true &&
  36                test_must_fail git fetch ../.git master
  37        )
  38'
  39
  40test_expect_success 'fetch with fetch.fsckobjects' '
  41        rm -rf dst &&
  42        git init dst &&
  43        (
  44                cd dst &&
  45                git config fetch.fsckobjects true &&
  46                git config transfer.fsckobjects false &&
  47                test_must_fail git fetch ../.git master
  48        )
  49'
  50
  51test_expect_success 'fetch with transfer.fsckobjects' '
  52        rm -rf dst &&
  53        git init dst &&
  54        (
  55                cd dst &&
  56                git config transfer.fsckobjects true &&
  57                test_must_fail git fetch ../.git master
  58        )
  59'
  60
  61cat >exp <<EOF
  62To dst
  63!       refs/heads/master:refs/heads/test       [remote rejected] (missing necessary objects)
  64EOF
  65
  66test_expect_success 'push without strict' '
  67        rm -rf dst &&
  68        git init dst &&
  69        (
  70                cd dst &&
  71                git config fetch.fsckobjects false &&
  72                git config transfer.fsckobjects false
  73        ) &&
  74        test_must_fail git push --porcelain dst master:refs/heads/test >act &&
  75        test_cmp exp act
  76'
  77
  78test_expect_success 'push with !receive.fsckobjects' '
  79        rm -rf dst &&
  80        git init dst &&
  81        (
  82                cd dst &&
  83                git config receive.fsckobjects false &&
  84                git config transfer.fsckobjects true
  85        ) &&
  86        test_must_fail git push --porcelain dst master:refs/heads/test >act &&
  87        test_cmp exp act
  88'
  89
  90cat >exp <<EOF
  91To dst
  92!       refs/heads/master:refs/heads/test       [remote rejected] (unpacker error)
  93EOF
  94
  95test_expect_success 'push with receive.fsckobjects' '
  96        rm -rf dst &&
  97        git init dst &&
  98        (
  99                cd dst &&
 100                git config receive.fsckobjects true &&
 101                git config transfer.fsckobjects false
 102        ) &&
 103        test_must_fail ok=sigpipe git push --porcelain dst master:refs/heads/test >act &&
 104        test_cmp exp act
 105'
 106
 107test_expect_success 'push with transfer.fsckobjects' '
 108        rm -rf dst &&
 109        git init dst &&
 110        (
 111                cd dst &&
 112                git config transfer.fsckobjects true
 113        ) &&
 114        test_must_fail ok=sigpipe git push --porcelain dst master:refs/heads/test >act
 115'
 116
 117cat >bogus-commit <<\EOF
 118tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
 119author Bugs Bunny 1234567890 +0000
 120committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
 121
 122This commit object intentionally broken
 123EOF
 124
 125test_expect_success 'push with receive.fsck.skipList' '
 126        commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
 127        git push . $commit:refs/heads/bogus &&
 128        rm -rf dst &&
 129        git init dst &&
 130        git --git-dir=dst/.git config receive.fsckObjects true &&
 131        test_must_fail git push --porcelain dst bogus &&
 132        git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
 133        echo $commit >dst/.git/SKIP &&
 134        git push --porcelain dst bogus
 135'
 136
 137test_expect_success 'push with receive.fsck.missingEmail=warn' '
 138        commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
 139        git push . $commit:refs/heads/bogus &&
 140        rm -rf dst &&
 141        git init dst &&
 142        git --git-dir=dst/.git config receive.fsckobjects true &&
 143        test_must_fail git push --porcelain dst bogus &&
 144        git --git-dir=dst/.git config \
 145                receive.fsck.missingEmail warn &&
 146        git push --porcelain dst bogus >act 2>&1 &&
 147        grep "missingEmail" act &&
 148        git --git-dir=dst/.git branch -D bogus &&
 149        git --git-dir=dst/.git config --add \
 150                receive.fsck.missingEmail ignore &&
 151        git --git-dir=dst/.git config --add \
 152                receive.fsck.badDate warn &&
 153        git push --porcelain dst bogus >act 2>&1 &&
 154        test_must_fail grep "missingEmail" act
 155'
 156
 157test_expect_success \
 158        'receive.fsck.unterminatedHeader=warn triggers error' '
 159        rm -rf dst &&
 160        git init dst &&
 161        git --git-dir=dst/.git config receive.fsckobjects true &&
 162        git --git-dir=dst/.git config \
 163                receive.fsck.unterminatedheader warn &&
 164        test_must_fail git push --porcelain dst HEAD >act 2>&1 &&
 165        grep "Cannot demote unterminatedheader" act
 166'
 167
 168test_done