2602bc515bce1373a56feac0783c1995d7c6422a
   1#!/bin/sh
   2#
   3# Copyright (c) 2014 Heiko Voigt
   4#
   5
   6test_description='Test submodules config cache infrastructure
   7
   8This test verifies that parsing .gitmodules configuration directly
   9from the database works.
  10'
  11
  12TEST_NO_CREATE_REPO=1
  13. ./test-lib.sh
  14
  15test_expect_success 'submodule config cache setup' '
  16        mkdir submodule &&
  17        (cd submodule &&
  18                git init &&
  19                echo a >a &&
  20                git add . &&
  21                git commit -ma
  22        ) &&
  23        mkdir super &&
  24        (cd super &&
  25                git init &&
  26                git submodule add ../submodule &&
  27                git submodule add ../submodule a &&
  28                git commit -m "add as submodule and as a" &&
  29                git mv a b &&
  30                git commit -m "move a to b"
  31        )
  32'
  33
  34cat >super/expect <<EOF
  35Submodule name: 'a' for path 'a'
  36Submodule name: 'a' for path 'b'
  37Submodule name: 'submodule' for path 'submodule'
  38Submodule name: 'submodule' for path 'submodule'
  39EOF
  40
  41test_expect_success 'test parsing and lookup of submodule config by path' '
  42        (cd super &&
  43                test-submodule-config \
  44                        HEAD^ a \
  45                        HEAD b \
  46                        HEAD^ submodule \
  47                        HEAD submodule \
  48                                >actual &&
  49                test_cmp expect actual
  50        )
  51'
  52
  53test_expect_success 'test parsing and lookup of submodule config by name' '
  54        (cd super &&
  55                test-submodule-config --name \
  56                        HEAD^ a \
  57                        HEAD a \
  58                        HEAD^ submodule \
  59                        HEAD submodule \
  60                                >actual &&
  61                test_cmp expect actual
  62        )
  63'
  64
  65cat >super/expect_error <<EOF
  66Submodule name: 'a' for path 'b'
  67Submodule name: 'submodule' for path 'submodule'
  68EOF
  69
  70test_expect_success 'error in one submodule config lets continue' '
  71        (cd super &&
  72                cp .gitmodules .gitmodules.bak &&
  73                echo "  value = \"" >>.gitmodules &&
  74                git add .gitmodules &&
  75                mv .gitmodules.bak .gitmodules &&
  76                git commit -m "add error" &&
  77                test-submodule-config \
  78                        HEAD b \
  79                        HEAD submodule \
  80                                >actual &&
  81                test_cmp expect_error actual
  82        )
  83'
  84
  85test_done