t / t3300-funny-names.shon commit Revert "get_sha1_basic(): corner case ambiguity fix" (c054d64)
   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# since FAT/NTFS does not allow tabs in filenames, skip this test
  13test "$(uname -o 2>/dev/null)" = Cygwin && exit 0
  14
  15. ./test-lib.sh
  16
  17p0='no-funny'
  18p1='tabs        ," (dq) and spaces'
  19p2='just space'
  20
  21cat >"$p0" <<\EOF
  221. A quick brown fox jumps over the lazy cat, oops dog.
  232. A quick brown fox jumps over the lazy cat, oops dog.
  243. A quick brown fox jumps over the lazy cat, oops dog.
  25EOF
  26
  27cat >"$p1" "$p0"
  28echo 'Foo Bar Baz' >"$p2"
  29
  30echo 'just space
  31no-funny' >expected
  32test_expect_success 'git-ls-files no-funny' \
  33        'git-update-index --add "$p0" "$p2" &&
  34        git-ls-files >current &&
  35        diff -u expected current'
  36
  37t0=`git-write-tree`
  38echo "$t0" >t0
  39
  40echo 'just space
  41no-funny
  42"tabs\t,\" (dq) and spaces"' >expected
  43test_expect_success 'git-ls-files with-funny' \
  44        'git-update-index --add "$p1" &&
  45        git-ls-files >current &&
  46        diff -u expected current'
  47
  48echo 'just space
  49no-funny
  50tabs    ," (dq) and spaces' >expected
  51test_expect_success 'git-ls-files -z with-funny' \
  52        'git-ls-files -z | tr \\0 \\012 >current &&
  53        diff -u expected current'
  54
  55t1=`git-write-tree`
  56echo "$t1" >t1
  57
  58echo 'just space
  59no-funny
  60"tabs\t,\" (dq) and spaces"' >expected
  61test_expect_success 'git-ls-tree with funny' \
  62        'git-ls-tree -r $t1 | sed -e "s/^[^     ]*      //" >current &&
  63         diff -u expected current'
  64
  65echo 'A "tabs\t,\" (dq) and spaces"' >expected
  66test_expect_success 'git-diff-index with-funny' \
  67        'git-diff-index --name-status $t0 >current &&
  68        diff -u expected current'
  69
  70test_expect_success 'git-diff-tree with-funny' \
  71        'git-diff-tree --name-status $t0 $t1 >current &&
  72        diff -u expected current'
  73
  74echo 'A
  75tabs    ," (dq) and spaces' >expected
  76test_expect_success 'git-diff-index -z with-funny' \
  77        'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
  78        diff -u expected current'
  79
  80test_expect_success 'git-diff-tree -z with-funny' \
  81        'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
  82        diff -u expected current'
  83
  84echo 'CNUM      no-funny        "tabs\t,\" (dq) and spaces"' >expected
  85test_expect_success 'git-diff-tree -C with-funny' \
  86        'git-diff-tree -C --find-copies-harder --name-status \
  87                $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
  88        diff -u expected current'
  89
  90echo 'RNUM      no-funny        "tabs\t,\" (dq) and spaces"' >expected
  91test_expect_success 'git-diff-tree delete with-funny' \
  92        'git-update-index --force-remove "$p0" &&
  93        git-diff-index -M --name-status \
  94                $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
  95        diff -u expected current'
  96
  97echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
  98similarity index NUM%
  99rename from no-funny
 100rename to "tabs\t,\" (dq) and spaces"' >expected
 101
 102test_expect_success 'git-diff-tree delete with-funny' \
 103        'git-diff-index -M -p $t0 |
 104         sed -e "s/index [0-9]*%/index NUM%/" >current &&
 105         diff -u expected current'
 106
 107chmod +x "$p1"
 108echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
 109old mode 100644
 110new mode 100755
 111similarity index NUM%
 112rename from no-funny
 113rename to "tabs\t,\" (dq) and spaces"' >expected
 114
 115test_expect_success 'git-diff-tree delete with-funny' \
 116        'git-diff-index -M -p $t0 |
 117         sed -e "s/index [0-9]*%/index NUM%/" >current &&
 118         diff -u expected current'
 119
 120echo >expected ' "tabs\t,\" (dq) and spaces"
 121 1 files changed, 0 insertions(+), 0 deletions(-)'
 122test_expect_success 'git-diff-tree rename with-funny applied' \
 123        'git-diff-index -M -p $t0 |
 124         git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 125         diff -u expected current'
 126
 127echo >expected ' no-funny
 128 "tabs\t,\" (dq) and spaces"
 129 2 files changed, 3 insertions(+), 3 deletions(-)'
 130
 131test_expect_success 'git-diff-tree delete with-funny applied' \
 132        'git-diff-index -p $t0 |
 133         git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 134         diff -u expected current'
 135
 136test_expect_success 'git-apply non-git diff' \
 137        'git-diff-index -p $t0 |
 138         sed -ne "/^[-+@]/p" |
 139         git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 140         diff -u expected current'
 141
 142test_done