t / t7403-submodule-sync.shon commit Merge branch 'jk/add-e-doc' into maint (54d04f2)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 David Aguilar
   4#
   5
   6test_description='git submodule sync
   7
   8These tests exercise the "git submodule sync" subcommand.
   9'
  10
  11. ./test-lib.sh
  12
  13test_expect_success setup '
  14        echo file > file &&
  15        git add file &&
  16        test_tick &&
  17        git commit -m upstream &&
  18        git clone . super &&
  19        git clone super submodule &&
  20        (cd super &&
  21         git submodule add ../submodule submodule &&
  22         test_tick &&
  23         git commit -m "submodule"
  24        ) &&
  25        git clone super super-clone &&
  26        (cd super-clone && git submodule update --init) &&
  27        git clone super empty-clone &&
  28        (cd empty-clone && git submodule init)
  29'
  30
  31test_expect_success 'change submodule' '
  32        (cd submodule &&
  33         echo second line >> file &&
  34         test_tick &&
  35         git commit -a -m "change submodule"
  36        )
  37'
  38
  39test_expect_success 'change submodule url' '
  40        (cd super &&
  41         cd submodule &&
  42         git checkout master &&
  43         git pull
  44        ) &&
  45        mv submodule moved-submodule &&
  46        (cd super &&
  47         git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
  48         test_tick &&
  49         git commit -a -m moved-submodule
  50        )
  51'
  52
  53test_expect_success '"git submodule sync" should update submodule URLs' '
  54        (cd super-clone &&
  55         git pull &&
  56         git submodule sync
  57        ) &&
  58        test -d "$(git config -f super-clone/submodule/.git/config \
  59                                remote.origin.url)" &&
  60        (cd super-clone/submodule &&
  61         git checkout master &&
  62         git pull
  63        ) &&
  64        (cd super-clone &&
  65         test -d "$(git config submodule.submodule.url)"
  66        )
  67'
  68
  69test_expect_success '"git submodule sync" should update submodule URLs if not yet cloned' '
  70        (cd empty-clone &&
  71         git pull &&
  72         git submodule sync &&
  73         test -d "$(git config submodule.submodule.url)"
  74        )
  75'
  76
  77test_done