t / t5538-push-shallow.shon commit clean: replace match_pathspec() with dir_path_match() (05b8502)
   1#!/bin/sh
   2
   3test_description='push from/to a shallow clone'
   4
   5. ./test-lib.sh
   6
   7commit() {
   8        echo "$1" >tracked &&
   9        git add tracked &&
  10        git commit -m "$1"
  11}
  12
  13test_expect_success 'setup' '
  14        git config --global transfer.fsckObjects true &&
  15        commit 1 &&
  16        commit 2 &&
  17        commit 3 &&
  18        commit 4 &&
  19        git clone . full &&
  20        (
  21        git init full-abc &&
  22        cd full-abc &&
  23        commit a &&
  24        commit b &&
  25        commit c
  26        ) &&
  27        git clone --no-local --depth=2 .git shallow &&
  28        git --git-dir=shallow/.git log --format=%s >actual &&
  29        cat <<EOF >expect &&
  304
  313
  32EOF
  33        test_cmp expect actual &&
  34        git clone --no-local --depth=2 full-abc/.git shallow2 &&
  35        git --git-dir=shallow2/.git log --format=%s >actual &&
  36        cat <<EOF >expect &&
  37c
  38b
  39EOF
  40        test_cmp expect actual
  41'
  42
  43test_expect_success 'push from shallow clone' '
  44        (
  45        cd shallow &&
  46        commit 5 &&
  47        git push ../.git +master:refs/remotes/shallow/master
  48        ) &&
  49        git log --format=%s shallow/master >actual &&
  50        git fsck &&
  51        cat <<EOF >expect &&
  525
  534
  543
  552
  561
  57EOF
  58        test_cmp expect actual
  59'
  60
  61test_expect_success 'push from shallow clone, with grafted roots' '
  62        (
  63        cd shallow2 &&
  64        test_must_fail git push ../.git +master:refs/remotes/shallow2/master 2>err &&
  65        grep "shallow2/master.*shallow update not allowed" err
  66        ) &&
  67        test_must_fail git rev-parse shallow2/master &&
  68        git fsck
  69'
  70
  71test_expect_success 'add new shallow root with receive.updateshallow on' '
  72        test_config receive.shallowupdate true &&
  73        (
  74        cd shallow2 &&
  75        git push ../.git +master:refs/remotes/shallow2/master
  76        ) &&
  77        git log --format=%s shallow2/master >actual &&
  78        git fsck &&
  79        cat <<EOF >expect &&
  80c
  81b
  82EOF
  83        test_cmp expect actual
  84'
  85
  86test_expect_success 'push from shallow to shallow' '
  87        (
  88        cd shallow &&
  89        git --git-dir=../shallow2/.git config receive.shallowupdate true &&
  90        git push ../shallow2/.git +master:refs/remotes/shallow/master &&
  91        git --git-dir=../shallow2/.git config receive.shallowupdate false
  92        ) &&
  93        (
  94        cd shallow2 &&
  95        git log --format=%s shallow/master >actual &&
  96        git fsck &&
  97        cat <<EOF >expect &&
  985
  994
 1003
 101EOF
 102        test_cmp expect actual
 103        )
 104'
 105
 106test_expect_success 'push from full to shallow' '
 107        ! git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object --stdin` &&
 108        commit 1 &&
 109        git push shallow2/.git +master:refs/remotes/top/master &&
 110        (
 111        cd shallow2 &&
 112        git log --format=%s top/master >actual &&
 113        git fsck &&
 114        cat <<EOF >expect &&
 1151
 1164
 1173
 118EOF
 119        test_cmp expect actual &&
 120        git cat-file blob `echo 1|git hash-object --stdin` >/dev/null
 121        )
 122'
 123
 124if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then
 125        say 'skipping remaining tests, git built without http support'
 126        test_done
 127fi
 128
 129LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5537'}
 130. "$TEST_DIRECTORY"/lib-httpd.sh
 131start_httpd
 132
 133test_expect_success 'push to shallow repo via http' '
 134        git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 135        (
 136        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 137        git config http.receivepack true
 138        ) &&
 139        (
 140        cd full &&
 141        commit 9 &&
 142        git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master
 143        ) &&
 144        (
 145        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 146        git fsck &&
 147        git log --format=%s top/master >actual &&
 148        cat <<EOF >expect &&
 1499
 1504
 1513
 152EOF
 153        test_cmp expect actual
 154        )
 155'
 156
 157test_expect_success 'push from shallow repo via http' '
 158        mv "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" shallow-upstream.git &&
 159        git clone --bare --no-local full "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 160        (
 161        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 162        git config http.receivepack true
 163        ) &&
 164        commit 10 &&
 165        git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master &&
 166        (
 167        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 168        git fsck &&
 169        git log --format=%s top/master >actual &&
 170        cat <<EOF >expect &&
 17110
 1721
 1734
 1743
 1752
 1761
 177EOF
 178        test_cmp expect actual
 179        )
 180'
 181
 182stop_httpd
 183test_done