t / t5531-deep-submodule-push.shon commit Merge branch 'jk/maint-commit-check-committer-early' into maint-1.7.11 (9e0833c)
   1#!/bin/sh
   2
   3test_description='unpack-objects'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        mkdir pub.git &&
   9        GIT_DIR=pub.git git init --bare &&
  10        GIT_DIR=pub.git git config receive.fsckobjects true &&
  11        mkdir work &&
  12        (
  13                cd work &&
  14                git init &&
  15                mkdir -p gar/bage &&
  16                (
  17                        cd gar/bage &&
  18                        git init &&
  19                        >junk &&
  20                        git add junk &&
  21                        git commit -m "Initial junk"
  22                ) &&
  23                git add gar/bage &&
  24                git commit -m "Initial superproject"
  25        )
  26'
  27
  28test_expect_success push '
  29        (
  30                cd work &&
  31                git push ../pub.git master
  32        )
  33'
  34
  35test_expect_success 'push if submodule has no remote' '
  36        (
  37                cd work/gar/bage &&
  38                >junk2 &&
  39                git add junk2 &&
  40                git commit -m "Second junk"
  41        ) &&
  42        (
  43                cd work &&
  44                git add gar/bage &&
  45                git commit -m "Second commit for gar/bage" &&
  46                git push --recurse-submodules=check ../pub.git master
  47        )
  48'
  49
  50test_expect_success 'push fails if submodule commit not on remote' '
  51        (
  52                cd work/gar &&
  53                git clone --bare bage ../../submodule.git &&
  54                cd bage &&
  55                git remote add origin ../../../submodule.git &&
  56                git fetch &&
  57                >junk3 &&
  58                git add junk3 &&
  59                git commit -m "Third junk"
  60        ) &&
  61        (
  62                cd work &&
  63                git add gar/bage &&
  64                git commit -m "Third commit for gar/bage" &&
  65                test_must_fail git push --recurse-submodules=check ../pub.git master
  66        )
  67'
  68
  69test_expect_success 'push succeeds after commit was pushed to remote' '
  70        (
  71                cd work/gar/bage &&
  72                git push origin master
  73        ) &&
  74        (
  75                cd work &&
  76                git push --recurse-submodules=check ../pub.git master
  77        )
  78'
  79
  80test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
  81        (
  82                cd work/gar/bage &&
  83                >junk4 &&
  84                git add junk4 &&
  85                git commit -m "Fourth junk"
  86        ) &&
  87        (
  88                cd work &&
  89                git branch branch2 &&
  90                git add gar/bage &&
  91                git commit -m "Fourth commit for gar/bage" &&
  92                git checkout branch2 &&
  93                (
  94                        cd gar/bage &&
  95                        git checkout HEAD~1
  96                ) &&
  97                >junk1 &&
  98                git add junk1 &&
  99                git commit -m "First junk" &&
 100                test_must_fail git push --recurse-submodules=check ../pub.git
 101        )
 102'
 103
 104test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' '
 105        git init --bare a
 106        git clone a a1 &&
 107        (
 108                cd a1 &&
 109                git init b
 110                (
 111                        cd b &&
 112                        >junk &&
 113                        git add junk &&
 114                        git commit -m "initial"
 115                ) &&
 116                git add b &&
 117                git commit -m "added submodule" &&
 118                git push --recurse-submodule=check origin master
 119        )
 120'
 121
 122test_expect_success 'push unpushed submodules when not needed' '
 123        (
 124                cd work &&
 125                (
 126                        cd gar/bage &&
 127                        git checkout master &&
 128                        >junk5 &&
 129                        git add junk5 &&
 130                        git commit -m "Fifth junk" &&
 131                        git push &&
 132                        git rev-parse origin/master >../../../expected
 133                ) &&
 134                git checkout master &&
 135                git add gar/bage &&
 136                git commit -m "Fifth commit for gar/bage" &&
 137                git push --recurse-submodules=on-demand ../pub.git master
 138        ) &&
 139        (
 140                cd submodule.git &&
 141                git rev-parse master >../actual
 142        ) &&
 143        test_cmp expected actual
 144'
 145
 146test_expect_success 'push unpushed submodules when not needed 2' '
 147        (
 148                cd submodule.git &&
 149                git rev-parse master >../expected
 150        ) &&
 151        (
 152                cd work &&
 153                (
 154                        cd gar/bage &&
 155                        >junk6 &&
 156                        git add junk6 &&
 157                        git commit -m "Sixth junk"
 158                ) &&
 159                >junk2 &&
 160                git add junk2 &&
 161                git commit -m "Second junk for work" &&
 162                git push --recurse-submodules=on-demand ../pub.git master
 163        ) &&
 164        (
 165                cd submodule.git &&
 166                git rev-parse master >../actual
 167        ) &&
 168        test_cmp expected actual
 169'
 170
 171test_expect_success 'push unpushed submodules recursively' '
 172        (
 173                cd work &&
 174                (
 175                        cd gar/bage &&
 176                        git checkout master &&
 177                        > junk7 &&
 178                        git add junk7 &&
 179                        git commit -m "Seventh junk" &&
 180                        git rev-parse master >../../../expected
 181                ) &&
 182                git checkout master &&
 183                git add gar/bage &&
 184                git commit -m "Seventh commit for gar/bage" &&
 185                git push --recurse-submodules=on-demand ../pub.git master
 186        ) &&
 187        (
 188                cd submodule.git &&
 189                git rev-parse master >../actual
 190        ) &&
 191        test_cmp expected actual
 192'
 193
 194test_expect_success 'push unpushable submodule recursively fails' '
 195        (
 196                cd work &&
 197                (
 198                        cd gar/bage &&
 199                        git rev-parse origin/master >../../../expected &&
 200                        git checkout master~0 &&
 201                        > junk8 &&
 202                        git add junk8 &&
 203                        git commit -m "Eighth junk"
 204                ) &&
 205                git add gar/bage &&
 206                git commit -m "Eighth commit for gar/bage" &&
 207                test_must_fail git push --recurse-submodules=on-demand ../pub.git master
 208        ) &&
 209        (
 210                cd submodule.git &&
 211                git rev-parse master >../actual
 212        ) &&
 213        test_cmp expected actual
 214'
 215
 216test_done