From patchwork Wed Jul 14 00:54:01 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: 12375461 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 EFDB1C07E95 for ; Wed, 14 Jul 2021 00:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3CD2611AC for ; Wed, 14 Jul 2021 00:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237199AbhGNA5A (ORCPT ); Tue, 13 Jul 2021 20:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237113AbhGNA5A (ORCPT ); Tue, 13 Jul 2021 20:57:00 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D98C0613E9 for ; Tue, 13 Jul 2021 17:54:09 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id k32so486582wms.4 for ; Tue, 13 Jul 2021 17:54:09 -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=HC9RNt9ejO/O1yy2AYqthhDhP74VNo4+BUHxfvHwf44=; b=JaXxQJ6jx134HKcp0puOEnswWoCJ4wEq9pD7swEn6cl/2lu/0cnd5hIfq5BNXB6I0T 90Wdv8Bf9x9WqlNtDCKsJqfRzfj3DANMGC/p6NRBpEDPFzzEBkqeXBfQk3p6tZ/CUHEj Oyct2KJufFFIL1qvet3FRtscT2KYM3L8P9cAD3cQOJyY5dp8wzoVLAAL5aaDWm+s4b4u EGpH1R3PZDyywyMybBXXdkiMRgDeKK9v4bHw9sGHCrlF58lio+3Z3NSEZuyPUtofDpRw 80Y8dwBbwRzX09CGZ990mOxt3PBrh14TuqY4RUbUb7jeuLVB/lhclvn7JHM5Tg9B3hS/ hRNQ== 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=HC9RNt9ejO/O1yy2AYqthhDhP74VNo4+BUHxfvHwf44=; b=RGqH91+iCULYX7xl0uQlJTRrQnpbyfbw/ae6bBPxICMe1pD8LTl/8kXMxEPoO3A+Jd /Nsxt+V/nBEQVUxAuLxSVb4xfrmFVlGQNqavhP/LG7E8gKYiX7OQUjCZa5W12KEerHM3 aGk/s8OW7eSx+PXF/MZZhZRjkIsrihKarM6Whl9+0IdUfi7KFtuNFZEVjusW38biXosz J6TpGAfg9tesWK4q1OxlW7QD67e1yLjD0vEvwUeYhfI5YwgyETO++2H7lb9ddjEgMEa1 tfm0zJ3eLiCbWS9UcHgS5B9KVgGhPuxjo9PUwoJ/DbgMUdePg2ETFjhWjAqZ0ycq0LsL QgcA== X-Gm-Message-State: AOAM532tXRhdwxKFP2dzQQfp6gjkIKbwaYWNtHKjdXYexLOmsdhBnFi8 BKrJXZOQVYOPDtidFju4q9hHquQ0fHZtggzf X-Google-Smtp-Source: ABdhPJz49lij50qLAG6UwX1utjayeadDXMtU0J4IE/SBYTjESDH0nGI3/OycIjnvPq7eijxYfFfJrA== X-Received: by 2002:a05:600c:6d8:: with SMTP id b24mr960728wmn.111.1626224047547; Tue, 13 Jul 2021 17:54:07 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g3sm463315wru.95.2021.07.13.17.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 17:54:07 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 1/5] serve tests: add missing "extra delim" test Date: Wed, 14 Jul 2021 02:54:01 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.788.ge724008458 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 5c941949b9..95f68e1d4b 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 Wed Jul 14 00:54:02 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: 12375467 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 472B0C07E96 for ; Wed, 14 Jul 2021 00:54:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D89061370 for ; Wed, 14 Jul 2021 00:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237228AbhGNA5F (ORCPT ); Tue, 13 Jul 2021 20:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237113AbhGNA5B (ORCPT ); Tue, 13 Jul 2021 20:57:01 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0541C0613E9 for ; Tue, 13 Jul 2021 17:54:09 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id a13so947655wrf.10 for ; Tue, 13 Jul 2021 17:54:09 -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=lvx7RbkgKgtMKEZECAKV9jbqO3jm4XogqQa2d33ZYtA=; b=OesMWjl50kI5WrF3JRkY879GcLwkCb2zu1g7D2eFmJh3YuImHu/eiMVdZoyN+cCIJb pw/ecICCAEElKRqZHfuyTbZl1oqJyvVLwP4CVxcKxb0dhxoUI8WK8iOJy+LX1mwb7YYc TZ0HZZgzR6I9Q/Ha0j24tSdai5WlAHCz2v2BjkJE3u/xR2oKftuPLx6QFuYze4rL/PTD yZDWyWXcoVhdul4WxlNjBramxQ2mnvQDObL5lMlYcKKZI5WZflp78Q+OGs2ysApIK3hR T4wmkWU+vLW2vdEbsOhwln0PXjLT9Z0+vhHAVpseS52BzRTdTGY5heFw1gxvwEWfWNXY Z0Gg== 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=lvx7RbkgKgtMKEZECAKV9jbqO3jm4XogqQa2d33ZYtA=; b=YsSx5V4jU8l3oXTBpD2FZTay9GGLyn3jLF5FeAa36W5iK0bGUVj5m/kqPMz99GxKfi /vw5ARO3o6e4gm3/utb/+c206BRS5ry1036DPiwwI1m9BJQWoMKJ83+7euuJhtzy8Bod wMDZavEELCvaIGDSjWHKx9yCd0O746qxs7HBpva5r5QVU52VdDRx0x++mnR0reX5gvnV AtGf/y9r0SP6EIJQubQ3dmA2A296CG7kZD8W/B6dU5DU0rPf/CV0UTA95WCIeOoCq6fH gzJc4rowsC97EJVFHOANxZnw4jQ9HcZ3O8UtS8lyg6HZ4r7YrvHNiai1GaJQZycDwFbv R7Sw== X-Gm-Message-State: AOAM530ybfdsR1BhZjVWHYlB21B9RJWMvc5zA7hFuspwU6p8NVQEoJCo tz4/1U5WD9DRbOau0eByfQl85ja0H47rypvv X-Google-Smtp-Source: ABdhPJytctKN9JHCV7D3jf9s9fvcILpuRqxvJmksvtavOGdqWk1yUzEc1Q2xdzmpA87aikirvVyYEg== X-Received: by 2002:a5d:6c6e:: with SMTP id r14mr9405511wrz.242.1626224048323; Tue, 13 Jul 2021 17:54:08 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g3sm463315wru.95.2021.07.13.17.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 17:54:07 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 2/5] serve tests: use test_cmp in "protocol violations" test Date: Wed, 14 Jul 2021 02:54:02 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.788.ge724008458 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 95f68e1d4b..038fffd3d0 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 Wed Jul 14 00:54:03 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: 12375465 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 A4579C07E95 for ; Wed, 14 Jul 2021 00:54:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83FDA61370 for ; Wed, 14 Jul 2021 00:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237224AbhGNA5D (ORCPT ); Tue, 13 Jul 2021 20:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237194AbhGNA5B (ORCPT ); Tue, 13 Jul 2021 20:57:01 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB6FC0613DD for ; Tue, 13 Jul 2021 17:54:10 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id i2-20020a05600c3542b02902058529ea07so325846wmq.3 for ; Tue, 13 Jul 2021 17:54:10 -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=tErMM66uwnUcqKAClY65bBInNBx/z3NreelbmQpG4w4=; b=R+YN10wGuFFdT9o+sC3L2Y9yTYSHQngFZhAXg2/pE6FQRB6APSYcZjI7vzzkEyiDFk Oa+1Y7DYc+NNhkCHrhHpfEcAWxTKyBTR4ctyYdrioQs8H1EUYYF69keH/Nar+pRyTPet zzKKrggZj2OfHKz6z331xR+rornjfha/ZmnmT+LDLyUH8FyO0agq5+EXiLHRhO3gS8oF cUULPa80Uz14DGU7+6f0jSbyMXzU+gh6RuV1eior1Ac2XJWXbnt8/u/YA6l7eM1Uluc4 IA5cwyArHuXNCxzVdy0Nwf6Dl9fK7gAW5W5vXzIc/P+tx2hIFbNR0W++MhkkJQLFlbT9 Y8Cw== 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=tErMM66uwnUcqKAClY65bBInNBx/z3NreelbmQpG4w4=; b=ZSj/O5RLq2IqsJysSITdmHFaR6E++1huc0AYLybUQpLyva9gI3zTFEO2GuPrQHTNhy TMYxOHOPoSTku2SxteJ3MzkP79lezjjRNvGn0jDdXJf0kNGI703ivZoa2UcNNIxNsgRO nuRW8TfEcjpnmDJOtJ2VqMNKdBzxzkfxWhziZW4niu0Y83cQYOTg/Dda3pdffjj9rI9E YRo/kkch8eEmO6RRUhFYYzLQvwc7wvP8imzS4/AjakKHmrnQz5FzwnduCkJwJpfEVHoo Qnv9ilrSRVtCUYJeAu1CTfCP0Q7aeA7c1I0z19uouKE9vKP42I3JLRcsgDVWijHzgbt6 FQiw== X-Gm-Message-State: AOAM531IqqxQuW151bLr8G8AVxBA/pqK4yS0yy8kq8I0iyji0JU+FaXS UAc5A+MmwMUaIaSXDX9HqBHQzdMF3fT98M8d X-Google-Smtp-Source: ABdhPJwnWXbpw1XsZDBbpWFw8JD8IqC1FG9/AEQL8S/k1QLcFRZc/YX7xweg6dOn0iZBRV1ry0AtyQ== X-Received: by 2002:a1c:7715:: with SMTP id t21mr951724wmi.121.1626224048941; Tue, 13 Jul 2021 17:54:08 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g3sm463315wru.95.2021.07.13.17.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 17:54:08 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Date: Wed, 14 Jul 2021 02:54:03 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.788.ge724008458 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. The conversion away from extract_haves() in t5410-receive-pack-alternates.sh and the "just pick out" logic in t5570-git-daemon.sh isn't strictly required for this migration, but in this case it's easy enough to test_cmp the whole output, so let's just do that. Similarly, there are cases here of changing "printf 0000" to a version that'll emit a trailing newline after "0000", or where we can do away with the "0000" trailer. Let's just always include, and include it in the same way. 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 | 16 +++++----- 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, 89 insertions(+), 63 deletions(-) diff --git a/t/t5410-receive-pack-alternates.sh b/t/t5410-receive-pack-alternates.sh index 0b28e4e452..d0053d95a4 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 1233a46eac..ddf3da5a26 100644 --- a/t/t5411/once-0010-report-status-v1.sh +++ b/t/t5411/once-0010-report-status-v1.sh @@ -33,15 +33,13 @@ test_expect_success "proc-receive: report status v1" ' printf "%s %s refs/heads/main\0report-status object-format=$GIT_DEFAULT_HASH\n" \ $A $B | packetize fi && - printf "%s %s refs/for/main/topic1\n" \ - $ZERO_OID $A | packetize && - printf "%s %s refs/heads/foo\n" \ - $ZERO_OID $A | packetize && - printf "%s %s refs/for/next/topic\n" \ - $ZERO_OID $A | packetize && - printf "%s %s refs/for/main/topic2\n" \ - $ZERO_OID $A | packetize && - printf 0000 && + test-tool pkt-line pack <<-EOF && + $ZERO_OID $A refs/for/main/topic1 + $ZERO_OID $A refs/heads/foo + $ZERO_OID $A refs/for/next/topic + $ZERO_OID $A refs/for/main/topic2 + 0000 + EOF printf "" | git -C "$upstream" pack-objects --stdout } | git receive-pack "$upstream" --stateless-rpc \ >out 2>&1 && diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 8a5d3492c7..ff0b7dd89f 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 7c1460eaa9..8ccaae1047 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 e5d3d15ba8..e6c8338b64 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 82c31ab6cd..2dde034881 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 038fffd3d0..44e2c0d3de 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 Wed Jul 14 00:54:04 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: 12375469 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 640D6C07E95 for ; Wed, 14 Jul 2021 00:54:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AF0A61370 for ; Wed, 14 Jul 2021 00:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237225AbhGNA5F (ORCPT ); Tue, 13 Jul 2021 20:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237214AbhGNA5C (ORCPT ); Tue, 13 Jul 2021 20:57:02 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5304DC0613EE for ; Tue, 13 Jul 2021 17:54:11 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id f17so979033wrt.6 for ; Tue, 13 Jul 2021 17:54:11 -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=+i+IFrFqHxB3Xd31yVqr/mypKHo7HjZpG3IR7j+cwz4=; b=ShdF2ZjcV0rMhjINQOZFojP6EeklGUiF93aPXgkBYilNzCs9aQkfZXqFRzM9t4Vc3C UsJG1H+Ma1uIA5Kbvxr6mmzlooJ1yhTwAY4M6L7TbcPw/CR5Z2rCD4MY8Z6Tq0cepsUQ 8L/raBYWWkwnfQUedF6v/ZnIXn4oeXeAgOkuhGYzCZvzmxnl9AhWwA8Xds2wjhIv7wYZ KCuVSZOCe1XCwA7TwpqKVuUSxpfhowMWTQwL+nRjmiAK3w9BA3lHl99/jpUz4I0D7F5d hi3z7EC4cm+9uM8LIrG9CKzurxBMYtVpYODCRVFIVZL1sC4rMJUFxBhapvhLduzhfQWr Z/Cw== 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=+i+IFrFqHxB3Xd31yVqr/mypKHo7HjZpG3IR7j+cwz4=; b=lzWUnehklABF7C+WFK5dDdymnt7FhBHyC+Ru/B6uRpKuZ4t4pgwr9yKZA2LoDea2At fkIGFyFsbdq4uBXDiv4exkq9B1CkfR6pImbiWOeFUAqGJOely9CSxFzTdXc76XeRZvPR lLGdK6CZvr3QkcvLC1UL96HVAN79SjdvmtwewEVuxiIuWQsnkDOC+kOBuMvk4F4+/2Ur YI4QVdLKpBPMlLRgTlyiV54GPzSgxrDx58UgM9bHaX5ZA0f2L74ZWxLRI5RJ8aHZRq8C wU3TCmxc7dJS8F8hgmh6V0YqJsNRy6LlptCbHbZhh6TNQ3iB7PIbR4lljPVxRU4OCU1Z kxRA== X-Gm-Message-State: AOAM530SKywHHES9AOpHuPslGt05OCuO2xeihfDhYr2NJFu785gsaFn4 VM1xVsiSyfuctZIx0W4sxAsJbeHuVYsJevcu X-Google-Smtp-Source: ABdhPJwesv7I82KxcgwLkbuub+Ztx01H7mHIWih/Om2SDOHiKF8DgszhUl/x7kHXbuP48tcs4SotHA== X-Received: by 2002:a05:6000:1841:: with SMTP id c1mr8892140wri.423.1626224049714; Tue, 13 Jul 2021 17:54:09 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g3sm463315wru.95.2021.07.13.17.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 17:54:09 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Date: Wed, 14 Jul 2021 02:54:04 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.788.ge724008458 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 | 8 ++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c index 5e638f0b97..c5e052e537 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; + + 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 ddf3da5a26..666b3d8726 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 && test-tool pkt-line pack <<-EOF && $ZERO_OID $A refs/for/main/topic1 diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index e6c8338b64..23a8a8d5c7 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 2dde034881..e2cb4f376d 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -194,9 +194,13 @@ 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" + printf "git-upload-pack /interp.git\n\0host=localhost" | + test-tool pkt-line pack-raw-stdin && + test-tool pkt-line pack <<-\EOF + 0000 + EOF } >input && + fake_nc "$GIT_DAEMON_HOST_PORT" output && test-tool pkt-line unpack actual && From patchwork Wed Jul 14 00:54:05 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: 12375471 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 6123CC07E95 for ; Wed, 14 Jul 2021 00:54:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4840E6136E for ; Wed, 14 Jul 2021 00:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237236AbhGNA5H (ORCPT ); Tue, 13 Jul 2021 20:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237223AbhGNA5D (ORCPT ); Tue, 13 Jul 2021 20:57:03 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0786DC0613DD for ; Tue, 13 Jul 2021 17:54:12 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id v5so986481wrt.3 for ; Tue, 13 Jul 2021 17:54:11 -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=NEDd+eUowNv2+u11H7bEKNYEV3vvVpWW0Rosx1GkS7A=; b=ZrSNeQlLUWVdJvhRpbxfaG+IJLz3k4WVsmeDfXz4dCNpZgK4N+ynV+/tCIANajJHvr s6EoTliOuHMEN7rwuGFU3YcNMnVC6xLWoWGSU2Ni9dRXpSFP0OKC6E3aYpMxVvuVCpXA OLDrDQQy8l+7j3TVSaF4w/I+1T/juh3b7XJDtwKy5VvuQl3zosJa9DmXZJlnqOFZrcF4 u/IQKrWTz89kXaEP6d0jVQIf8ptcUOHfh7cr3KhIrK/UKUwMn+veyvH4LAsZpQNGhiRC E9LTVPDhFNpeTYwu1B6qGFRmD9iRKsVv7siiYoTzKR4KUwDORzSCgRwaeCgUnCJdBLs0 jbSg== 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=NEDd+eUowNv2+u11H7bEKNYEV3vvVpWW0Rosx1GkS7A=; b=PlxsmaJ6LdO/Hr8+xnM3bRhC6TCKIx9tzLG/WpFfhp2qZB6tgwxE06EN5+432MhSYF uCC97ku/jjWj4hk/RC3oQFmHyTefls7T8BCCFQzclZJC5qSmvY8q5vkUh1ia4ejhWBlb OaJociMXuvj8dSqPqrsTVTmO94mVO2KbPI2NYpF22JGE9QaKJhUo69ELh0uvUVrQjAkQ hmhRfghK3JK5Np0dyfBPSDWuXuNAqqJHOj80a9B4CarvJbrCtpaSRK724hDCm1Tp2pbE SaySU8q4ZFOJYgYZqIOsaIvjLCkD0jb/za4dDaLZEedXBHJSfI6EWcfnadqgOBjji8tH /9uQ== X-Gm-Message-State: AOAM530+MG6R1haX7oUHVTrqfelOcU9Kveooqbjz4+WXkdMfICJG07vP qyWM2A3pbzDYPC7yn7tkKjaQpH0UWgi11F83 X-Google-Smtp-Source: ABdhPJz9O+3UXuWALxsiPKRNxZlIiKCOT7p5bxN+W5gszpdxHYNdQCuNfZsD8MtQpRRRLogGPwonbw== X-Received: by 2002:adf:dcca:: with SMTP id x10mr9053811wrm.59.1626224050491; Tue, 13 Jul 2021 17:54:10 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g3sm463315wru.95.2021.07.13.17.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 17:54:09 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Date: Wed, 14 Jul 2021 02:54:05 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.788.ge724008458 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 b2810478a2..77e4434dcd 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 () {