t / t5540-http-push.shon commit fix simple deepening of a repo (8638682)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
   4#
   5
   6test_description='test http-push
   7
   8This test runs various sanity checks on http-push.'
   9
  10. ./test-lib.sh
  11
  12ROOT_PATH="$PWD"
  13LIB_HTTPD_DAV=t
  14LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
  15
  16if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
  17then
  18        say "skipping test, USE_CURL_MULTI is not defined"
  19        test_done
  20fi
  21
  22. "$TEST_DIRECTORY"/lib-httpd.sh
  23start_httpd
  24
  25test_expect_success 'setup remote repository' '
  26        cd "$ROOT_PATH" &&
  27        mkdir test_repo &&
  28        cd test_repo &&
  29        git init &&
  30        : >path1 &&
  31        git add path1 &&
  32        test_tick &&
  33        git commit -m initial &&
  34        cd - &&
  35        git clone --bare test_repo test_repo.git &&
  36        cd test_repo.git &&
  37        git --bare update-server-info &&
  38        mv hooks/post-update.sample hooks/post-update &&
  39        cd - &&
  40        mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
  41'
  42
  43test_expect_success 'clone remote repository' '
  44        cd "$ROOT_PATH" &&
  45        git clone $HTTPD_URL/test_repo.git test_repo_clone
  46'
  47
  48test_expect_failure 'push to remote repository with packed refs' '
  49        cd "$ROOT_PATH"/test_repo_clone &&
  50        : >path2 &&
  51        git add path2 &&
  52        test_tick &&
  53        git commit -m path2 &&
  54        HEAD=$(git rev-parse --verify HEAD) &&
  55        git push &&
  56        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
  57         test $HEAD = $(git rev-parse --verify HEAD))
  58'
  59
  60test_expect_success ' push to remote repository with unpacked refs' '
  61        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
  62         rm packed-refs &&
  63         git update-ref refs/heads/master \
  64                0c973ae9bd51902a28466f3850b543fa66a6aaf4) &&
  65        git push &&
  66        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
  67         test $HEAD = $(git rev-parse --verify HEAD))
  68'
  69
  70test_expect_success 'create and delete remote branch' '
  71        cd "$ROOT_PATH"/test_repo_clone &&
  72        git checkout -b dev &&
  73        : >path3 &&
  74        git add path3 &&
  75        test_tick &&
  76        git commit -m dev &&
  77        git push origin dev &&
  78        git fetch &&
  79        git push origin :dev &&
  80        git branch -d -r origin/dev &&
  81        git fetch &&
  82        test_must_fail git show-ref --verify refs/remotes/origin/dev
  83'
  84
  85test_expect_success 'MKCOL sends directory names with trailing slashes' '
  86
  87        ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
  88
  89'
  90
  91x1="[0-9a-f]"
  92x2="$x1$x1"
  93x5="$x1$x1$x1$x1$x1"
  94x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
  95x40="$x38$x2"
  96
  97test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
  98        sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
  99        grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "
 100
 101'
 102
 103stop_httpd
 104
 105test_done