t / t5801-remote-helpers.shon commit Merge branch 'jn/config-ignore-inaccessible' into maint (b1c418e)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Sverre Rabbelier
   4#
   5
   6test_description='Test remote-helper import and export commands'
   7
   8. ./test-lib.sh
   9. "$TEST_DIRECTORY"/lib-gpg.sh
  10
  11if ! type "${BASH-bash}" >/dev/null 2>&1; then
  12        skip_all='skipping remote-testgit tests, bash not available'
  13        test_done
  14fi
  15
  16compare_refs() {
  17        git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
  18        git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
  19        test_cmp expect actual
  20}
  21
  22test_expect_success 'setup repository' '
  23        git init server &&
  24        (cd server &&
  25         echo content >file &&
  26         git add file &&
  27         git commit -m one)
  28'
  29
  30test_expect_success 'cloning from local repo' '
  31        git clone "testgit::${PWD}/server" local &&
  32        test_cmp server/file local/file
  33'
  34
  35test_expect_success 'create new commit on remote' '
  36        (cd server &&
  37         echo content >>file &&
  38         git commit -a -m two)
  39'
  40
  41test_expect_success 'pulling from local repo' '
  42        (cd local && git pull) &&
  43        test_cmp server/file local/file
  44'
  45
  46test_expect_success 'pushing to local repo' '
  47        (cd local &&
  48        echo content >>file &&
  49        git commit -a -m three &&
  50        git push) &&
  51        compare_refs local HEAD server HEAD
  52'
  53
  54test_expect_success 'fetch new branch' '
  55        (cd server &&
  56         git reset --hard &&
  57         git checkout -b new &&
  58         echo content >>file &&
  59         git commit -a -m five
  60        ) &&
  61        (cd local &&
  62         git fetch origin new
  63        ) &&
  64        compare_refs server HEAD local FETCH_HEAD
  65'
  66
  67test_expect_success 'fetch multiple branches' '
  68        (cd local &&
  69         git fetch
  70        ) &&
  71        compare_refs server master local refs/remotes/origin/master &&
  72        compare_refs server new local refs/remotes/origin/new
  73'
  74
  75test_expect_success 'push when remote has extra refs' '
  76        (cd local &&
  77         git reset --hard origin/master &&
  78         echo content >>file &&
  79         git commit -a -m six &&
  80         git push
  81        ) &&
  82        compare_refs local master server master
  83'
  84
  85test_expect_success 'push new branch by name' '
  86        (cd local &&
  87         git checkout -b new-name  &&
  88         echo content >>file &&
  89         git commit -a -m seven &&
  90         git push origin new-name
  91        ) &&
  92        compare_refs local HEAD server refs/heads/new-name
  93'
  94
  95test_expect_failure 'push new branch with old:new refspec' '
  96        (cd local &&
  97         git push origin new-name:new-refspec
  98        ) &&
  99        compare_refs local HEAD server refs/heads/new-refspec
 100'
 101
 102test_expect_success 'cloning without refspec' '
 103        GIT_REMOTE_TESTGIT_REFSPEC="" \
 104        git clone "testgit::${PWD}/server" local2 &&
 105        compare_refs local2 HEAD server HEAD
 106'
 107
 108test_expect_success 'pulling without refspecs' '
 109        (cd local2 &&
 110        git reset --hard &&
 111        GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
 112        compare_refs local2 HEAD server HEAD
 113'
 114
 115test_expect_failure 'pushing without refspecs' '
 116        test_when_finished "(cd local2 && git reset --hard origin)" &&
 117        (cd local2 &&
 118        echo content >>file &&
 119        git commit -a -m ten &&
 120        GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
 121        compare_refs local2 HEAD server HEAD
 122'
 123
 124test_expect_success 'pulling with straight refspec' '
 125        (cd local2 &&
 126        GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
 127        compare_refs local2 HEAD server HEAD
 128'
 129
 130test_expect_failure 'pushing with straight refspec' '
 131        test_when_finished "(cd local2 && git reset --hard origin)" &&
 132        (cd local2 &&
 133        echo content >>file &&
 134        git commit -a -m eleven &&
 135        GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
 136        compare_refs local2 HEAD server HEAD
 137'
 138
 139test_expect_success 'pulling without marks' '
 140        (cd local2 &&
 141        GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
 142        compare_refs local2 HEAD server HEAD
 143'
 144
 145test_expect_failure 'pushing without marks' '
 146        test_when_finished "(cd local2 && git reset --hard origin)" &&
 147        (cd local2 &&
 148        echo content >>file &&
 149        git commit -a -m twelve &&
 150        GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
 151        compare_refs local2 HEAD server HEAD
 152'
 153
 154test_expect_success 'push all with existing object' '
 155        (cd local &&
 156        git branch dup2 master &&
 157        git push origin --all
 158        ) &&
 159        compare_refs local dup2 server dup2
 160'
 161
 162test_expect_success 'push ref with existing object' '
 163        (cd local &&
 164        git branch dup master &&
 165        git push origin dup
 166        ) &&
 167        compare_refs local dup server dup
 168'
 169
 170test_expect_success GPG 'push signed tag' '
 171        (cd local &&
 172        git checkout master &&
 173        git tag -s -m signed-tag signed-tag &&
 174        git push origin signed-tag
 175        ) &&
 176        compare_refs local signed-tag^{} server signed-tag^{} &&
 177        test_must_fail compare_refs local signed-tag server signed-tag
 178'
 179
 180test_expect_success GPG 'push signed tag with signed-tags capability' '
 181        (cd local &&
 182        git checkout master &&
 183        git tag -s -m signed-tag signed-tag-2 &&
 184        GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2
 185        ) &&
 186        compare_refs local signed-tag-2 server signed-tag-2
 187'
 188
 189test_expect_success 'push messages' '
 190        (cd local &&
 191        git checkout -b new_branch master &&
 192        echo new >>file &&
 193        git commit -a -m new &&
 194        git push origin new_branch &&
 195        git fetch origin &&
 196        echo new >>file &&
 197        git commit -a -m new &&
 198        git push origin new_branch 2> msg &&
 199        ! grep "\[new branch\]" msg
 200        )
 201'
 202
 203test_done