t / t3005-ls-files-relative.shon commit Merge branch 'tr/maint-strbuf-grow-nul-termination' (5e2b3d7)
   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
  10new_line='
  11'
  12sq=\'
  13
  14test_expect_success 'prepare' '
  15        : >never-mind-me &&
  16        git add never-mind-me &&
  17        mkdir top &&
  18        (
  19                cd top &&
  20                mkdir sub &&
  21                x="x xa xbc xdef xghij xklmno" &&
  22                y=$(echo "$x" | tr x y) &&
  23                touch $x &&
  24                touch $y &&
  25                cd sub &&
  26                git add ../x*
  27        )
  28'
  29
  30test_expect_success 'ls-files with mixed levels' '
  31        (
  32                cd top/sub &&
  33                cat >expect <<-EOF &&
  34                ../../never-mind-me
  35                ../x
  36                EOF
  37                git ls-files $(cat expect) >actual &&
  38                test_cmp expect actual
  39        )
  40'
  41
  42test_expect_success 'ls-files -c' '
  43        (
  44                cd top/sub &&
  45                for f in ../y*
  46                do
  47                        echo "error: pathspec $sq$f$sq did not match any file(s) known to git."
  48                done >expect &&
  49                echo "Did you forget to ${sq}git add${sq}?" >>expect &&
  50                ls ../x* >>expect &&
  51                test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual 2>&1 &&
  52                test_cmp expect actual
  53        )
  54'
  55
  56test_expect_success 'ls-files -o' '
  57        (
  58                cd top/sub &&
  59                for f in ../x*
  60                do
  61                        echo "error: pathspec $sq$f$sq did not match any file(s) known to git."
  62                done >expect &&
  63                echo "Did you forget to ${sq}git add${sq}?" >>expect &&
  64                ls ../y* >>expect &&
  65                test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual 2>&1 &&
  66                test_cmp expect actual
  67        )
  68'
  69
  70test_done