t / t3005-ls-files-relative.shon commit Merge branch 'js/gitdir-at-unc-root' (b57a88a)
   1#!/bin/sh
   2
   3test_description='ls-files tests with relative paths
   4
   5This test runs git ls-files with various relative path arguments.
   6'
   7
   8. ./test-lib.sh
   9
  10sq=\'
  11
  12test_expect_success 'prepare' '
  13        : >never-mind-me &&
  14        git add never-mind-me &&
  15        mkdir top &&
  16        (
  17                cd top &&
  18                mkdir sub &&
  19                x="x xa xbc xdef xghij xklmno" &&
  20                y=$(echo "$x" | tr x y) &&
  21                touch $x &&
  22                touch $y &&
  23                cd sub &&
  24                git add ../x*
  25        )
  26'
  27
  28test_expect_success 'ls-files with mixed levels' '
  29        (
  30                cd top/sub &&
  31                cat >expect <<-EOF &&
  32                ../../never-mind-me
  33                ../x
  34                EOF
  35                git ls-files $(cat expect) >actual &&
  36                test_cmp expect actual
  37        )
  38'
  39
  40test_expect_success 'ls-files -c' '
  41        (
  42                cd top/sub &&
  43                for f in ../y*
  44                do
  45                        echo "error: pathspec $sq$f$sq did not match any file(s) known to git"
  46                done >expect.err &&
  47                echo "Did you forget to ${sq}git add${sq}?" >>expect.err &&
  48                ls ../x* >expect.out &&
  49                test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err &&
  50                test_cmp expect.out actual.out &&
  51                test_i18ncmp expect.err actual.err
  52        )
  53'
  54
  55test_expect_success 'ls-files -o' '
  56        (
  57                cd top/sub &&
  58                for f in ../x*
  59                do
  60                        echo "error: pathspec $sq$f$sq did not match any file(s) known to git"
  61                done >expect.err &&
  62                echo "Did you forget to ${sq}git add${sq}?" >>expect.err &&
  63                ls ../y* >expect.out &&
  64                test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err &&
  65                test_cmp expect.out actual.out &&
  66                test_i18ncmp expect.err actual.err
  67        )
  68'
  69
  70test_done