t / t1504-ceiling-dirs.shon commit Merge branch 'tb/char-may-be-unsigned' (1f8e7dc)
   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_success "$1: prefix" '
  13                test_expect_code 128 git rev-parse --show-prefix
  14        '
  15}
  16
  17TRASH_ROOT="$PWD"
  18ROOT_PARENT=$(dirname "$TRASH_ROOT")
  19
  20
  21unset GIT_CEILING_DIRECTORIES
  22test_prefix no_ceil ""
  23
  24export GIT_CEILING_DIRECTORIES
  25
  26GIT_CEILING_DIRECTORIES=""
  27test_prefix ceil_empty ""
  28
  29GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
  30test_prefix ceil_at_parent ""
  31
  32GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
  33test_prefix ceil_at_parent_slash ""
  34
  35GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
  36test_prefix ceil_at_trash ""
  37
  38GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
  39test_prefix ceil_at_trash_slash ""
  40
  41GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
  42test_prefix ceil_at_sub ""
  43
  44GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
  45test_prefix ceil_at_sub_slash ""
  46
  47if test_have_prereq SYMLINKS
  48then
  49        ln -s sub top
  50fi
  51
  52mkdir -p sub/dir || exit 1
  53cd sub/dir || exit 1
  54
  55unset GIT_CEILING_DIRECTORIES
  56test_prefix subdir_no_ceil "sub/dir/"
  57
  58export GIT_CEILING_DIRECTORIES
  59
  60GIT_CEILING_DIRECTORIES=""
  61test_prefix subdir_ceil_empty "sub/dir/"
  62
  63GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
  64test_fail subdir_ceil_at_trash
  65
  66GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
  67test_fail subdir_ceil_at_trash_slash
  68
  69GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
  70test_fail subdir_ceil_at_sub
  71
  72GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
  73test_fail subdir_ceil_at_sub_slash
  74
  75if test_have_prereq SYMLINKS
  76then
  77        GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top"
  78        test_fail subdir_ceil_at_top
  79        GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
  80        test_fail subdir_ceil_at_top_slash
  81
  82        GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
  83        test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
  84        GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
  85        test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
  86fi
  87
  88GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
  89test_prefix subdir_ceil_at_subdir "sub/dir/"
  90
  91GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
  92test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
  93
  94
  95GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
  96test_prefix subdir_ceil_at_su "sub/dir/"
  97
  98GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
  99test_prefix subdir_ceil_at_su_slash "sub/dir/"
 100
 101GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
 102test_prefix subdir_ceil_at_sub_di "sub/dir/"
 103
 104GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
 105test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
 106
 107GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 108test_prefix subdir_ceil_at_subdi "sub/dir/"
 109
 110GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 111test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 112
 113
 114GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 115test_fail second_of_two
 116
 117GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 118test_fail first_of_two
 119
 120GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 121test_fail second_of_three
 122
 123
 124GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
 125GIT_DIR=../../.git
 126export GIT_DIR
 127test_prefix git_dir_specified ""
 128unset GIT_DIR
 129
 130
 131cd ../.. || exit 1
 132mkdir -p s/d || exit 1
 133cd s/d || exit 1
 134
 135unset GIT_CEILING_DIRECTORIES
 136test_prefix sd_no_ceil "s/d/"
 137
 138export GIT_CEILING_DIRECTORIES
 139
 140GIT_CEILING_DIRECTORIES=""
 141test_prefix sd_ceil_empty "s/d/"
 142
 143GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
 144test_fail sd_ceil_at_trash
 145
 146GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
 147test_fail sd_ceil_at_trash_slash
 148
 149GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
 150test_fail sd_ceil_at_s
 151
 152GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
 153test_fail sd_ceil_at_s_slash
 154
 155GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
 156test_prefix sd_ceil_at_sd "s/d/"
 157
 158GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
 159test_prefix sd_ceil_at_sd_slash "s/d/"
 160
 161
 162GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
 163test_prefix sd_ceil_at_su "s/d/"
 164
 165GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
 166test_prefix sd_ceil_at_su_slash "s/d/"
 167
 168GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
 169test_prefix sd_ceil_at_s_di "s/d/"
 170
 171GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
 172test_prefix sd_ceil_at_s_di_slash "s/d/"
 173
 174GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
 175test_prefix sd_ceil_at_sdi "s/d/"
 176
 177GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
 178test_prefix sd_ceil_at_sdi_slash "s/d/"
 179
 180
 181test_done