t / t1504-ceiling-dirs.shon commit t1010: add mktree test (801cfae)
   1#!/bin/sh
   2
   3test_description='test GIT_CEILING_DIRECTORIES'
   4. ./test-lib.sh
   5
   6test_prefix() {
   7        test_expect_success "$1" \
   8        "test '$2' = \"\$(git rev-parse --show-prefix)\""
   9}
  10
  11test_fail() {
  12        test_expect_code 128 "$1: prefix" \
  13        "git rev-parse --show-prefix"
  14}
  15
  16TRASH_ROOT="$PWD"
  17ROOT_PARENT=$(dirname "$TRASH_ROOT")
  18
  19
  20unset GIT_CEILING_DIRECTORIES
  21test_prefix no_ceil ""
  22
  23export GIT_CEILING_DIRECTORIES
  24
  25GIT_CEILING_DIRECTORIES=""
  26test_prefix ceil_empty ""
  27
  28GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
  29test_prefix ceil_at_parent ""
  30
  31GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
  32test_prefix ceil_at_parent_slash ""
  33
  34GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
  35test_prefix ceil_at_trash ""
  36
  37GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
  38test_prefix ceil_at_trash_slash ""
  39
  40GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
  41test_prefix ceil_at_sub ""
  42
  43GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
  44test_prefix ceil_at_sub_slash ""
  45
  46
  47mkdir -p sub/dir || exit 1
  48cd sub/dir || exit 1
  49
  50unset GIT_CEILING_DIRECTORIES
  51test_prefix subdir_no_ceil "sub/dir/"
  52
  53export GIT_CEILING_DIRECTORIES
  54
  55GIT_CEILING_DIRECTORIES=""
  56test_prefix subdir_ceil_empty "sub/dir/"
  57
  58GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
  59test_fail subdir_ceil_at_trash
  60
  61GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
  62test_fail subdir_ceil_at_trash_slash
  63
  64GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
  65test_fail subdir_ceil_at_sub
  66
  67GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
  68test_fail subdir_ceil_at_sub_slash
  69
  70GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
  71test_prefix subdir_ceil_at_subdir "sub/dir/"
  72
  73GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
  74test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
  75
  76
  77GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
  78test_prefix subdir_ceil_at_su "sub/dir/"
  79
  80GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
  81test_prefix subdir_ceil_at_su_slash "sub/dir/"
  82
  83GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
  84test_prefix subdir_ceil_at_sub_di "sub/dir/"
  85
  86GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
  87test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
  88
  89GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
  90test_prefix subdir_ceil_at_subdi "sub/dir/"
  91
  92GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
  93test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
  94
  95
  96GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
  97test_fail second_of_two
  98
  99GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 100test_fail first_of_two
 101
 102GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 103test_fail second_of_three
 104
 105
 106GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
 107GIT_DIR=../../.git
 108export GIT_DIR
 109test_prefix git_dir_specified ""
 110unset GIT_DIR
 111
 112
 113cd ../.. || exit 1
 114mkdir -p s/d || exit 1
 115cd s/d || exit 1
 116
 117unset GIT_CEILING_DIRECTORIES
 118test_prefix sd_no_ceil "s/d/"
 119
 120export GIT_CEILING_DIRECTORIES
 121
 122GIT_CEILING_DIRECTORIES=""
 123test_prefix sd_ceil_empty "s/d/"
 124
 125GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
 126test_fail sd_ceil_at_trash
 127
 128GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
 129test_fail sd_ceil_at_trash_slash
 130
 131GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
 132test_fail sd_ceil_at_s
 133
 134GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
 135test_fail sd_ceil_at_s_slash
 136
 137GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
 138test_prefix sd_ceil_at_sd "s/d/"
 139
 140GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
 141test_prefix sd_ceil_at_sd_slash "s/d/"
 142
 143
 144GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
 145test_prefix sd_ceil_at_su "s/d/"
 146
 147GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
 148test_prefix sd_ceil_at_su_slash "s/d/"
 149
 150GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
 151test_prefix sd_ceil_at_s_di "s/d/"
 152
 153GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
 154test_prefix sd_ceil_at_s_di_slash "s/d/"
 155
 156GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
 157test_prefix sd_ceil_at_sdi "s/d/"
 158
 159GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
 160test_prefix sd_ceil_at_sdi_slash "s/d/"
 161
 162
 163test_done