t / t3000-ls-files-others.shon commit Merge branch 'js/maint-diff-temp-smudge' (b71fdc5)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='git ls-files test (--others should pick up symlinks).
   7
   8This test runs git ls-files --others with the following on the
   9filesystem.
  10
  11    path0       - a file
  12    path1       - a symlink
  13    path2/file2 - a file in a directory
  14    path3-junk  - a file to confuse things
  15    path3/file3 - a file in a directory
  16    path4       - an empty directory
  17'
  18. ./test-lib.sh
  19
  20date >path0
  21if test_have_prereq SYMLINKS
  22then
  23        ln -s xyzzy path1
  24else
  25        date > path1
  26fi
  27mkdir path2 path3 path4
  28date >path2/file2
  29date >path2-junk
  30date >path3/file3
  31date >path3-junk
  32git update-index --add path3-junk path3/file3
  33
  34cat >expected1 <<EOF
  35expected1
  36expected2
  37expected3
  38output
  39path0
  40path1
  41path2-junk
  42path2/file2
  43EOF
  44sed -e 's|path2/file2|path2/|' <expected1 >expected2
  45cat <expected2 >expected3
  46echo path4/ >>expected2
  47
  48test_expect_success \
  49    'git ls-files --others to show output.' \
  50    'git ls-files --others >output'
  51
  52test_expect_success \
  53    'git ls-files --others should pick up symlinks.' \
  54    'test_cmp expected1 output'
  55
  56test_expect_success \
  57    'git ls-files --others --directory to show output.' \
  58    'git ls-files --others --directory >output'
  59
  60
  61test_expect_success \
  62    'git ls-files --others --directory should not get confused.' \
  63    'test_cmp expected2 output'
  64
  65test_expect_success \
  66    'git ls-files --others --directory --no-empty-directory to show output.' \
  67    'git ls-files --others --directory --no-empty-directory >output'
  68
  69test_expect_success \
  70    '--no-empty-directory hides empty directory' \
  71    'test_cmp expected3 output'
  72
  73test_done