t / t1020-subdirectory.shon commit git-svn: implement git svn create-ignore (d05ddec)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5
   6test_description='Try various core-level commands in subdirectory.
   7'
   8
   9. ./test-lib.sh
  10
  11test_expect_success setup '
  12        long="a b c d e f g h i j k l m n o p q r s t u v w x y z" &&
  13        for c in $long; do echo $c; done >one &&
  14        mkdir dir &&
  15        for c in x y z $long a b c; do echo $c; done >dir/two &&
  16        cp one original.one &&
  17        cp dir/two original.two
  18'
  19HERE=`pwd`
  20LF='
  21'
  22
  23test_expect_success 'update-index and ls-files' '
  24        cd $HERE &&
  25        git update-index --add one &&
  26        case "`git ls-files`" in
  27        one) echo ok one ;;
  28        *) echo bad one; exit 1 ;;
  29        esac &&
  30        cd dir &&
  31        git update-index --add two &&
  32        case "`git ls-files`" in
  33        two) echo ok two ;;
  34        *) echo bad two; exit 1 ;;
  35        esac &&
  36        cd .. &&
  37        case "`git ls-files`" in
  38        dir/two"$LF"one) echo ok both ;;
  39        *) echo bad; exit 1 ;;
  40        esac
  41'
  42
  43test_expect_success 'cat-file' '
  44        cd $HERE &&
  45        two=`git ls-files -s dir/two` &&
  46        two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
  47        echo "$two" &&
  48        git cat-file -p "$two" >actual &&
  49        cmp dir/two actual &&
  50        cd dir &&
  51        git cat-file -p "$two" >actual &&
  52        cmp two actual
  53'
  54rm -f actual dir/actual
  55
  56test_expect_success 'diff-files' '
  57        cd $HERE &&
  58        echo a >>one &&
  59        echo d >>dir/two &&
  60        case "`git diff-files --name-only`" in
  61        dir/two"$LF"one) echo ok top ;;
  62        *) echo bad top; exit 1 ;;
  63        esac &&
  64        # diff should not omit leading paths
  65        cd dir &&
  66        case "`git diff-files --name-only`" in
  67        dir/two"$LF"one) echo ok subdir ;;
  68        *) echo bad subdir; exit 1 ;;
  69        esac &&
  70        case "`git diff-files --name-only .`" in
  71        dir/two) echo ok subdir limited ;;
  72        *) echo bad subdir limited; exit 1 ;;
  73        esac
  74'
  75
  76test_expect_success 'write-tree' '
  77        cd $HERE &&
  78        top=`git write-tree` &&
  79        echo $top &&
  80        cd dir &&
  81        sub=`git write-tree` &&
  82        echo $sub &&
  83        test "z$top" = "z$sub"
  84'
  85
  86test_expect_success 'checkout-index' '
  87        cd $HERE &&
  88        git checkout-index -f -u one &&
  89        cmp one original.one &&
  90        cd dir &&
  91        git checkout-index -f -u two &&
  92        cmp two ../original.two
  93'
  94
  95test_expect_success 'read-tree' '
  96        cd $HERE &&
  97        rm -f one dir/two &&
  98        tree=`git write-tree` &&
  99        git read-tree --reset -u "$tree" &&
 100        cmp one original.one &&
 101        cmp dir/two original.two &&
 102        cd dir &&
 103        rm -f two &&
 104        git read-tree --reset -u "$tree" &&
 105        cmp two ../original.two &&
 106        cmp ../one ../original.one
 107'
 108
 109test_expect_success 'no file/rev ambiguity check inside .git' '
 110        cd $HERE &&
 111        git commit -a -m 1 &&
 112        cd $HERE/.git &&
 113        git show -s HEAD
 114'
 115
 116test_expect_success 'no file/rev ambiguity check inside a bare repo' '
 117        cd $HERE &&
 118        git clone -s --bare .git foo.git &&
 119        cd foo.git && GIT_DIR=. git show -s HEAD
 120'
 121
 122# This still does not work as it should...
 123: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
 124        cd $HERE &&
 125        git clone -s --bare .git foo.git &&
 126        cd foo.git && git show -s HEAD
 127'
 128
 129test_expect_success 'detection should not be fooled by a symlink' '
 130        cd $HERE &&
 131        rm -fr foo.git &&
 132        git clone -s .git another &&
 133        ln -s another yetanother &&
 134        cd yetanother/.git &&
 135        git show -s HEAD
 136'
 137
 138test_done