From patchwork Wed Jan 2 04:34:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 10746069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C37A8746 for ; Wed, 2 Jan 2019 04:37:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B373A285A6 for ; Wed, 2 Jan 2019 04:37:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7963285BE; Wed, 2 Jan 2019 04:37:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EEA5285AA for ; Wed, 2 Jan 2019 04:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728451AbfABEhd (ORCPT ); Tue, 1 Jan 2019 23:37:33 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38388 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728432AbfABEhd (ORCPT ); Tue, 1 Jan 2019 23:37:33 -0500 Received: by mail-pl1-f194.google.com with SMTP id e5so14029163plb.5 for ; Tue, 01 Jan 2019 20:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kI0l/8Ye2iyV9ZCf9gyiXUBXsZaFP0x8pmAjvmnaHCI=; b=JjtQl3zwVMlxccZ2xFTaCrf0gK0WpWcYJznLZrzDiePzV5nXhY1iidDej8NKkrPrOk E0+UTpw/GWPTqkXB3WvyoGV8xhx0DC40rMFc9nyb2uwbXop7TSO3rVMY3AyRFeyN54G/ x81gvAyCPnplm6Sq63GWAMHC4iUiOxX79LLiXEUYzL1uaIT+OySZSkPeEnMVY3oMY3Nq uP/dr0nCbJt8O3JTpzXyIPrHVq9bQwvd8q+LyQiJ9Hsz77NLTNoVxlOR758xlrGaxfzO JJbIuoK0ZloTD5hf94o0bRA7uT9955PEHhiKTIuinKYZehqa/dZl45u+L3KSN4yTfwaJ tNYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kI0l/8Ye2iyV9ZCf9gyiXUBXsZaFP0x8pmAjvmnaHCI=; b=Kmv1NtARyaIYJrqddB566Dga1y+h7VecI++rs3Ld3MTi75qDpIvQsmCnWF21Jk1RHF 6CWx3MmjJfqwX9UJIkts1P6OkWWV198S9P0ahZB22axEFsq/8t0WXde6dexxX/SMZMKX qevhH+oGelWSB+GrrVQ4Uej9QKfGNistaDpxQyTJNJG8gBcYNuOF3lF7LzqHWGUQ8MJ2 ZCinbNBJdYycUeB21KKpTIMB2QUc5l5SPXA3AS3GGk6RQbkuKk9/zorMCU5FLayK25cJ zWJGfIJK+lVxcGTMCgUA+xpCqHX/6b/puhOZuCa+CgtIoenuIUmjWqfr0JJlGLrL5QQ3 zTZg== X-Gm-Message-State: AJcUukdbBKAEbO/q5y1Nz9WBF3r0/QJ+VIxyRlOUc0Nf92QQaCQrA/Gx mcmEa57teQ+reNdGj0MEe1o= X-Google-Smtp-Source: ALg8bN5mFdCQlsdtgBFKgMGxB5oAzwSJA7OEHUzd1DZkQfXTfyM2QyUUmMBrMTYgrubueck1qkj9Rw== X-Received: by 2002:a17:902:c5:: with SMTP id a63mr42838014pla.267.1546403852587; Tue, 01 Jan 2019 20:37:32 -0800 (PST) Received: from GotGit.hz.ali.com ([106.11.34.207]) by smtp.gmail.com with ESMTPSA id b27sm75904397pfh.113.2019.01.01.20.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Jan 2019 20:37:32 -0800 (PST) From: Jiang Xin To: Sun Chao , Git List , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 1/3] t5323: test cases for git-pack-redundant Date: Wed, 2 Jan 2019 12:34:54 +0800 Message-Id: <20190102043456.15652-2-worldhello.net@gmail.com> X-Mailer: git-send-email 2.20.0.3.gc45e608566 In-Reply-To: <20181219121451.21697-1-worldhello.net@gmail.com> References: <20181219121451.21697-1-worldhello.net@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiang Xin Add test cases for git pack-redundant to validate new algorithm for git pack-redundant. Signed-off-by: Jiang Xin --- t/t5323-pack-redundant.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 t/t5323-pack-redundant.sh diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh new file mode 100755 index 0000000000..ef6076f065 --- /dev/null +++ b/t/t5323-pack-redundant.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# +# Copyright (c) 2018 Jiang Xin +# + +test_description='git redundant test' + +. ./test-lib.sh + +create_commits() +{ + set -e + parent= + for name in A B C D E F G H I J K L M + do + test_tick + T=$(git write-tree) + if test -z "$parent" + then + sha1=$(echo $name | git commit-tree $T) + else + sha1=$(echo $name | git commit-tree -p $parent $T) + fi + eval $name=$sha1 + parent=$sha1 + done + git update-ref refs/heads/master $M +} + +create_redundant_packs() +{ + set -e + cd .git/objects/pack + P1=$(printf "$T\n$A\n" | git pack-objects pack 2>/dev/null) + P2=$(printf "$T\n$A\n$B\n$C\n$D\n$E\n" | git pack-objects pack 2>/dev/null) + P3=$(printf "$C\n$D\n$F\n$G\n$I\n$J\n" | git pack-objects pack 2>/dev/null) + P4=$(printf "$D\n$E\n$G\n$H\n$J\n$K\n" | git pack-objects pack 2>/dev/null) + P5=$(printf "$F\n$G\n$H\n" | git pack-objects pack 2>/dev/null) + P6=$(printf "$F\n$I\n$L\n" | git pack-objects pack 2>/dev/null) + P7=$(printf "$H\n$K\n$M\n" | git pack-objects pack 2>/dev/null) + P8=$(printf "$L\n$M\n" | git pack-objects pack 2>/dev/null) + cd - + eval P$P1=P1:$P1 + eval P$P2=P2:$P2 + eval P$P3=P3:$P3 + eval P$P4=P4:$P4 + eval P$P5=P5:$P5 + eval P$P6=P6:$P6 + eval P$P7=P7:$P7 + eval P$P8=P8:$P8 +} + +# Create commits and packs +create_commits +create_redundant_packs + +test_expect_success 'clear loose objects' ' + git prune-packed && + test $(find .git/objects -type f | grep -v pack | wc -l) -eq 0 +' + +cat >expected < actual && \ + test_cmp expected actual +' + +test_expect_success 'remove redundant packs' ' + git pack-redundant --all | xargs rm && + git fsck && + test $(git pack-redundant --all | wc -l) -eq 0 +' + +test_done