From patchwork Mon Jul 12 16:44:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12371527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15480C07E99 for ; Mon, 12 Jul 2021 16:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F128261186 for ; Mon, 12 Jul 2021 16:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234156AbhGLQrP (ORCPT ); Mon, 12 Jul 2021 12:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234029AbhGLQrP (ORCPT ); Mon, 12 Jul 2021 12:47:15 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87220C0613E8 for ; Mon, 12 Jul 2021 09:44:25 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id a13so26498073wrf.10 for ; Mon, 12 Jul 2021 09:44:25 -0700 (PDT) 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=ruqkHLtP3AjQcDLK1MKlkm5M1+OUORB21Gzp5AqNfdo=; b=Bq5ZwEc7BreG07qNaFI5pEoQuAawDWfZn6WYnhoClrsSiVC6vXpmlSoGFYJm0GQaSZ YHNdM0G8hi7DDrqSuy8Q9pP1QEKHA105gSTzy5hm0Pi+DSShtqXok9sJorRo8g9Ko6Zj g0ry1Yc/L5iZ+7OCQBAxoNiMz7vjgcAPvffetW5o+c/iIvB1yuoeyLEg4v8j4QA5PnpX 06Yc3Yz3wmOw+peV2rZfe/jNSscIQvKPpSQZhoeuEyrXhogo3HMrWlKnoCCLe6WE+MEy cBrETu/WeMZrvwDRaBLUCI15MFTd4NIxBKCPE8uflECN3EhJAlR4nNZ9GmKTGl6nDzyq f1iw== 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=ruqkHLtP3AjQcDLK1MKlkm5M1+OUORB21Gzp5AqNfdo=; b=sy5HzJsyV667WC4KanFo7Qlx2gdfz/KR0SX3KX7gEj9WBrF4JUVXRsiMQuFxxzK3qb aenTUh1tjbeM8HwGjxMoHSRXknwK0156BtZssi48unfgQSov3C66FmgwE/7+q+Du12Fl 2SCTkQF7qKvLv2+DHM4HPLU9esepW7zmZ0wcOt54xvMIDj12tp5lT87+vlImVz29yxpO hTHRQHkqXtOYi+LSx3CU3duaS9rIQTRUWMmXCyFVXNEXWbI2OOEX2JjCAXeswIJVYs99 i47Rfqj2LF75vGy+xkHAzJBTWUiSBtfrsUjJ/OPRSKt2KQFMUxtHJyFB5oo6JY8lE/gg utdA== X-Gm-Message-State: AOAM533Lvr9LEd+f+qcZv4YnE/LYXRKeCdQWrzkZnaF48iDDhdATtx6B NMuT6p0EwpRnkY2Wi8i7mBhJb/EMGP1DY0Py X-Google-Smtp-Source: ABdhPJwdL1hh3/UykCn5X3QPw/ju4XoKm0cRDO89hEqWxxTVvalPsX1cdxVpqF3TLZ2k9zRFoBatsA== X-Received: by 2002:a5d:6304:: with SMTP id i4mr7641757wru.406.1626108263983; Mon, 12 Jul 2021 09:44:23 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id c10sm12988347wmb.40.2021.07.12.09.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 09:44:23 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 1/5] serve tests: add missing "extra delim" test Date: Mon, 12 Jul 2021 18:44:16 +0200 Message-Id: X-Mailer: git-send-email 2.32.0-dev In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the object-info protocol v2 call was added in a2ba162cda2 (object-info: support for retrieving object info, 2021-04-20) we didn't add a corresponding test here. We had tests for ls-refs and fetch already since 4845b772458 (upload-pack: handle unexpected delim packets, 2020-03-27), but the same behavior in object-info (which is clearly copied from the template of "ls-refs") did not have the corresponding tests. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5704-protocol-violations.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/t/t5704-protocol-violations.sh b/t/t5704-protocol-violations.sh index 5c941949b98..95f68e1d4b7 100755 --- a/t/t5704-protocol-violations.sh +++ b/t/t5704-protocol-violations.sh @@ -32,4 +32,21 @@ test_expect_success 'extra delim packet in v2 fetch args' ' test_i18ngrep "expected flush after fetch arguments" err ' +test_expect_success 'extra delim packet in v2 object-info args' ' + # protocol expects 0000 flush after the 0001 + test-tool pkt-line pack >input <<-EOF && + command=object-info + object-format=$(test_oid algo) + 0001 + 0001 + EOF + + cat >err.expect <<-\EOF && + fatal: object-info: expected flush after arguments + EOF + test_must_fail env GIT_PROTOCOL=version=2 \ + git upload-pack . err.actual && + test_cmp err.expect err.actual +' + test_done From patchwork Mon Jul 12 16:44:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12371529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD3D6C07E9C for ; Mon, 12 Jul 2021 16:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94CF560FE9 for ; Mon, 12 Jul 2021 16:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbhGLQrR (ORCPT ); Mon, 12 Jul 2021 12:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234139AbhGLQrP (ORCPT ); Mon, 12 Jul 2021 12:47:15 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46045C0613DD for ; Mon, 12 Jul 2021 09:44:26 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id l4-20020a05600c4f04b0290220f8455631so441634wmq.1 for ; Mon, 12 Jul 2021 09:44:26 -0700 (PDT) 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=1BpUaFjhGxS3C09d2FSRXu7JDMRkadSACf+ZqspHQOk=; b=NGo1uAm6wVzhO/cGtZ4/AdiGnNW8/DmrkluK60FY/kHYS280mm0jSecyXoOOpqNOIh 3i/3omPtfHbn39j0AGuRMSW70GbPkz/np5ToA1q9Lppe0h1n5T7AtIT2wbXz+3QLjx2C +soeQM0AjIB2wEANs/PjdFLE2n8jOBvYgYe4U/Ox0cn6V19T4/111/p0Y9Xv06VoXIhu PHjxSfxtWnX6nRB0524uXFzafLvy6rbHPAZ+KTgw27k/HGYOI9IJNAJC4uRpuHgYnHEN rY9d28VFcV01gP6oKoPhY8NY9GJr5nXhybF4AQookA8J6rwTkaifXuLwjhJrMocTYL1e jqew== 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=1BpUaFjhGxS3C09d2FSRXu7JDMRkadSACf+ZqspHQOk=; b=kwOLugKfnYbsmqoa1r/RqgmucRICsRoFrfkrPWFdh3StnngjFmLrWKZGT1etQactAC iMgzQvebn29b07TLaN3n/EZOjQNjiLZ0VPAzEvJUvjfFft2fLYvq2xaOg61IHcy1ySX9 p9wHKOziZ3PplJ83U5D59++JlO+VNtX7+1jhgfyENsb6SWA6msypHIWgnrvwf6WekpkZ g6WhYlaqXwOqxCsNFbVp4Tsd1uimmCUiOOz6ICEzhzZlzHetpCg6POWyFxk6K9aDU4GI Oo4r/IWZKZ8JVoKi5EAfkn7DoSUXdsLvj8H850XLSDPhTK1G2xXMSpiIm5lA8/ChHsH/ WyWA== X-Gm-Message-State: AOAM53207WznOrNNQCG0HcGF72oxoZJ54LslfnY4ybAyMbHW06D/8ZeB M+PS7XkarSWjTWnJMR/SYkYulkIAQFKgo/45 X-Google-Smtp-Source: ABdhPJzVZ6oHl8ZL45UqatvJaMnZU0UdGLGYI+7bsPQKIOk8YW3fRJBSx3k7PK++mgzdtLIF89rSPQ== X-Received: by 2002:a1c:4c18:: with SMTP id z24mr9166466wmf.168.1626108264693; Mon, 12 Jul 2021 09:44:24 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id c10sm12988347wmb.40.2021.07.12.09.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 09:44:24 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 2/5] serve tests: use test_cmp in "protocol violations" test Date: Mon, 12 Jul 2021 18:44:17 +0200 Message-Id: X-Mailer: git-send-email 2.32.0-dev In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Amend the protocol violations tests to check the full output, not just grep it. This changes code added in 4845b772458 (upload-pack: handle unexpected delim packets, 2020-03-27). The newly added test in the preceding commit already did the full test_cmp. I have a related series to tweak the output from upload-pack et al, we really want to make sure we have this exact output, and not fewer or more lines etc. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5704-protocol-violations.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/t/t5704-protocol-violations.sh b/t/t5704-protocol-violations.sh index 95f68e1d4b7..038fffd3d03 100755 --- a/t/t5704-protocol-violations.sh +++ b/t/t5704-protocol-violations.sh @@ -14,9 +14,12 @@ test_expect_success 'extra delim packet in v2 ls-refs args' ' # protocol expects 0000 flush here printf 0001 } >input && + cat >err.expect <<-\EOF && + fatal: expected flush after ls-refs arguments + EOF test_must_fail env GIT_PROTOCOL=version=2 \ - git upload-pack . err && - test_i18ngrep "expected flush after ls-refs arguments" err + git upload-pack . err.actual && + test_cmp err.expect err.actual ' test_expect_success 'extra delim packet in v2 fetch args' ' @@ -27,9 +30,12 @@ test_expect_success 'extra delim packet in v2 fetch args' ' # protocol expects 0000 flush here printf 0001 } >input && + cat >err.expect <<-\EOF && + fatal: expected flush after fetch arguments + EOF test_must_fail env GIT_PROTOCOL=version=2 \ - git upload-pack . err && - test_i18ngrep "expected flush after fetch arguments" err + git upload-pack . err.actual && + test_cmp err.expect err.actual ' test_expect_success 'extra delim packet in v2 object-info args' ' From patchwork Mon Jul 12 16:44:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12371531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE825C07E99 for ; Mon, 12 Jul 2021 16:44:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC26060FE9 for ; Mon, 12 Jul 2021 16:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234205AbhGLQrT (ORCPT ); Mon, 12 Jul 2021 12:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234224AbhGLQrR (ORCPT ); Mon, 12 Jul 2021 12:47:17 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDCDC0613E5 for ; Mon, 12 Jul 2021 09:44:27 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id l7so25602945wrv.7 for ; Mon, 12 Jul 2021 09:44:27 -0700 (PDT) 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=B94/wQoWk78grEy2Hhgt/qOwklxPlUa4DC1PCQ/HR+w=; b=sHPsLyaT/e545x5vlGFq2OEHEkVq5hzdAtIiBuvPL3YQqzLsEosCvSz7rQKRddqQbq k192waRCkhxxoUQ4CFiu8y+DrhliM7bKNKZWD+xIYGHSi9oYwkUIp2d7kBdeaG6vDR4p NxO0bqcPgDh2liHAFtTKy25f9uldGSf3GMSBXREfekPHXxvexTkR65riENQnoAbPD41d pDsTbDQyiJBTB7tcCaZCV9SDc9fh9BZXMdNJwrJmNmmTKJ0UepKm5ybhpRFjjW1wKIHH gGmxiYWHHBvI5M1MpIqK6N0cQtG1+wTThUN03IGWxNAf82PVV+8s78D9G5doUyY6O+Hz M+Hg== 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=B94/wQoWk78grEy2Hhgt/qOwklxPlUa4DC1PCQ/HR+w=; b=tZ9I9McFlfxvBOzJB/7cXNID3eLfNRiL76ljhxcWGfhfdUi3WXINHae3orB82h3gHD iZJNrmiY8QeSWju2GRRiwvjIB0+M1qe8pHopFqv57LwdCL3ObRb4dufp626TruEjqpaC QVHLa4ZQIaUGyhLpADhESokY+G0Dt+7RvduL5iFEjE/t1IwaSBnIHrDq3PoShvOWLji7 BXneZGO2xZ8AlWqABvPyGmrnK9pMpdbezaHUGVEJj5rrwRv5T9wWqaTwX9MUH0js3Luh +MKAJzPh/M7LF3SB2ZceOMxzzZZcjzHpDqDO3ErIuf6G/a5QL/sPCwCOLWohyZttYw9l PpHg== X-Gm-Message-State: AOAM532ZVTlrcgCtTWL/N6C7CW+/t2JsU9f/r6c27pG3yl+T446Aw5X4 ObHEPTXAdJbeisfflCV3G2hTFdoOm1XL9m/3 X-Google-Smtp-Source: ABdhPJyvxxua3GFLWNMQ1gus8ijFFT4EtE6ZlilVXMgY0D9XIVFbYV+RzcKdKIsbQ3e0nefJPU56Dw== X-Received: by 2002:a5d:410b:: with SMTP id l11mr60017516wrp.173.1626108265400; Mon, 12 Jul 2021 09:44:25 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id c10sm12988347wmb.40.2021.07.12.09.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 09:44:24 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Date: Mon, 12 Jul 2021 18:44:18 +0200 Message-Id: X-Mailer: git-send-email 2.32.0-dev In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The shell+perl "[de]packetize()" helper functions were added in 4414a150025 (t/lib-git-daemon: add network-protocol helpers, 2018-01-24), and around the same time we added the "pkt-line" helper in 74e70029615 (test-pkt-line: introduce a packet-line test helper, 2018-03-14). For some reason it seems we've mostly used the shell+perl version instead of the helper since then. There were discussions around 88124ab2636 (test-lib-functions: make packetize() more efficient, 2020-03-27) and cacae4329fa (test-lib-functions: simplify packetize() stdin code, 2020-03-29) to improve them and make them more efficient. Let's instead just use the test helper, I think this results in both more legible code, and for anyone who cares about efficiency it'll be faster. We can't convert all the users of packetize(), it has a feature the test-tool is missing. This'll be addressed in the subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5410-receive-pack-alternates.sh | 42 ++++++++++++++++++-------- t/t5411/once-0010-report-status-v1.sh | 8 ++--- t/t5500-fetch-pack.sh | 15 +++++---- t/t5530-upload-pack-error.sh | 24 ++++++++------- t/t5562-http-backend-content-length.sh | 13 ++++---- t/t5570-git-daemon.sh | 12 +++++--- t/t5704-protocol-violations.sh | 30 +++++++++--------- 7 files changed, 86 insertions(+), 58 deletions(-) diff --git a/t/t5410-receive-pack-alternates.sh b/t/t5410-receive-pack-alternates.sh index 0b28e4e452f..d0053d95a44 100755 --- a/t/t5410-receive-pack-alternates.sh +++ b/t/t5410-receive-pack-alternates.sh @@ -16,10 +16,6 @@ test_expect_success 'setup' ' test_commit private ' -extract_haves () { - depacketize | perl -lne '/^(\S+) \.have/ and print $1' -} - test_expect_success 'with core.alternateRefsCommand' ' write_script fork/alternate-refs <<-\EOF && git --git-dir="$1" for-each-ref \ @@ -27,18 +23,40 @@ test_expect_success 'with core.alternateRefsCommand' ' refs/heads/public/ EOF test_config -C fork core.alternateRefsCommand ./alternate-refs && - git rev-parse public/branch >expect && - printf "0000" | git receive-pack fork >actual && - extract_haves actual.haves && - test_cmp expect actual.haves + + test-tool pkt-line pack >in <<-\EOF && + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse main) refs/heads/main + $(git rev-parse base) refs/tags/base + $(git rev-parse public) .have + 0000 + EOF + + git receive-pack fork >out actual && + test_cmp expect actual ' test_expect_success 'with core.alternateRefsPrefixes' ' test_config -C fork core.alternateRefsPrefixes "refs/heads/private" && - git rev-parse private/branch >expect && - printf "0000" | git receive-pack fork >actual && - extract_haves actual.haves && - test_cmp expect actual.haves + + test-tool pkt-line pack >in <<-\EOF && + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse main) refs/heads/main + $(git rev-parse base) refs/tags/base + $(git rev-parse private) .have + 0000 + EOF + + git receive-pack fork >out actual && + test_cmp expect actual ' test_done diff --git a/t/t5411/once-0010-report-status-v1.sh b/t/t5411/once-0010-report-status-v1.sh index 1233a46eac5..cf33d993192 100644 --- a/t/t5411/once-0010-report-status-v1.sh +++ b/t/t5411/once-0010-report-status-v1.sh @@ -34,13 +34,13 @@ test_expect_success "proc-receive: report status v1" ' $A $B | packetize fi && printf "%s %s refs/for/main/topic1\n" \ - $ZERO_OID $A | packetize && + $ZERO_OID $A | test-tool pkt-line pack && printf "%s %s refs/heads/foo\n" \ - $ZERO_OID $A | packetize && + $ZERO_OID $A | test-tool pkt-line pack && printf "%s %s refs/for/next/topic\n" \ - $ZERO_OID $A | packetize && + $ZERO_OID $A | test-tool pkt-line pack && printf "%s %s refs/for/main/topic2\n" \ - $ZERO_OID $A | packetize && + $ZERO_OID $A | test-tool pkt-line pack && printf 0000 && printf "" | git -C "$upstream" pack-objects --stdout } | git receive-pack "$upstream" --stateless-rpc \ diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 8a5d3492c71..ff0b7dd89f9 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -872,14 +872,17 @@ test_expect_success 'shallow since with commit graph and already-seen commit' ' git commit-graph write --reachable && git config core.commitGraph true && - GIT_PROTOCOL=version=2 git upload-pack . <<-EOF >/dev/null - 0012command=fetch - $(echo "object-format=$(test_oid algo)" | packetize) - 00010013deepen-since 1 - $(echo "want $(git rev-parse other)" | packetize) - $(echo "have $(git rev-parse main)" | packetize) + test-tool pkt-line pack >in <<-EOF && + command=fetch + object-format=$(test_oid algo) + 0001 + deepen-since 1 + want $(git rev-parse other) + have $(git rev-parse main) 0000 EOF + + GIT_PROTOCOL=version=2 git upload-pack . /dev/null ) ' diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh index 7c1460eaa99..8ccaae10475 100755 --- a/t/t5530-upload-pack-error.sh +++ b/t/t5530-upload-pack-error.sh @@ -90,18 +90,20 @@ test_expect_success 'upload-pack fails due to error in pack-objects enumeration' test_expect_success 'upload-pack tolerates EOF just after stateless client wants' ' test_commit initial && - head=$(git rev-parse HEAD) && - - { - packetize "want $head" && - packetize "shallow $head" && - packetize "deepen 1" && - printf "0000" - } >request && - printf "0000" >expect && - - git upload-pack --stateless-rpc . actual && + head=$(git rev-parse HEAD) && + test-tool pkt-line pack >request <<-EOF && + want $head + shallow $head + deepen 1 + 0000 + EOF + + cat >expect <<-\EOF && + 0000 + EOF + git upload-pack --stateless-rpc . out && + test-tool pkt-line unpack actual && test_cmp expect actual ' diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index e5d3d15ba8d..e6c8338b648 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -53,12 +53,13 @@ test_expect_success 'setup' ' test_commit c1 && hash_head=$(git rev-parse HEAD) && hash_prev=$(git rev-parse HEAD~1) && - { - packetize "want $hash_head" && - printf 0000 && - packetize "have $hash_prev" && - packetize "done" - } >fetch_body && + test-tool pkt-line pack >fetch_body <<-EOF && + want $hash_head + 0000 + have $hash_prev + done + 0000 + EOF test_copy_bytes 10 fetch_body.trunc && hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) && { diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 82c31ab6cd8..2dde0348816 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -198,12 +198,14 @@ test_expect_success FAKENC 'hostname interpolation works after LF-stripping' ' printf "0000" } >input && fake_nc "$GIT_DAEMON_HOST_PORT" output && - depacketize output.raw && + test-tool pkt-line unpack actual && + + cat >expect <<-EOF && + $(git rev-parse HEAD) HEAD + $(git rev-parse refs/heads/main) refs/heads/main + 0000 + EOF - # just pick out the value of main, which avoids any protocol - # particulars - perl -lne "print \$1 if m{^(\\S+) refs/heads/main}" actual && - git -C "$repo" rev-parse main >expect && test_cmp expect actual ' diff --git a/t/t5704-protocol-violations.sh b/t/t5704-protocol-violations.sh index 038fffd3d03..44e2c0d3ded 100755 --- a/t/t5704-protocol-violations.sh +++ b/t/t5704-protocol-violations.sh @@ -7,13 +7,14 @@ making sure that we do not segfault or otherwise behave badly.' . ./test-lib.sh test_expect_success 'extra delim packet in v2 ls-refs args' ' - { - packetize command=ls-refs && - packetize "object-format=$(test_oid algo)" && - printf 0001 && - # protocol expects 0000 flush here - printf 0001 - } >input && + # protocol expects 0000 flush after the 0001 + test-tool pkt-line pack >input <<-EOF && + command=ls-refs + object-format=$(test_oid algo) + 0001 + 0001 + EOF + cat >err.expect <<-\EOF && fatal: expected flush after ls-refs arguments EOF @@ -23,13 +24,14 @@ test_expect_success 'extra delim packet in v2 ls-refs args' ' ' test_expect_success 'extra delim packet in v2 fetch args' ' - { - packetize command=fetch && - packetize "object-format=$(test_oid algo)" && - printf 0001 && - # protocol expects 0000 flush here - printf 0001 - } >input && + # protocol expects 0000 flush after the 0001 + test-tool pkt-line pack >input <<-EOF && + command=fetch + object-format=$(test_oid algo) + 0001 + 0001 + EOF + cat >err.expect <<-\EOF && fatal: expected flush after fetch arguments EOF From patchwork Mon Jul 12 16:44:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12371533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9309DC07E9C for ; Mon, 12 Jul 2021 16:44:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E13960FE9 for ; Mon, 12 Jul 2021 16:44:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234300AbhGLQrU (ORCPT ); Mon, 12 Jul 2021 12:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234208AbhGLQrR (ORCPT ); Mon, 12 Jul 2021 12:47:17 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3DD9C0613E9 for ; Mon, 12 Jul 2021 09:44:27 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id t5so12670412wrw.12 for ; Mon, 12 Jul 2021 09:44:27 -0700 (PDT) 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=79wy7yg0RL4WI3JlF9hqjKjI608FL1XhF0FHsoTw3tM=; b=FTsf+JftbNomRgKSg0VU0asCmC75JOt3pMDnSX2+jfnU7nui5Ams2vCw6ZOguoT7HQ WqRENZ965FddxvlLQuxYlm8bhUISO7Tsb7t6Ko6+WnCfkjLNSBsD5ZFK/S9g3vsxOOWM 8fKLb81SxsZQq1GLPPYm2B1TiagJoizLD8xscIlNdP6IKd0W7ZxAGk0hh/hqTXzu+JnJ 6qXOTfH1IcN3AmJOWLE20wC+HpKm1hCuAdiiXEwQOPrQZmJfKfMQbkCsfUKMo/n1wa5z 6EbtwMV0nYuL9vMn8YMSfjlzMXHbRUEeS52R0X94CL9x6uJHu4JvJvCiuBaFqj84yb/f PyOg== 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=79wy7yg0RL4WI3JlF9hqjKjI608FL1XhF0FHsoTw3tM=; b=JMJQFmSCFZJa6KSx9FjGy3AaYR4xmhzrcMMALsjEhxz41KP629tRO3PkyYsFktkjBQ AhFWDU9em4rQRdKFpJkneZAkWlzuXnqdftJRFVYpdiwukBtjtkYM+EEBMpnnEtsJwMx2 nlvQEtU+S0NSEWizSjuUbqTcgbsSRDgsmbJkUmg3j6w6duSOJxH1ae/qsMiJmky3Fple J4MCtPrqDIAb6r5CA8AdF6mMD74FV53an2rba2m6LgdMOQkS6wjJijHvOTogsoUi1d16 jgkHGmlR83fOwGVZl79BYfFqs/X+aX8Oui4hcLEYt6Um77NDtq1Dbu5mT7NCxE5HxvNh GY8w== X-Gm-Message-State: AOAM531G/Yg1yWYcurGfj3hMv+KhNg7/8GcpKqOzp6QqWlyCLAiPn4f3 BGnxEMqEwwBbS8fd+8dStslPgbI8jgyAhuf7 X-Google-Smtp-Source: ABdhPJxHs8bVYbaZoqTWarXYQkgWDDACwHT3H3paWUfiEa6/U2STmdhZ6S6sC5QUAM5NSDQ8Xfy2EQ== X-Received: by 2002:adf:cd86:: with SMTP id q6mr58289547wrj.422.1626108266266; Mon, 12 Jul 2021 09:44:26 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id c10sm12988347wmb.40.2021.07.12.09.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 09:44:25 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Date: Mon, 12 Jul 2021 18:44:19 +0200 Message-Id: X-Mailer: git-send-email 2.32.0-dev In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the only remaining users of "packetize()" over to "test-tool pkt-line", for this we need a new "pack-raw-stdin" subcommand in the test-tool. The "pack" command takes input on stdin, but splits it by "\n", furthermore we'll format the output using C-strings, so the embedded "\0" being tested for here would cause the string to be truncated. So we need another mode that just calls packet_write() on the raw input we got on stdin. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-pkt-line.c | 12 ++++++++++++ t/t5411/once-0010-report-status-v1.sh | 4 ++-- t/t5562-http-backend-content-length.sh | 3 ++- t/t5570-git-daemon.sh | 10 ++++++---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c index 5e638f0b970..8563a0da4c5 100644 --- a/t/helper/test-pkt-line.c +++ b/t/helper/test-pkt-line.c @@ -26,6 +26,16 @@ static void pack(int argc, const char **argv) } } +static void pack_raw_stdin(void) +{ + struct strbuf sb = STRBUF_INIT; + strbuf_read(&sb, 0, 0); + if (strbuf_read(&sb, 0, 0) < 0) + die_errno("failed to read from stdin"); + packet_write(1, sb.buf, sb.len); + strbuf_release(&sb); +} + static void unpack(void) { struct packet_reader reader; @@ -110,6 +120,8 @@ int cmd__pkt_line(int argc, const char **argv) if (!strcmp(argv[1], "pack")) pack(argc - 2, argv + 2); + else if (!strcmp(argv[1], "pack-raw-stdin")) + pack_raw_stdin(); else if (!strcmp(argv[1], "unpack")) unpack(); else if (!strcmp(argv[1], "unpack-sideband")) diff --git a/t/t5411/once-0010-report-status-v1.sh b/t/t5411/once-0010-report-status-v1.sh index cf33d993192..75d4233e49f 100644 --- a/t/t5411/once-0010-report-status-v1.sh +++ b/t/t5411/once-0010-report-status-v1.sh @@ -28,10 +28,10 @@ test_expect_success "proc-receive: report status v1" ' if test -z "$GIT_DEFAULT_HASH" || test "$GIT_DEFAULT_HASH" = "sha1" then printf "%s %s refs/heads/main\0report-status\n" \ - $A $B | packetize + $A $B | test-tool pkt-line pack-raw-stdin else printf "%s %s refs/heads/main\0report-status object-format=$GIT_DEFAULT_HASH\n" \ - $A $B | packetize + $A $B | test-tool pkt-line pack-raw-stdin fi && printf "%s %s refs/for/main/topic1\n" \ $ZERO_OID $A | test-tool pkt-line pack && diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index e6c8338b648..23a8a8d5c70 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -64,7 +64,8 @@ test_expect_success 'setup' ' hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) && { printf "%s %s refs/heads/newbranch\\0report-status object-format=%s\\n" \ - "$ZERO_OID" "$hash_next" "$(test_oid algo)" | packetize && + "$ZERO_OID" "$hash_next" "$(test_oid algo)" | + test-tool pkt-line pack-raw-stdin && printf 0000 && echo "$hash_next" | git pack-objects --stdout } >push_body && diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 2dde0348816..b52afb0cdea 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -193,10 +193,12 @@ test_expect_success 'hostname cannot break out of directory' ' ' test_expect_success FAKENC 'hostname interpolation works after LF-stripping' ' - { - printf "git-upload-pack /interp.git\n\0host=localhost" | packetize - printf "0000" - } >input && + printf "git-upload-pack /interp.git\n\0host=localhost" >has-null && + test-tool pkt-line pack-raw-stdin >input >input <<-\EOF && + 0000 + EOF + fake_nc "$GIT_DAEMON_HOST_PORT" output && test-tool pkt-line unpack actual && From patchwork Mon Jul 12 16:44:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12371535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FCB3C11F66 for ; Mon, 12 Jul 2021 16:44:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B27C61186 for ; Mon, 12 Jul 2021 16:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234316AbhGLQrU (ORCPT ); Mon, 12 Jul 2021 12:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234289AbhGLQrS (ORCPT ); Mon, 12 Jul 2021 12:47:18 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31154C0613EF for ; Mon, 12 Jul 2021 09:44:28 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id g8-20020a1c9d080000b02901f13dd1672aso310810wme.0 for ; Mon, 12 Jul 2021 09:44:28 -0700 (PDT) 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=f9hqVrq6jJuYqXnGExueXT057F3C92bAgIuP3TZ1r+Q=; b=Vudjj1KdiQsb49DfUG7JeYCsBii+QTQKloWrSL5UwcUlVRk5H4MQF+drRD1HQniAEy I0aF6HYxHnsHTedCcwXPZqKFqafH88LUojK0MwW+OEoDOiNmAjA1FZvC20B+LrR9MhDg YQjBQT8TWsxAHRB0Urw1uhaSQVABXTFphfICwKE1gLbV8lCGK+ZIeCoeWnEpoadebDq6 bY9sfffYayV6eVFtGMLUzB0X/OIiOW6fuKJLFE+a51v/O/3rFfibWvIRTHr8kLB5BAOv iDb+DYXNiAGo+dWYYkhI+JD9B69UaaXvZKSF9OqKRMpC6pxUr2zuPDhWj1G6GepDDnds 1wYQ== 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=f9hqVrq6jJuYqXnGExueXT057F3C92bAgIuP3TZ1r+Q=; b=IGBfUZFzb6FFV+gKCP3B38omP+V+O2l5vkXz1xg6se5kXoLTtyLzGkDECWa2YEMpQl TEGeu/HOqPLVEKhb0DiPAFErHaHdM071+++WZg4MZjDE/VITWG1R5iWMAEKBF1WiEBUR If8PzRarulJF5kMpRIuBkUg/gJ4wuEyshcxvKGxhAQ4Jz/NsoG9bvVvzVq5kIm+Tymzj ersvYWM5qM5gCAz9CyEVt4+Aaq9sbL8d/qWt5KbuZMF1a9W10JcG8hwTWxcLc4KUxOi3 5c8+KPSsqyE0ipdMAEgmBBBhvmx36NQsO2tUCHwWxaf/bNS2t3swY2Ko17Y6rsqxJnmp Q3hw== X-Gm-Message-State: AOAM530xs4n8xok4gN7YrUe8TGaO4UN3AnHpF6ILgTrTl95QRYcTkfvq ipaxx0J2WTNPzT2pkOxfNY9WdohCqyUu6DkH X-Google-Smtp-Source: ABdhPJy3Kc/wvQHtQ5U0gJb2hvu0aWAcDMIMkb9eQm+CEvJpMcWk0PH1zoRFd9RlHtWr28FTSanmYA== X-Received: by 2002:a1c:4603:: with SMTP id t3mr15325174wma.178.1626108267198; Mon, 12 Jul 2021 09:44:27 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id c10sm12988347wmb.40.2021.07.12.09.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 09:44:26 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Date: Mon, 12 Jul 2021 18:44:20 +0200 Message-Id: X-Mailer: git-send-email 2.32.0-dev In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the now-unused "packetize()" and "depacketize()" functions added in 4414a150025 (t/lib-git-daemon: add network-protocol helpers, 2018-01-24). As discussed in the preceding commits we've now moved all their users over to "test-tool pkt-line". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 42 ----------------------------------------- 1 file changed, 42 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index b2810478a21..77e4434dcda 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1453,48 +1453,6 @@ nongit () { ) } 7>&2 2>&4 -# convert function arguments or stdin (if not arguments given) to pktline -# representation. If multiple arguments are given, they are separated by -# whitespace and put in a single packet. Note that data containing NULs must be -# given on stdin, and that empty input becomes an empty packet, not a flush -# packet (for that you can just print 0000 yourself). -packetize () { - if test $# -gt 0 - then - packet="$*" - printf '%04x%s' "$((4 + ${#packet}))" "$packet" - else - perl -e ' - my $packet = do { local $/; }; - printf "%04x%s", 4 + length($packet), $packet; - ' - fi -} - -# Parse the input as a series of pktlines, writing the result to stdout. -# Sideband markers are removed automatically, and the output is routed to -# stderr if appropriate. -# -# NUL bytes are converted to "\\0" for ease of parsing with text tools. -depacketize () { - perl -e ' - while (read(STDIN, $len, 4) == 4) { - if ($len eq "0000") { - print "FLUSH\n"; - } else { - read(STDIN, $buf, hex($len) - 4); - $buf =~ s/\0/\\0/g; - if ($buf =~ s/^[\x2\x3]//) { - print STDERR $buf; - } else { - $buf =~ s/^\x1//; - print $buf; - } - } - } - ' -} - # Converts base-16 data into base-8. The output is given as a sequence of # escaped octals, suitable for consumption by 'printf'. hex2oct () {