t / t5572-pull-submodule.shon commit Merge branch 'jk/trailers-parse' into next (2d4d937)
   1#!/bin/sh
   2
   3test_description='pull can handle submodules'
   4
   5. ./test-lib.sh
   6. "$TEST_DIRECTORY"/lib-submodule-update.sh
   7
   8reset_branch_to_HEAD () {
   9        git branch -D "$1" &&
  10        git checkout -b "$1" HEAD &&
  11        git branch --set-upstream-to="origin/$1" "$1"
  12}
  13
  14git_pull () {
  15        reset_branch_to_HEAD "$1" &&
  16        git pull
  17}
  18
  19# pulls without conflicts
  20test_submodule_switch "git_pull"
  21
  22git_pull_ff () {
  23        reset_branch_to_HEAD "$1" &&
  24        git pull --ff
  25}
  26
  27test_submodule_switch "git_pull_ff"
  28
  29git_pull_ff_only () {
  30        reset_branch_to_HEAD "$1" &&
  31        git pull --ff-only
  32}
  33
  34test_submodule_switch "git_pull_ff_only"
  35
  36git_pull_noff () {
  37        reset_branch_to_HEAD "$1" &&
  38        git pull --no-ff
  39}
  40
  41KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
  42KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
  43test_submodule_switch "git_pull_noff"
  44
  45test_expect_success 'pull --recurse-submodule setup' '
  46        test_create_repo child &&
  47        test_commit -C child bar &&
  48
  49        test_create_repo parent &&
  50        test_commit -C child foo &&
  51
  52        git -C parent submodule add ../child sub &&
  53        git -C parent commit -m "add submodule" &&
  54
  55        git clone --recurse-submodules parent super
  56'
  57
  58test_expect_success 'recursive pull updates working tree' '
  59        test_commit -C child merge_strategy &&
  60        git -C parent submodule update --remote &&
  61        git -C parent add sub &&
  62        git -C parent commit -m "update submodule" &&
  63
  64        git -C super pull --no-rebase --recurse-submodules &&
  65        test_path_is_file super/sub/merge_strategy.t
  66'
  67
  68test_expect_success 'recursive rebasing pull' '
  69        # change upstream
  70        test_commit -C child rebase_strategy &&
  71        git -C parent submodule update --remote &&
  72        git -C parent add sub &&
  73        git -C parent commit -m "update submodule" &&
  74
  75        # also have local commits
  76        test_commit -C super/sub local_stuff &&
  77
  78        git -C super pull --rebase --recurse-submodules &&
  79        test_path_is_file super/sub/rebase_strategy.t &&
  80        test_path_is_file super/sub/local_stuff.t
  81'
  82
  83test_expect_success 'pull rebase recursing fails with conflicts' '
  84
  85        # local changes in submodule recorded in superproject:
  86        test_commit -C super/sub local_stuff_2 &&
  87        git -C super add sub &&
  88        git -C super commit -m "local update submodule" &&
  89
  90        # and in the remote as well:
  91        test_commit -C child important_upstream_work &&
  92        git -C parent submodule update --remote &&
  93        git -C parent add sub &&
  94        git -C parent commit -m "remote update submodule" &&
  95
  96        # Unfortunately we fail here, despite no conflict in the
  97        # submodule itself, but the merge strategy in submodules
  98        # does not support rebase:
  99        test_must_fail git -C super pull --rebase --recurse-submodules 2>err &&
 100        test_i18ngrep "locally recorded submodule modifications" err
 101'
 102
 103test_done