t / t3010-ls-files-killed-modified.shon commit Whip post 1.5.3.3 maintenance series into shape. (5946d4b)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='git ls-files -k and -m flags test.
   7
   8This test prepares the following in the cache:
   9
  10    path0       - a file
  11    path1       - a symlink
  12    path2/file2 - a file in a directory
  13    path3/file3 - a file in a directory
  14
  15and the following on the filesystem:
  16
  17    path0/file0 - a file in a directory
  18    path1/file1 - a file in a directory
  19    path2       - a file
  20    path3       - a symlink
  21    path4       - a file
  22    path5       - a symlink
  23    path6/file6 - a file in a directory
  24
  25git ls-files -k should report that existing filesystem
  26objects except path4, path5 and path6/file6 to be killed.
  27
  28Also for modification test, the cache and working tree have:
  29
  30    path7       - an empty file, modified to a non-empty file.
  31    path8       - a non-empty file, modified to an empty file.
  32    path9       - an empty file, cache dirtied.
  33    path10      - a non-empty file, cache dirtied.
  34
  35We should report path0, path1, path2/file2, path3/file3, path7 and path8
  36modified without reporting path9 and path10.
  37'
  38. ./test-lib.sh
  39
  40date >path0
  41ln -s xyzzy path1
  42mkdir path2 path3
  43date >path2/file2
  44date >path3/file3
  45: >path7
  46date >path8
  47: >path9
  48date >path10
  49test_expect_success \
  50    'git update-index --add to add various paths.' \
  51    "git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10"
  52
  53rm -fr path? ;# leave path10 alone
  54date >path2
  55ln -s frotz path3
  56ln -s nitfol path5
  57mkdir path0 path1 path6
  58date >path0/file0
  59date >path1/file1
  60date >path6/file6
  61date >path7
  62: >path8
  63: >path9
  64touch path10
  65
  66test_expect_success \
  67    'git ls-files -k to show killed files.' \
  68    'git ls-files -k >.output'
  69cat >.expected <<EOF
  70path0/file0
  71path1/file1
  72path2
  73path3
  74EOF
  75
  76test_expect_success \
  77    'validate git ls-files -k output.' \
  78    'diff .output .expected'
  79
  80test_expect_success \
  81    'git ls-files -m to show modified files.' \
  82    'git ls-files -m >.output'
  83cat >.expected <<EOF
  84path0
  85path1
  86path2/file2
  87path3/file3
  88path7
  89path8
  90EOF
  91
  92test_expect_success \
  93    'validate git ls-files -m output.' \
  94    'diff .output .expected'
  95
  96test_done