t / t1504-ceiling-dirs.shon commit format-patch: pick up correct branch name from symbolic ref (20b630a)
   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
  47
  48mkdir -p sub/dir || exit 1
  49cd sub/dir || exit 1
  50
  51unset GIT_CEILING_DIRECTORIES
  52test_prefix subdir_no_ceil "sub/dir/"
  53
  54export GIT_CEILING_DIRECTORIES
  55
  56GIT_CEILING_DIRECTORIES=""
  57test_prefix subdir_ceil_empty "sub/dir/"
  58
  59GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
  60test_fail subdir_ceil_at_trash
  61
  62GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
  63test_fail subdir_ceil_at_trash_slash
  64
  65GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
  66test_fail subdir_ceil_at_sub
  67
  68GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
  69test_fail subdir_ceil_at_sub_slash
  70
  71GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
  72test_prefix subdir_ceil_at_subdir "sub/dir/"
  73
  74GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
  75test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
  76
  77
  78GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
  79test_prefix subdir_ceil_at_su "sub/dir/"
  80
  81GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
  82test_prefix subdir_ceil_at_su_slash "sub/dir/"
  83
  84GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
  85test_prefix subdir_ceil_at_sub_di "sub/dir/"
  86
  87GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
  88test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
  89
  90GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
  91test_prefix subdir_ceil_at_subdi "sub/dir/"
  92
  93GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
  94test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
  95
  96
  97GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
  98test_fail second_of_two
  99
 100GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 101test_fail first_of_two
 102
 103GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 104test_fail second_of_three
 105
 106
 107GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
 108GIT_DIR=../../.git
 109export GIT_DIR
 110test_prefix git_dir_specified ""
 111unset GIT_DIR
 112
 113
 114cd ../.. || exit 1
 115mkdir -p s/d || exit 1
 116cd s/d || exit 1
 117
 118unset GIT_CEILING_DIRECTORIES
 119test_prefix sd_no_ceil "s/d/"
 120
 121export GIT_CEILING_DIRECTORIES
 122
 123GIT_CEILING_DIRECTORIES=""
 124test_prefix sd_ceil_empty "s/d/"
 125
 126GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
 127test_fail sd_ceil_at_trash
 128
 129GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
 130test_fail sd_ceil_at_trash_slash
 131
 132GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
 133test_fail sd_ceil_at_s
 134
 135GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
 136test_fail sd_ceil_at_s_slash
 137
 138GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
 139test_prefix sd_ceil_at_sd "s/d/"
 140
 141GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
 142test_prefix sd_ceil_at_sd_slash "s/d/"
 143
 144
 145GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
 146test_prefix sd_ceil_at_su "s/d/"
 147
 148GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
 149test_prefix sd_ceil_at_su_slash "s/d/"
 150
 151GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
 152test_prefix sd_ceil_at_s_di "s/d/"
 153
 154GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
 155test_prefix sd_ceil_at_s_di_slash "s/d/"
 156
 157GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
 158test_prefix sd_ceil_at_sdi "s/d/"
 159
 160GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
 161test_prefix sd_ceil_at_sdi_slash "s/d/"
 162
 163
 164test_done