This tests basic functionality and also exercises a bug noticed by Keith Packard, (prune_cache followed by add_index_entry can trigger an attempt to realloc a pointer into the middle of an allocated buffer). Signed-off-by: Carl Worth <cworth@xxxxxxxxxx> --- t/t3060-ls-files-with-head.sh | 55 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) create mode 100755 t/t3060-ls-files-with-head.sh On Wed, 03 Oct 2007 14:09:13 +0200, Johannes Sixt wrote: > seq is not universally available. Can we have that as Simple enough. I've included the amended patch, (and I even remembered to do the sign-off thing this time). Thanks, -Carl diff --git a/t/t3060-ls-files-with-head.sh b/t/t3060-ls-files-with-head.sh new file mode 100755 index 0000000..bc3ef58 --- /dev/null +++ b/t/t3060-ls-files-with-head.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (c) 2007 Carl D. Worth +# + +test_description='gt ls-files test (--with-head). + +This test runs git ls-files --with-head and in particular in +a scenario known to trigger a crash with some versions of git. +' +. ./test-lib.sh + +# The bug we're exercising requires a fair number of entries in a +# sub-directory so that add_index_entry will trigger a realloc +echo file > expected +mkdir sub +for i in 0 1 2 3 4; do + for j in 0 1 2 3 4 5 6 7 8 9; do + > sub/file-$i$j + echo file-$i$j >> expected + done +done +git add . +git commit -m "add a bunch of files" + +# We remove them all so that we'll have something to add back with +# --with-head and so that we'll definitely be under the realloc size +# to trigger the bug. +rm -r sub +git commit -a -m "remove them all" + +# The bug also requires some entry before our directory so that +# prune_path will modify the_index.cache +mkdir a_directory_that_sorts_before_sub +touch a_directory_that_sorts_before_sub/file +mkdir sub +touch sub/file +git add . + +# We have to run from a sub-directory to trigger prune_path +cd sub + +# Then we finally get to run our --with-tree test +test_expect_success \ + 'git -ls-files --with-tree should succeed.' \ + 'git ls-files --with-tree=HEAD~1 >../output' + +cd .. +test_expect_success \ + 'git -ls-files --with-tree should add entries from named tree.' \ + 'diff output expected' + +test_done + + -- 1.5.3.3.131.g34c6d - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html