From patchwork Wed Dec 4 22:03:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11273661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3C946C1 for ; Wed, 4 Dec 2019 22:03:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DC892073C for ; Wed, 4 Dec 2019 22:03:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mzVIdCDh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728135AbfLDWDP (ORCPT ); Wed, 4 Dec 2019 17:03:15 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45048 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727989AbfLDWDP (ORCPT ); Wed, 4 Dec 2019 17:03:15 -0500 Received: by mail-pl1-f193.google.com with SMTP id d19so282095pls.11 for ; Wed, 04 Dec 2019 14:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kbJBz6lo+xgCtsxlGt18hk9MuyrM8XiQvoH6NL1DSIU=; b=mzVIdCDhYLjolYnmPMufskCYcE0O02N4/eh1fYV3wLKy/hH+VmeCxhCZH+aRKVn0mM HWIk5rk2B8amVJHqS/ZnUtQF7skvnXGqGD5B6Do6rqSepewbkdrMkp90r28d/f9ULuqF gl8dqhzJmpb2MQ+e7N3+AfjLcqk1sWzpT5BcKr3nV9kflKTXKeh8eCYpYh9COH7Tx8Ho 82v5q4LkQHhykgUI5CK4NQhssWFBAydBIlUmKQ68RTxsMVXpL3Bl9E6FYrq8AQ86P8B4 6TCAUqycbQ9HUnWdXQtlIG8V1ndSIw0V+u5przrFcQYpcunoaLTR/LLwcz8+zj7nRCtt eXgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kbJBz6lo+xgCtsxlGt18hk9MuyrM8XiQvoH6NL1DSIU=; b=YOnyhzaGhQdkHrnUQ7ov9ddFroiAh+xO/USXmYRETvqvLJPMytrStoX7RM7d4wNMT8 VROOQcgpkDPsIlCS0zEDbK0PkLvrwEfXaB71FHBZSwNpYe4U0JJ7px3ydtLtGDGpdfP/ dotDnlAChVzROOWXeCIo8gZnUvHv9kk24CWYVMBnKHMvOqifadQT5FICm+Yqi7hj/jtw 4xMeX7PEf/GFjzUavDKrsbk1+iBBqXWCwlO3cCCjJ0kS+xqE8A2SHOvQMVNnojDgNjQ9 cr25OLeZQ9j2ph9sDz2Nhbrv0f/o4uXMWvrcYqvSXnHnHTWx31iOjGu5I7VXVbRzXNfK C3Ow== X-Gm-Message-State: APjAAAUrl3VxpvTw9VrTgqTVRHIIKq+1F/Usy1yftHMdujIpUrv7ruuv JlP5QhmQWASnXC48VKxgHgqMiOin X-Google-Smtp-Source: APXvYqz9tVdlG34Erz7epngy9ASxDDHd8x2nvf4j/QxMgyQXo1c0RI9YYU7S0aEvEmaaKhqIMSbyAA== X-Received: by 2002:a17:90a:c095:: with SMTP id o21mr5679993pjs.41.1575496994341; Wed, 04 Dec 2019 14:03:14 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id p68sm9648732pfp.149.2019.12.04.14.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 14:03:13 -0800 (PST) Date: Wed, 4 Dec 2019 14:03:09 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v6 1/5] t7700: consolidate code into test_no_missing_in_packs() Message-ID: <3008ce8deb4055f39fd4e1331b30666b40b26eaa.1575496684.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The code to test that objects were not missing from the packfile was duplicated many times. Extract the duplicated code into test_no_missing_in_packs() and use that instead. Refactor the resulting extraction so that if any git commands fail, their return codes are not silently lost. Instead of verifying each file of `alt_objects/pack/*.idx` individually in a for-loop, batch them together into one verification step. The original testing construct was O(n^2): it used a grep in a loop to test whether any objects were missing in the packfile. Rewrite this to extract the hash using sed or cut, sort the files, then use `comm -23` so that finding missing lines from the original file is done more efficiently. While we're at it, add a space to `commit_and_pack ()` for style. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 55 +++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 1d14ddcbdb..5fb9e99f34 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -4,12 +4,23 @@ test_description='git repack works correctly' . ./test-lib.sh -commit_and_pack() { +commit_and_pack () { test_commit "$@" 1>&2 && SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack orig.raw && + sed -n -e "s/^\([0-9a-f]\{40\}\).*/\1/p" orig.raw | sort >orig && + git verify-pack -v $myidx >dest.raw && + cut -d" " -f1 dest.raw | sort >dest && + comm -23 orig dest >missing && + test_must_be_empty missing +} + test_expect_success 'objects in packs marked .keep are not repacked' ' echo content1 >file1 && echo content2 >file2 && @@ -105,19 +116,7 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is mkdir alt_objects/pack && mv .git/objects/pack/* alt_objects/pack && git repack -a && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test_path_is_file "$myidx" && - for p in alt_objects/pack/*.idx - do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest - do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ) - then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' ' @@ -128,19 +127,7 @@ test_expect_success 'packed obs in alt ODB are repacked when local repo has pack git commit -m more_content && git repack && git repack -a -d && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test_path_is_file "$myidx" && - for p in alt_objects/pack/*.idx - do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest - do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ) - then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' @@ -156,19 +143,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' fi done && git repack -a -d && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test_path_is_file "$myidx" && - for p in alt_objects/pack/*.idx - do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest - do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ) - then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' From patchwork Wed Dec 4 22:03:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11273663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A8D46C1 for ; Wed, 4 Dec 2019 22:03:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7617C21826 for ; Wed, 4 Dec 2019 22:03:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a1N0Qcjk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728229AbfLDWDU (ORCPT ); Wed, 4 Dec 2019 17:03:20 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35374 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727989AbfLDWDU (ORCPT ); Wed, 4 Dec 2019 17:03:20 -0500 Received: by mail-pg1-f194.google.com with SMTP id l24so521794pgk.2 for ; Wed, 04 Dec 2019 14:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=b60uezCEopvQvo36hmyWSpQLOhAgYwOufKH99W8KA34=; b=a1N0Qcjk5RO/Bdt2TZv/UVoUvlthAsRVKC8iVO6X0UjFS7ZoMTtAmr7jJ6sJ/02Gyk R051DRMIvi+KdhiLzpL1XOPVlsBWibny+xeVxNauP/cJPwTpnB/FAJ01NEK4Q9xIZT/q Sr4u1P/ymSqLaMQfTZiZdTngJOQ+o45E6YihiI33SD8USBAuPC6BvrTQkzk9JS1aHM35 wXC7Hcw2mX8LEbfqMcogkS5hU+I4gSe/EtYl40sJByBq7ns36wbgw+MaBLLJ3kDYp4mU IbOJRM9LWucWFnEtrVHL2e7bSR5AtOdXwjHvCGyxAo7sSIPlaBVql0GL6hOdsGDu15LK Okkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=b60uezCEopvQvo36hmyWSpQLOhAgYwOufKH99W8KA34=; b=AbwIFiLKPIIlCXjdyVOZaqWMSRFdVAHNmRgCpKDnIwuAk5ySIvwPDm31kts5GuOGyK Rfz13P6CeIXW+eh55s2Wd4acJ+36LAIMwoo7WzGon9RZ8HLXYxpC7YXNTI28wpiUWFWz I9ovoXl61vSXIRWsm1C+SuyD8ySYy8tk/dFpK6+FLeo06qOh1jNmIaqqQ9MTk3N4hJx1 l2Y/yf7L+zzBnJL2PvpUSCY5FDjKmgG6Di30uOFz/VWlBwubgDxcPGdNX0mCpTsIKV3q ezajDhvBWVcnF8YYS3Ti4nsAbEoNmxUjn26vk4V9vZTO5x8XODf2lvVghH78/TFXXIGm YW4w== X-Gm-Message-State: APjAAAUIAnZfjz6iklj/o+kR+FP57mxDGQFVjekJCIWBM1AcIJR3w1db QKlsBYr10nEN0gMkBM25v0Rx8uWN X-Google-Smtp-Source: APXvYqzh0afnatYvp5UTvmVvf9vFbNqZrIAhAQwF9ADfewzYvoz6tirFO5oG1lvm6aOGNIVIlGO39w== X-Received: by 2002:a63:a449:: with SMTP id c9mr5788709pgp.53.1575496999377; Wed, 04 Dec 2019 14:03:19 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id v8sm7873925pfn.76.2019.12.04.14.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 14:03:18 -0800 (PST) Date: Wed, 4 Dec 2019 14:03:14 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v6 2/5] t7700: consolidate code into test_has_duplicate_object() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The code to test that objects were not duplicated from the packfile was duplicated many times. Extract the duplicated code into test_has_duplicate_object() and use that instead. Refactor the resulting extraction so that if the git command fails, the return code is not silently lost. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 71 +++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 5fb9e99f34..80ded48088 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -21,6 +21,25 @@ test_no_missing_in_packs () { test_must_be_empty missing } +# we expect $packsha1 and $objsha1 to be defined +test_has_duplicate_object () { + want_duplicate_object="$1" + found_duplicate_object=false + for p in .git/objects/pack/*.idx + do + idx=$(basename $p) + test "pack-$packsha1.idx" = "$idx" && continue + git verify-pack -v $p >packlist || return $? + if egrep "^$objsha1" packlist + then + found_duplicate_object=true + echo "DUPLICATE OBJECT FOUND" + break + fi + done && + test "$want_duplicate_object" = "$found_duplicate_object" +} + test_expect_success 'objects in packs marked .keep are not repacked' ' echo content1 >file1 && echo content2 >file2 && @@ -40,54 +59,19 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && - for p in .git/objects/pack/*.idx - do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test -z "$found_duplicate_object" + test_has_duplicate_object false ' test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' ' # build on $objsha1, $packsha1, and .keep state from previous git repack -Adbl && - test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx - do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test "$found_duplicate_object" = 1 + test_has_duplicate_object true ' test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' # build on $objsha1, $packsha1, and .keep state from previous git -c repack.writebitmaps=true repack -Adl && - test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx - do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test "$found_duplicate_object" = 1 + test_has_duplicate_object true ' test_expect_success 'loose objects in alternate ODB are not repacked' ' @@ -100,16 +84,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' ' git commit -m commit_file3 && git repack -a -d -l && git prune-packed && - for p in .git/objects/pack/*.idx - do - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test -z "$found_duplicate_object" + test_has_duplicate_object false ' test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' ' From patchwork Wed Dec 4 22:03:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11273665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB1666C1 for ; Wed, 4 Dec 2019 22:03:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7C362186D for ; Wed, 4 Dec 2019 22:03:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aJJz0Vdi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbfLDWD0 (ORCPT ); Wed, 4 Dec 2019 17:03:26 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:44498 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727989AbfLDWDZ (ORCPT ); Wed, 4 Dec 2019 17:03:25 -0500 Received: by mail-pj1-f68.google.com with SMTP id w5so354152pjh.11 for ; Wed, 04 Dec 2019 14:03:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wQAWHVnUI9MZ2leYUkYV6h6KgNbJhq8DQeyyJJG6pZc=; b=aJJz0VdiBai8uCYaWeq8NKjYRaRATUZmOF+QPwcHJUv/xoavN9TcrbQctCE+WGbFuD I+CgMMXbKZZLTIErJ/CnIE3BdhDhliIh0lHhuajx2E0UEHeWMNhdiL8L4EHsvKyovOp6 UvbwydVvXuaaxpVby08ZmwQ8ouuD3sWY+GyBo/a77oPpA3XLuI+T+jmFlyY/kl2o4pyP BlfXLJaybEo8tUOSJXNkRs4NiVeyCDT9BcuZrKF0EWXulxy4hr4z09UrNuUDrcaAbSqE EkNTWnIscbJao+hj2fMNGZiEAFVyQ5Q4Al+BEHtAJo323PByOfEOSjwMfAt+1NmAF9J6 M8TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wQAWHVnUI9MZ2leYUkYV6h6KgNbJhq8DQeyyJJG6pZc=; b=VBlx24kKBkRb6TWHJoq+04VQM2FKie5QLjzB3jP8PrL5nGh6QD95tWnyMduN7gOnXj ZBAET0vDD9DZOhgSlAh40xjKd7NNOfT9PEoL7BNyq99Gf+t2lQAkkjOBbnrBaVu1covd +VbbupmahOA2kEC9W2BENjOv6/4DKXKzUoQvgcynFeswDlPkhwDSvrs9a3LRNylip8UI NY0MBJ/jmlj9o1bvTr4UksdoUm+pYqr8JiEENP+0NJue1ZfeIJL7/ip3/V0+tuXaVOG0 MOVO8qn7VdTtW2/9UMUCN4c0puRW+fMolnrLORvEvx8HFN7Ls4q/IsdCQkAhABrZVyY+ XyMA== X-Gm-Message-State: APjAAAUOpuQst6bw0oR2qihVfZaGrQHNW0Ga79vXh9kSnXkNNNXnRXJ4 Z5480V6H7+xSlTOleAefNBTbL5RV X-Google-Smtp-Source: APXvYqwDvMPkzgBRNYefUxv6rARn58hUxkbWopNeINiYXhBoSgfMq8E/Gvmmwn5JVesM3bDyi8A8cA== X-Received: by 2002:a17:902:8d83:: with SMTP id v3mr5566167plo.205.1575497004520; Wed, 04 Dec 2019 14:03:24 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id 20sm8194268pgw.71.2019.12.04.14.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 14:03:23 -0800 (PST) Date: Wed, 4 Dec 2019 14:03:19 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v6 3/5] t7700: replace egrep with grep Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The egrep expressions in this test suite were of the form `^$variable`. Although egrep works just fine, it's overkill since we're not using any extended regex. Replace egrep invocations with grep so that we aren't swatting flies with a sledgehammer. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 80ded48088..bfef5888a2 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -30,7 +30,7 @@ test_has_duplicate_object () { idx=$(basename $p) test "pack-$packsha1.idx" = "$idx" && continue git verify-pack -v $p >packlist || return $? - if egrep "^$objsha1" packlist + if grep "^$objsha1" packlist then found_duplicate_object=true echo "DUPLICATE OBJECT FOUND" @@ -135,7 +135,7 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - egrep "^$csha1 " | sort | uniq | wc -l) && + grep "^$csha1 " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && test_must_fail git show $csha1 ' @@ -152,7 +152,7 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - egrep "^$csha1 " | sort | uniq | wc -l) && + grep "^$csha1 " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && test_must_fail git show $csha1 ' From patchwork Wed Dec 4 22:03:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11273667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18BAC138C for ; Wed, 4 Dec 2019 22:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1272218AC for ; Wed, 4 Dec 2019 22:03:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KnMFMVnd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbfLDWDb (ORCPT ); Wed, 4 Dec 2019 17:03:31 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33447 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727989AbfLDWDa (ORCPT ); Wed, 4 Dec 2019 17:03:30 -0500 Received: by mail-pg1-f194.google.com with SMTP id 6so527397pgk.0 for ; Wed, 04 Dec 2019 14:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1bxwgvNh24W16drycVbxRAjN5TPRSPl8CyG6Jhhqxj0=; b=KnMFMVnduXxJM5afpaA4f23CP1O0l2D1y21cYY2FO/rCc8TxHfgpRs5Zc8LWESL33p obcIcytYIaoqSY/CttGNEn3jjICt/7JC0rMQ08O3KcNBJmX0wdBnf5KmqNJ2E9piSWFo OPBz1xg9p5p2aQD7KBXcSa1iAVZWKOiXvApdbJfvjdbcu4nlyWCAJErTvbqP8E/uZCX4 CdiWhlwYfreUDUGv+W+Qlyh5+V7+l8xPFoMMCnjF7EU1FarwuLmArxfX7ms4yh/HmYvD 14h/61+0pGQ+OqcgKzovlZf11mPdBdym7cEMyCX8hhFQbQhDP2PDp7qwqYVAAiseed1o wYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1bxwgvNh24W16drycVbxRAjN5TPRSPl8CyG6Jhhqxj0=; b=XV9K38iqgAcSDmpaNPoDO32jzB35BMtORoPq2PS36bGpCUlKpw6T+D6vV6dw9bBvKy SCmRcZxfWZi8nD3Cv397WOe0GmfMwDfajbMZg9SRQNMPfyexZs/ruhUkvWQHZ2jPbg5G Z5q5rX5CfF+HZLv9lfmpAry2CEfe2diy+r8J8Cb9b1ljEmdLNyvEi7m398Zn1cD2vYPd o5BUcalUPju33qtT63Q0qWHHxwkYCIokAcuFeVJVzUhfnxixppfTN2JbncIrIJTHB3NC RDyfDefajAjUiCO/zPZs0mVD0N6B7PGEEedElIPWyO40x1T7dnDqnlP9GXw/9pIEr9dh LDMQ== X-Gm-Message-State: APjAAAU/U6qzZ+QQTP8sjAjAbMDcSAhAhj5BD2N0AmMa2hQ7ZFaDw8KP FCAdPFsxLocomzSG355yld9ELiF8 X-Google-Smtp-Source: APXvYqyqBBxPewaV9gM7RpVmN7MC/I0uU6AJIakdPY2QE7X5IVLoX3kJwZZS2me0+wOUjDOENQS2NA== X-Received: by 2002:a63:ff5c:: with SMTP id s28mr5751869pgk.196.1575497009575; Wed, 04 Dec 2019 14:03:29 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id w12sm2706983pfd.58.2019.12.04.14.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 14:03:29 -0800 (PST) Date: Wed, 4 Dec 2019 14:03:24 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v6 4/5] t7700: make references to SHA-1 generic Message-ID: <113f375192655c3cb566770cb7f1c4f993e51b47.1575496684.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Make the test more hash-agnostic by renaming variables from "sha1" to some variation of "oid" or "packid". Also, replace the regex, `[0-9a-f]\{40\}` with `$OID_REGEX`. A better name for "incrpackid" (incremental pack-id) might have been just "packid". However, later in the test suite, we have other uses of "packid". Although the scopes of these variables don't conflict, a future developer may think that commit_and_pack() and test_has_duplicate_object() are semantically related somehow since they share the same variable name. Give them distinct names so that it's clear these uses are unrelated. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index bfef5888a2..5229999d77 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -6,31 +6,31 @@ test_description='git repack works correctly' commit_and_pack () { test_commit "$@" 1>&2 && - SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack orig.raw && - sed -n -e "s/^\([0-9a-f]\{40\}\).*/\1/p" orig.raw | sort >orig && + sed -n -e "s/^\($OID_REGEX\).*/\1/p" orig.raw | sort >orig && git verify-pack -v $myidx >dest.raw && cut -d" " -f1 dest.raw | sort >dest && comm -23 orig dest >missing && test_must_be_empty missing } -# we expect $packsha1 and $objsha1 to be defined +# we expect $packid and $oid to be defined test_has_duplicate_object () { want_duplicate_object="$1" found_duplicate_object=false for p in .git/objects/pack/*.idx do idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue + test "pack-$packid.idx" = "$idx" && continue git verify-pack -v $p >packlist || return $? - if grep "^$objsha1" packlist + if grep "^$oid" packlist then found_duplicate_object=true echo "DUPLICATE OBJECT FOUND" @@ -51,11 +51,11 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' git rev-list --objects --all | grep -v file2 | git pack-objects pack && # The second pack will contain the excluded object - packsha1=$(git rev-list --objects --all | grep file2 | + packid=$(git rev-list --objects --all | grep file2 | git pack-objects pack) && - >pack-$packsha1.keep && - objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 | - sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") && + >pack-$packid.keep && + oid=$(git verify-pack -v pack-$packid.idx | head -n 1 | + sed -e "s/^\($OID_REGEX\).*/\1/") && mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && @@ -63,13 +63,13 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' ' test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' ' - # build on $objsha1, $packsha1, and .keep state from previous + # build on $oid, $packid, and .keep state from previous git repack -Adbl && test_has_duplicate_object true ' test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' - # build on $objsha1, $packsha1, and .keep state from previous + # build on $oid, $packid, and .keep state from previous git -c repack.writebitmaps=true repack -Adl && test_has_duplicate_object true ' @@ -78,7 +78,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' ' mkdir alt_objects && echo $(pwd)/alt_objects >.git/objects/info/alternates && echo content3 >file3 && - objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && + oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && git add file3 && test_tick && git commit -m commit_file3 && @@ -124,7 +124,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f alt_objects/pack/*.keep && mv .git/objects/pack/* alt_objects/pack/ && - csha1=$(git rev-parse HEAD^{commit}) && + coid=$(git rev-parse HEAD^{commit}) && git reset --hard HEAD^ && test_tick && git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all && @@ -135,14 +135,14 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - grep "^$csha1 " | sort | uniq | wc -l) && + grep "^$coid " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && - test_must_fail git show $csha1 + test_must_fail git show $coid ' test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' ' echo $(pwd)/alt_objects >.git/objects/info/alternates && - echo "$csha1" | git pack-objects --non-empty --all --reflog pack && + echo "$coid" | git pack-objects --non-empty --all --reflog pack && rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && # The pack-objects call on the next line is equivalent to @@ -152,9 +152,9 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - grep "^$csha1 " | sort | uniq | wc -l) && + grep "^$coid " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && - test_must_fail git show $csha1 + test_must_fail git show $coid ' test_expect_success 'objects made unreachable by grafts only are kept' ' From patchwork Wed Dec 4 22:03:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11273669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4879138C for ; Wed, 4 Dec 2019 22:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A139F21823 for ; Wed, 4 Dec 2019 22:03:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nvOSePtc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbfLDWDf (ORCPT ); Wed, 4 Dec 2019 17:03:35 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:36409 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727989AbfLDWDf (ORCPT ); Wed, 4 Dec 2019 17:03:35 -0500 Received: by mail-pj1-f65.google.com with SMTP id n96so371047pjc.3 for ; Wed, 04 Dec 2019 14:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=C7rwZbuP+3Q6dplwJ5UCWsl4aV9yuCVSpFmhOGqQ4bU=; b=nvOSePtc3UK0peKRTvMoGwOaKS+SGniI+pQgVHQqYsUxl69I6yJTrdNnylBSaipQBR xlXc6lMYRcl1SxdxPigpCNxBrI4fGt2RDFz8FBZDFS2JsFU9smIzv0+VnNuNW4nkEWh1 L4Mjz8xIMWC0e8aiMkBO/r9gWPTtEp5lwe4EHl5j56txVkkmjQusTey7z6qWbvci4SG+ DtlNWfmhSxDD8kSrvCtBGUYHc8iL1OHe0ufeisQ45eyQ8kegcH75mxCiWj4AZkcb+mrY bJIDk4OKINBKBXnTOii7PMgxtMFVltZ3mAdD8wKAgdyWUjgtoUUJdek7hh6D7TDS2j2B 1Xdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=C7rwZbuP+3Q6dplwJ5UCWsl4aV9yuCVSpFmhOGqQ4bU=; b=ENEhOV/oRmz4dqCA6ysvI6AaLro8dP6LY8l8DlF3D6AjOw4K9LZPGd+6IfN7/EMxKz AiPl4+OkuiipmqjRBk1scPyCPB4jJpatk/NTgsNYfoXLEf0UFjBR1dzNZrYG8BcqyN9a T3PQGCUhdwoHhfn46iGI/VbXy5WgGqLcV2cVri9eepc67j3cKb56eEkTaGojkaq+pk4T ZhCxdVLME/ifK4w1QtxTDxtNdb4Wm3yne7QvhANOBNL3Ael2tyfRXmrfwyyJw/uqkZse swenJRBx8EqPpIG0689X22K/ka8MYt/Jzv+cINpt+zoBrRu0TwXv0z9CiiZcCcjewE3c IiWA== X-Gm-Message-State: APjAAAXxc12HagERb1GrIIZKqANoGjuIcABhw6gFVsBvIG/ZpZ4exGdJ ymgXi/1iu434nfe0qyheUH8So9gv X-Google-Smtp-Source: APXvYqyIHuacrtHPhl+fEapHbQOdS8iuTnT4PkT1ZSQhbgLoroR0kh49fgTEpPQzGOHHdznyf0SwSA== X-Received: by 2002:a17:90a:c08c:: with SMTP id o12mr5526073pjs.68.1575497014688; Wed, 04 Dec 2019 14:03:34 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id u26sm8641220pfn.46.2019.12.04.14.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 14:03:34 -0800 (PST) Date: Wed, 4 Dec 2019 14:03:30 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v6 5/5] t7700: stop losing return codes of git commands Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream so that we will know if a command fails. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 5229999d77..25b235c063 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -48,14 +48,13 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' git commit -m initial_commit && # Create two packs # The first pack will contain all of the objects except one - git rev-list --objects --all | grep -v file2 | - git pack-objects pack && + git rev-list --objects --all >objs && + grep -v file2 objs | git pack-objects pack && # The second pack will contain the excluded object - packid=$(git rev-list --objects --all | grep file2 | - git pack-objects pack) && + packid=$(grep file2 objs | git pack-objects pack) && >pack-$packid.keep && - oid=$(git verify-pack -v pack-$packid.idx | head -n 1 | - sed -e "s/^\($OID_REGEX\).*/\1/") && + git verify-pack -v pack-$packid.idx >packlist && + oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") && mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && @@ -134,8 +133,8 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' --unpack-unreachable packlist && + ! grep "^$coid " packlist && echo >.git/objects/info/alternates && test_must_fail git show $coid ' @@ -151,8 +150,8 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar --unpack-unreachable packlist && + ! grep "^$coid " && echo >.git/objects/info/alternates && test_must_fail git show $coid '