t / t3300-funny-names.shon commit Really honour NO_PYTHON (a348ab7)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='Pathnames with funny characters.
   7
   8This test tries pathnames with funny characters in the working
   9tree, index, and tree objects.
  10'
  11
  12. ./test-lib.sh
  13
  14p0='no-funny'
  15p1='tabs        ," (dq) and spaces'
  16p2='just space'
  17
  18cat >"$p0" <<\EOF
  191. A quick brown fox jumps over the lazy cat, oops dog.
  202. A quick brown fox jumps over the lazy cat, oops dog.
  213. A quick brown fox jumps over the lazy cat, oops dog.
  22EOF
  23
  24cat >"$p1" "$p0"
  25echo 'Foo Bar Baz' >"$p2"
  26
  27test -f "$p1" && cmp "$p0" "$p1" || {
  28        # since FAT/NTFS does not allow tabs in filenames, skip this test
  29        say 'Your filesystem does not allow tabs in filenames, test skipped.'
  30        test_done
  31}
  32
  33echo 'just space
  34no-funny' >expected
  35test_expect_success 'git-ls-files no-funny' \
  36        'git-update-index --add "$p0" "$p2" &&
  37        git-ls-files >current &&
  38        diff -u expected current'
  39
  40t0=`git-write-tree`
  41echo "$t0" >t0
  42
  43echo 'just space
  44no-funny
  45"tabs\t,\" (dq) and spaces"' >expected
  46test_expect_success 'git-ls-files with-funny' \
  47        'git-update-index --add "$p1" &&
  48        git-ls-files >current &&
  49        diff -u expected current'
  50
  51echo 'just space
  52no-funny
  53tabs    ," (dq) and spaces' >expected
  54test_expect_success 'git-ls-files -z with-funny' \
  55        'git-ls-files -z | tr \\0 \\012 >current &&
  56        diff -u expected current'
  57
  58t1=`git-write-tree`
  59echo "$t1" >t1
  60
  61echo 'just space
  62no-funny
  63"tabs\t,\" (dq) and spaces"' >expected
  64test_expect_success 'git-ls-tree with funny' \
  65        'git-ls-tree -r $t1 | sed -e "s/^[^     ]*      //" >current &&
  66         diff -u expected current'
  67
  68echo 'A "tabs\t,\" (dq) and spaces"' >expected
  69test_expect_success 'git-diff-index with-funny' \
  70        'git-diff-index --name-status $t0 >current &&
  71        diff -u expected current'
  72
  73test_expect_success 'git-diff-tree with-funny' \
  74        'git-diff-tree --name-status $t0 $t1 >current &&
  75        diff -u expected current'
  76
  77echo 'A
  78tabs    ," (dq) and spaces' >expected
  79test_expect_success 'git-diff-index -z with-funny' \
  80        'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
  81        diff -u expected current'
  82
  83test_expect_success 'git-diff-tree -z with-funny' \
  84        'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
  85        diff -u expected current'
  86
  87echo 'CNUM      no-funny        "tabs\t,\" (dq) and spaces"' >expected
  88test_expect_success 'git-diff-tree -C with-funny' \
  89        'git-diff-tree -C --find-copies-harder --name-status \
  90                $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
  91        diff -u expected current'
  92
  93echo 'RNUM      no-funny        "tabs\t,\" (dq) and spaces"' >expected
  94test_expect_success 'git-diff-tree delete with-funny' \
  95        'git-update-index --force-remove "$p0" &&
  96        git-diff-index -M --name-status \
  97                $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
  98        diff -u expected current'
  99
 100echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
 101similarity index NUM%
 102rename from no-funny
 103rename to "tabs\t,\" (dq) and spaces"' >expected
 104
 105test_expect_success 'git-diff-tree delete with-funny' \
 106        'git-diff-index -M -p $t0 |
 107         sed -e "s/index [0-9]*%/index NUM%/" >current &&
 108         diff -u expected current'
 109
 110chmod +x "$p1"
 111echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
 112old mode 100644
 113new mode 100755
 114similarity index NUM%
 115rename from no-funny
 116rename to "tabs\t,\" (dq) and spaces"' >expected
 117
 118test_expect_success 'git-diff-tree delete with-funny' \
 119        'git-diff-index -M -p $t0 |
 120         sed -e "s/index [0-9]*%/index NUM%/" >current &&
 121         diff -u expected current'
 122
 123echo >expected ' "tabs\t,\" (dq) and spaces"
 124 1 files changed, 0 insertions(+), 0 deletions(-)'
 125test_expect_success 'git-diff-tree rename with-funny applied' \
 126        'git-diff-index -M -p $t0 |
 127         git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 128         diff -u expected current'
 129
 130echo >expected ' no-funny
 131 "tabs\t,\" (dq) and spaces"
 132 2 files changed, 3 insertions(+), 3 deletions(-)'
 133
 134test_expect_success 'git-diff-tree delete with-funny applied' \
 135        'git-diff-index -p $t0 |
 136         git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 137         diff -u expected current'
 138
 139test_expect_success 'git-apply non-git diff' \
 140        'git-diff-index -p $t0 |
 141         sed -ne "/^[-+@]/p" |
 142         git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 143         diff -u expected current'
 144
 145test_done