ec310d59386c1ab8de9e1d4d37aa69093234c9ed
   1#!/bin/sh
   2
   3test_description='check that read-tree rejects confusing paths'
   4. ./test-lib.sh
   5
   6test_expect_success 'create base tree' '
   7        echo content >file &&
   8        git add file &&
   9        git commit -m base &&
  10        blob=$(git rev-parse HEAD:file) &&
  11        tree=$(git rev-parse HEAD^{tree})
  12'
  13
  14test_expect_success 'enable core.protectHFS for rejection tests' '
  15        git config core.protectHFS true
  16'
  17
  18while read path pretty; do
  19        : ${pretty:=$path}
  20        test_expect_success "reject $pretty at end of path" '
  21                printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
  22                bogus=$(git mktree <tree) &&
  23                test_must_fail git read-tree $bogus
  24        '
  25
  26        test_expect_success "reject $pretty as subtree" '
  27                printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
  28                bogus=$(git mktree <tree) &&
  29                test_must_fail git read-tree $bogus
  30        '
  31done <<-EOF
  32.
  33..
  34.git
  35.GIT
  36${u200c}.Git {u200c}.Git
  37.gI${u200c}T .gI{u200c}T
  38.GiT${u200c} .GiT{u200c}
  39EOF
  40
  41test_expect_success 'utf-8 paths allowed with core.protectHFS off' '
  42        test_when_finished "git read-tree HEAD" &&
  43        test_config core.protectHFS false &&
  44        printf "100644 blob %s\t%s" "$blob" ".gi${u200c}t" >tree &&
  45        ok=$(git mktree <tree) &&
  46        git read-tree $ok
  47'
  48
  49test_done