git-gui: fix encoding in git-gui file browser
[git/dscho.git] / t / t3060-ls-files-with-tree.sh
blob61c1f53d1b75302be60396d2e01ccd5da5b6e5b4
1 #!/bin/sh
3 # Copyright (c) 2007 Carl D. Worth
6 test_description='git ls-files test (--with-tree).
8 This test runs git ls-files --with-tree and in particular in
9 a scenario known to trigger a crash with some versions of git.
11 . ./test-lib.sh
13 test_expect_success setup '
15 # The bug we are exercising requires a fair number of entries
16 # in a sub-directory so that add_index_entry will trigger a
17 # realloc.
19 echo file >expected &&
20 mkdir sub &&
21 bad= &&
22 for n in 0 1 2 3 4 5
24 for m in 0 1 2 3 4 5 6 7 8 9
26 num=00$n$m &&
27 >sub/file-$num &&
28 echo file-$num >>expected || {
29 bad=t
30 break
32 done && test -z "$bad" || {
33 bad=t
34 break
36 done && test -z "$bad" &&
37 git add . &&
38 git commit -m "add a bunch of files" &&
40 # We remove them all so that we will have something to add
41 # back with --with-tree and so that we will definitely be
42 # under the realloc size to trigger the bug.
43 rm -rf sub &&
44 git commit -a -m "remove them all" &&
46 # The bug also requires some entry before our directory so that
47 # prune_path will modify the_index.cache
49 mkdir a_directory_that_sorts_before_sub &&
50 >a_directory_that_sorts_before_sub/file &&
51 mkdir sub &&
52 >sub/file &&
53 git add .
56 test_expect_success 'git -ls-files --with-tree should succeed from subdir' '
57 # We have to run from a sub-directory to trigger prune_path
58 # Then we finally get to run our --with-tree test
60 cd sub &&
61 git ls-files --with-tree=HEAD~1 >../output
65 test_expect_success \
66 'git -ls-files --with-tree should add entries from named tree.' \
67 'test_cmp expected output'
69 test_done