t / t5521-pull-options.shon commit t/lib-submodule-update.sh: fix test ignoring ignored files in submodules (63d963a)
   1#!/bin/sh
   2
   3test_description='pull options'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        mkdir parent &&
   9        (cd parent && git init &&
  10         echo one >file && git add file &&
  11         git commit -m one)
  12'
  13
  14test_expect_success 'git pull -q' '
  15        mkdir clonedq &&
  16        (cd clonedq && git init &&
  17        git pull -q "../parent" >out 2>err &&
  18        test_must_be_empty err &&
  19        test_must_be_empty out)
  20'
  21
  22test_expect_success 'git pull -q --rebase' '
  23        mkdir clonedqrb &&
  24        (cd clonedqrb && git init &&
  25        git pull -q --rebase "../parent" >out 2>err &&
  26        test_must_be_empty err &&
  27        test_must_be_empty out &&
  28        git pull -q --rebase "../parent" >out 2>err &&
  29        test_must_be_empty err &&
  30        test_must_be_empty out)
  31'
  32
  33test_expect_success 'git pull' '
  34        mkdir cloned &&
  35        (cd cloned && git init &&
  36        git pull "../parent" >out 2>err &&
  37        test -s err &&
  38        test_must_be_empty out)
  39'
  40
  41test_expect_success 'git pull --rebase' '
  42        mkdir clonedrb &&
  43        (cd clonedrb && git init &&
  44        git pull --rebase "../parent" >out 2>err &&
  45        test -s err &&
  46        test_must_be_empty out)
  47'
  48
  49test_expect_success 'git pull -v' '
  50        mkdir clonedv &&
  51        (cd clonedv && git init &&
  52        git pull -v "../parent" >out 2>err &&
  53        test -s err &&
  54        test_must_be_empty out)
  55'
  56
  57test_expect_success 'git pull -v --rebase' '
  58        mkdir clonedvrb &&
  59        (cd clonedvrb && git init &&
  60        git pull -v --rebase "../parent" >out 2>err &&
  61        test -s err &&
  62        test_must_be_empty out)
  63'
  64
  65test_expect_success 'git pull -v -q' '
  66        mkdir clonedvq &&
  67        (cd clonedvq && git init &&
  68        git pull -v -q "../parent" >out 2>err &&
  69        test_must_be_empty out &&
  70        test_must_be_empty err)
  71'
  72
  73test_expect_success 'git pull -q -v' '
  74        mkdir clonedqv &&
  75        (cd clonedqv && git init &&
  76        git pull -q -v "../parent" >out 2>err &&
  77        test_must_be_empty out &&
  78        test -s err)
  79'
  80
  81test_expect_success 'git pull --force' '
  82        mkdir clonedoldstyle &&
  83        (cd clonedoldstyle && git init &&
  84        cat >>.git/config <<-\EOF &&
  85        [remote "one"]
  86                url = ../parent
  87                fetch = refs/heads/master:refs/heads/mirror
  88        [remote "two"]
  89                url = ../parent
  90                fetch = refs/heads/master:refs/heads/origin
  91        [branch "master"]
  92                remote = two
  93                merge = refs/heads/master
  94        EOF
  95        git pull two &&
  96        test_commit A &&
  97        git branch -f origin &&
  98        git pull --all --force
  99        )
 100'
 101
 102test_expect_success 'git pull --all' '
 103        mkdir clonedmulti &&
 104        (cd clonedmulti && git init &&
 105        cat >>.git/config <<-\EOF &&
 106        [remote "one"]
 107                url = ../parent
 108                fetch = refs/heads/*:refs/remotes/one/*
 109        [remote "two"]
 110                url = ../parent
 111                fetch = refs/heads/*:refs/remotes/two/*
 112        [branch "master"]
 113                remote = one
 114                merge = refs/heads/master
 115        EOF
 116        git pull --all
 117        )
 118'
 119
 120test_expect_success 'git pull --dry-run' '
 121        test_when_finished "rm -rf clonedry" &&
 122        git init clonedry &&
 123        (
 124                cd clonedry &&
 125                git pull --dry-run ../parent &&
 126                test_path_is_missing .git/FETCH_HEAD &&
 127                test_path_is_missing .git/refs/heads/master &&
 128                test_path_is_missing .git/index &&
 129                test_path_is_missing file
 130        )
 131'
 132
 133test_expect_success 'git pull --all --dry-run' '
 134        test_when_finished "rm -rf cloneddry" &&
 135        git init clonedry &&
 136        (
 137                cd clonedry &&
 138                git remote add origin ../parent &&
 139                git pull --all --dry-run &&
 140                test_path_is_missing .git/FETCH_HEAD &&
 141                test_path_is_missing .git/refs/remotes/origin/master &&
 142                test_path_is_missing .git/index &&
 143                test_path_is_missing file
 144        )
 145'
 146
 147test_expect_success 'git pull --allow-unrelated-histories' '
 148        test_when_finished "rm -fr src dst" &&
 149        git init src &&
 150        (
 151                cd src &&
 152                test_commit one &&
 153                test_commit two
 154        ) &&
 155        git clone src dst &&
 156        (
 157                cd src &&
 158                git checkout --orphan side HEAD^ &&
 159                test_commit three
 160        ) &&
 161        (
 162                cd dst &&
 163                test_must_fail git pull ../src side &&
 164                git pull --allow-unrelated-histories ../src side
 165        )
 166'
 167
 168test_expect_success 'git pull does not add a sign-off line' '
 169        test_when_finished "rm -fr src dst actual" &&
 170        git init src &&
 171        test_commit -C src one &&
 172        git clone src dst &&
 173        test_commit -C src two &&
 174        git -C dst pull --no-ff &&
 175        git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
 176        test_must_be_empty actual
 177'
 178
 179test_expect_success 'git pull --no-signoff does not add sign-off line' '
 180        test_when_finished "rm -fr src dst actual" &&
 181        git init src &&
 182        test_commit -C src one &&
 183        git clone src dst &&
 184        test_commit -C src two &&
 185        git -C dst pull --no-signoff --no-ff &&
 186        git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
 187        test_must_be_empty actual
 188'
 189
 190test_expect_success 'git pull --signoff add a sign-off line' '
 191        test_when_finished "rm -fr src dst expected actual" &&
 192        echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
 193        git init src &&
 194        test_commit -C src one &&
 195        git clone src dst &&
 196        test_commit -C src two &&
 197        git -C dst pull --signoff --no-ff &&
 198        git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
 199        test_cmp expected actual
 200'
 201
 202test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
 203        test_when_finished "rm -fr src dst actual" &&
 204        git init src &&
 205        test_commit -C src one &&
 206        git clone src dst &&
 207        test_commit -C src two &&
 208        git -C dst pull --signoff --no-signoff --no-ff &&
 209        git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
 210        test_must_be_empty actual
 211'
 212
 213test_done