t / t5612-clone-refspec.shon commit tests: change "cd ... && git fetch" to "cd &&\n\tgit fetch" (28d67d9)
   1#!/bin/sh
   2
   3test_description='test refspec written by clone-command'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup' '
   7        # Make two branches, "master" and "side"
   8        echo one >file &&
   9        git add file &&
  10        git commit -m one &&
  11        echo two >file &&
  12        git commit -a -m two &&
  13        git tag two &&
  14        echo three >file &&
  15        git commit -a -m three &&
  16        git checkout -b side &&
  17        echo four >file &&
  18        git commit -a -m four &&
  19        git checkout master &&
  20
  21        # default clone
  22        git clone . dir_all &&
  23
  24        # default --single that follows HEAD=master
  25        git clone --single-branch . dir_master &&
  26
  27        # default --single that follows HEAD=side
  28        git checkout side &&
  29        git clone --single-branch . dir_side &&
  30
  31        # explicit --single that follows side
  32        git checkout master &&
  33        git clone --single-branch --branch side . dir_side2 &&
  34
  35        # default --single with --mirror
  36        git clone --single-branch --mirror . dir_mirror &&
  37
  38        # default --single with --branch and --mirror
  39        git clone --single-branch --mirror --branch side . dir_mirror_side &&
  40
  41        # --single that does not know what branch to follow
  42        git checkout two^ &&
  43        git clone --single-branch . dir_detached &&
  44
  45        # explicit --single with tag
  46        git clone --single-branch --branch two . dir_tag &&
  47
  48        # advance both "master" and "side" branches
  49        git checkout side &&
  50        echo five >file &&
  51        git commit -a -m five &&
  52        git checkout master &&
  53        echo six >file &&
  54        git commit -a -m six &&
  55
  56        # update tag
  57        git tag -d two && git tag two
  58'
  59
  60test_expect_success 'by default all branches will be kept updated' '
  61        (
  62                cd dir_all &&
  63                git fetch &&
  64                git for-each-ref refs/remotes/origin |
  65                sed -e "/HEAD$/d" \
  66                    -e "s|/remotes/origin/|/heads/|" >../actual
  67        ) &&
  68        # follow both master and side
  69        git for-each-ref refs/heads >expect &&
  70        test_cmp expect actual
  71'
  72
  73test_expect_success 'by default no tags will be kept updated' '
  74        (
  75                cd dir_all &&
  76                git fetch &&
  77                git for-each-ref refs/tags >../actual
  78        ) &&
  79        git for-each-ref refs/tags >expect &&
  80        test_must_fail test_cmp expect actual
  81'
  82
  83test_expect_success '--single-branch while HEAD pointing at master' '
  84        (
  85                cd dir_master &&
  86                git fetch &&
  87                git for-each-ref refs/remotes/origin |
  88                sed -e "/HEAD$/d" \
  89                    -e "s|/remotes/origin/|/heads/|" >../actual
  90        ) &&
  91        # only follow master
  92        git for-each-ref refs/heads/master >expect &&
  93        test_cmp expect actual
  94'
  95
  96test_expect_success '--single-branch while HEAD pointing at side' '
  97        (
  98                cd dir_side &&
  99                git fetch &&
 100                git for-each-ref refs/remotes/origin |
 101                sed -e "/HEAD$/d" \
 102                    -e "s|/remotes/origin/|/heads/|" >../actual
 103        ) &&
 104        # only follow side
 105        git for-each-ref refs/heads/side >expect &&
 106        test_cmp expect actual
 107'
 108
 109test_expect_success '--single-branch with explicit --branch side' '
 110        (
 111                cd dir_side2 &&
 112                git fetch &&
 113                git for-each-ref refs/remotes/origin |
 114                sed -e "/HEAD$/d" \
 115                    -e "s|/remotes/origin/|/heads/|" >../actual
 116        ) &&
 117        # only follow side
 118        git for-each-ref refs/heads/side >expect &&
 119        test_cmp expect actual
 120'
 121
 122test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '
 123        (
 124                cd dir_tag &&
 125                git fetch &&
 126                git for-each-ref refs/tags >../actual
 127        ) &&
 128        git for-each-ref refs/tags >expect &&
 129        test_cmp expect actual
 130'
 131
 132test_expect_success '--single-branch with --mirror' '
 133        (
 134                cd dir_mirror &&
 135                git fetch &&
 136                git for-each-ref refs > ../actual
 137        ) &&
 138        git for-each-ref refs >expect &&
 139        test_cmp expect actual
 140'
 141
 142test_expect_success '--single-branch with explicit --branch and --mirror' '
 143        (
 144                cd dir_mirror_side &&
 145                git fetch &&
 146                git for-each-ref refs > ../actual
 147        ) &&
 148        git for-each-ref refs >expect &&
 149        test_cmp expect actual
 150'
 151
 152test_expect_success '--single-branch with detached' '
 153        (
 154                cd dir_detached &&
 155                git fetch &&
 156                git for-each-ref refs/remotes/origin |
 157                sed -e "/HEAD$/d" \
 158                    -e "s|/remotes/origin/|/heads/|" >../actual
 159        ) &&
 160        # nothing
 161        >expect &&
 162        test_cmp expect actual
 163'
 164
 165test_done