ce5585ebb173834e629ea650db907840916917d7
   1#!/bin/sh
   2
   3test_description='magic pathspec tests using git-add'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        mkdir sub anothersub &&
   9        : >sub/foo &&
  10        : >anothersub/foo
  11'
  12
  13test_expect_success 'add :/' "
  14        cat >expected <<-EOF &&
  15        add 'anothersub/foo'
  16        add 'expected'
  17        add 'sub/actual'
  18        add 'sub/foo'
  19        EOF
  20        (cd sub && git add -n :/ >actual) &&
  21        test_cmp expected sub/actual
  22"
  23
  24cat >expected <<EOF
  25add 'anothersub/foo'
  26EOF
  27
  28test_expect_success 'add :/anothersub' '
  29        (cd sub && git add -n :/anothersub >actual) &&
  30        test_cmp expected sub/actual
  31'
  32
  33test_expect_success 'add :/non-existent' '
  34        (cd sub && test_must_fail git add -n :/non-existent)
  35'
  36
  37cat >expected <<EOF
  38add 'sub/foo'
  39EOF
  40
  41test_expect_success 'a file with the same (long) magic name exists' '
  42        : >":(icase)ha" &&
  43        test_must_fail git add -n ":(icase)ha" &&
  44        git add -n "./:(icase)ha"
  45'
  46
  47test_expect_success 'a file with the same (short) magic name exists' '
  48        mkdir ":" &&
  49        : >":/bar" &&
  50        test_must_fail git add -n :/bar &&
  51        git add -n "./:/bar"
  52'
  53
  54test_done