t / t7409-submodule-detached-worktree.shon commit Merge branch 'da/difftool-updates' (de54ef2)
   1#!/bin/sh
   2#
   3# Copyright (c) 2012 Daniel GraƱa
   4#
   5
   6test_description='Test submodules on detached working tree
   7
   8This test verifies that "git submodule" initialization, update and addition works
   9on detahced working trees
  10'
  11
  12TEST_NO_CREATE_REPO=1
  13. ./test-lib.sh
  14
  15test_expect_success 'submodule on detached working tree' '
  16        git init --bare remote &&
  17        test_create_repo bundle1 &&
  18        (
  19                cd bundle1 &&
  20                test_commit "shoot" &&
  21                git rev-parse --verify HEAD >../expect
  22        ) &&
  23        mkdir home &&
  24        (
  25                cd home &&
  26                export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" &&
  27                git clone --bare ../remote .dotfiles &&
  28                git submodule add ../bundle1 .vim/bundle/sogood &&
  29                test_commit "sogood" &&
  30                (
  31                        unset GIT_WORK_TREE GIT_DIR &&
  32                        cd .vim/bundle/sogood &&
  33                        git rev-parse --verify HEAD >actual &&
  34                        test_cmp ../../../../expect actual
  35                ) &&
  36                git push origin master
  37        ) &&
  38        mkdir home2 &&
  39        (
  40                cd home2 &&
  41                git clone --bare ../remote .dotfiles &&
  42                export GIT_WORK_TREE="$(pwd)" GIT_DIR="$(pwd)/.dotfiles" &&
  43                git checkout master &&
  44                git submodule update --init &&
  45                (
  46                        unset GIT_WORK_TREE GIT_DIR &&
  47                        cd .vim/bundle/sogood &&
  48                        git rev-parse --verify HEAD >actual &&
  49                        test_cmp ../../../../expect actual
  50                )
  51        )
  52'
  53
  54test_expect_success 'submodule on detached working pointed by core.worktree' '
  55        mkdir home3 &&
  56        (
  57                cd home3 &&
  58                export GIT_DIR="$(pwd)/.dotfiles" &&
  59                git clone --bare ../remote "$GIT_DIR" &&
  60                git config core.bare false &&
  61                git config core.worktree .. &&
  62                git checkout master &&
  63                git submodule add ../bundle1 .vim/bundle/dupe &&
  64                test_commit "dupe" &&
  65                git push origin master
  66        ) &&
  67        (
  68                cd home &&
  69                export GIT_DIR="$(pwd)/.dotfiles" &&
  70                git config core.bare false &&
  71                git config core.worktree .. &&
  72                git pull &&
  73                git submodule update --init &&
  74                test -f .vim/bundle/dupe/shoot.t
  75        )
  76'
  77
  78test_done