t / t5542-push-http-shallow.shon commit t1500: avoid changing working directory outside of tests (1e043cf)
   1#!/bin/sh
   2
   3test_description='push from/to a shallow clone over http'
   4
   5. ./test-lib.sh
   6. "$TEST_DIRECTORY"/lib-httpd.sh
   7start_httpd
   8
   9commit() {
  10        echo "$1" >tracked &&
  11        git add tracked &&
  12        git commit -m "$1"
  13}
  14
  15test_expect_success 'setup' '
  16        git config --global transfer.fsckObjects true &&
  17        commit 1 &&
  18        commit 2 &&
  19        commit 3 &&
  20        commit 4 &&
  21        git clone . full &&
  22        (
  23        git init full-abc &&
  24        cd full-abc &&
  25        commit a &&
  26        commit b &&
  27        commit c
  28        ) &&
  29        git clone --no-local --depth=2 .git shallow &&
  30        git --git-dir=shallow/.git log --format=%s >actual &&
  31        cat <<EOF >expect &&
  324
  333
  34EOF
  35        test_cmp expect actual &&
  36        git clone --no-local --depth=2 full-abc/.git shallow2 &&
  37        git --git-dir=shallow2/.git log --format=%s >actual &&
  38        cat <<EOF >expect &&
  39c
  40b
  41EOF
  42        test_cmp expect actual
  43'
  44
  45test_expect_success 'push to shallow repo via http' '
  46        git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  47        (
  48        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  49        git config http.receivepack true
  50        ) &&
  51        (
  52        cd full &&
  53        commit 9 &&
  54        git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master
  55        ) &&
  56        (
  57        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  58        git fsck &&
  59        git log --format=%s top/master >actual &&
  60        cat <<EOF >expect &&
  619
  624
  633
  64EOF
  65        test_cmp expect actual
  66        )
  67'
  68
  69test_expect_success 'push from shallow repo via http' '
  70        mv "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" shallow-upstream.git &&
  71        git clone --bare --no-local full "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  72        (
  73        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  74        git config http.receivepack true
  75        ) &&
  76        commit 10 &&
  77        git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master &&
  78        (
  79        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  80        git fsck &&
  81        git log --format=%s top/master >actual &&
  82        cat <<EOF >expect &&
  8310
  844
  853
  862
  871
  88EOF
  89        test_cmp expect actual
  90        )
  91'
  92
  93stop_httpd
  94test_done