t / t3010-ls-files-killed-modified.shon commit sha1-lookup: handle duplicate keys with GIT_USE_LOOKUP (171bdac)
   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
  40test_expect_success 'git update-index --add to add various paths.' '
  41        date >path0 &&
  42        test_ln_s_add xyzzy path1 &&
  43        mkdir path2 path3 &&
  44        date >path2/file2 &&
  45        date >path3/file3 &&
  46        : >path7 &&
  47        date >path8 &&
  48        : >path9 &&
  49        date >path10 &&
  50        git update-index --add -- path0 path?/file? path7 path8 path9 path10 &&
  51        rm -fr path?    # leave path10 alone
  52'
  53
  54test_expect_success 'git ls-files -k to show killed files.' '
  55        date >path2 &&
  56        if test_have_prereq SYMLINKS
  57        then
  58                ln -s frotz path3 &&
  59                ln -s nitfol path5
  60        else
  61                date >path3 &&
  62                date >path5
  63        fi &&
  64        mkdir path0 path1 path6 &&
  65        date >path0/file0 &&
  66        date >path1/file1 &&
  67        date >path6/file6 &&
  68        date >path7 &&
  69        : >path8 &&
  70        : >path9 &&
  71        touch path10 &&
  72        git ls-files -k >.output
  73'
  74
  75test_expect_success 'validate git ls-files -k output.' '
  76        cat >.expected <<-\EOF &&
  77        path0/file0
  78        path1/file1
  79        path2
  80        path3
  81        EOF
  82        test_cmp .expected .output
  83'
  84
  85test_expect_success 'git ls-files -m to show modified files.' '
  86        git ls-files -m >.output
  87'
  88
  89test_expect_success 'validate git ls-files -m output.' '
  90        cat >.expected <<-\EOF &&
  91        path0
  92        path1
  93        path2/file2
  94        path3/file3
  95        path7
  96        path8
  97        EOF
  98        test_cmp .expected .output
  99'
 100
 101test_done