From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carl Worth Subject: [PATCH] Add test case for ls-files --with-head Date: Wed, 03 Oct 2007 08:50:30 -0700 Message-ID: <87odfgqjsp.wl%cworth@cworth.org> References: <1191390255.16292.2.camel@koto.keithp.com> <7vtzp8g2s2.fsf@gitster.siamese.dyndns.org> <87y7ekr86e.wl%cworth@cworth.org> <47038669.30302@viscovery.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: Junio C Hamano , Keith Packard , Git Mailing List To: Johannes Sixt X-From: git-owner@vger.kernel.org Wed Oct 03 17:50:58 2007 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1Id6Ul-0002oZ-2m for gcvg-git-2@gmane.org; Wed, 03 Oct 2007 17:50:43 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754326AbXJCPue (ORCPT ); Wed, 3 Oct 2007 11:50:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754763AbXJCPue (ORCPT ); Wed, 3 Oct 2007 11:50:34 -0400 Received: from olra.theworths.org ([82.165.184.25]:55796 "EHLO olra.theworths.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754305AbXJCPud (ORCPT ); Wed, 3 Oct 2007 11:50:33 -0400 Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 9A26F431FB3; Wed, 3 Oct 2007 08:50:32 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5U-pzOuCtg3U; Wed, 3 Oct 2007 08:50:31 -0700 (PDT) Received: from raht.cworth.org (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1BDC5431FB0; Wed, 3 Oct 2007 08:50:31 -0700 (PDT) In-Reply-To: <47038669.30302@viscovery.net> User-Agent: Wanderlust/2.14.0 (Africa) Emacs/21.4 Mule/5.0 (SAKAKI) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: 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 --- 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