From patchwork Wed Sep 23 09:38:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11794413 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 611ED6CB for ; Wed, 23 Sep 2020 09:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45EA023600 for ; Wed, 23 Sep 2020 09:38:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VDsdW0Vo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbgIWJi5 (ORCPT ); Wed, 23 Sep 2020 05:38:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIWJi4 (ORCPT ); Wed, 23 Sep 2020 05:38:56 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77144C0613CE for ; Wed, 23 Sep 2020 02:38:56 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id u24so3232586pgi.1 for ; Wed, 23 Sep 2020 02:38:56 -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=iKj7F5cvjSGHtHmsaLdR4s9zi4yZlEC9oB4QE1NrV+M=; b=VDsdW0VoEwBhY6GjI+fQNBl9HXvLVJyHhvH/U+jDyV0Mi8ldEzt+CZMHx4nYwLtgen hto6vX2RTS+GvH22CPTvfCgGAFz0tl208vohqMoxVhJGTOjJAaS2FmHoBKjM0BWI7sxo UO+DAbgNfxAiQjYM+b6u+VG9AjPW+LD9OduYm06pe6fP4psoD7sFC1HflI2KBkHv4WOK WGvsX6LvRXufZbaVzEHe5XOg2r9SZFkqzkqCv0ev1DvHuhCTRCTggFSrUcnANQoUH4sU GI3vJpHKfKP4VecgFbhQAi7ZHu0cl5t2woSiVCUaowFdcw9cP4QgBEjPaP7WUG3hoGH8 p/YQ== 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=iKj7F5cvjSGHtHmsaLdR4s9zi4yZlEC9oB4QE1NrV+M=; b=RDontc6VIiIMqcq9YUhdU9rPFoP02XLTJvxGhqTKkbulgmxM+L/yYyv6xASIZBxMrH wfn9Xs1s3/O8kSA1qyy8n2MbbOuha7S54vO6xxbnfm0xj7LVMDQycFHSmUhd3mt7F5Bg TPGUCSUMTl94uayIRhI4I6NC4YseHKKZAYsOCSfB4fKCv3K5DqdFfpePGfJjqmdrv5uo diAYrhNjgGjZ3jXDpyePwvtdMQdYdJGvCCJ1bZkdclBXCVi+c2U/ofchUwJmGOIgRY+E Ea96+dOdF0+tp1Ei6T21IaM1y/kmLI5HIjTjbfbTuqGywM/DNNbqGkDQV2KmNmjz7A5G vNTg== X-Gm-Message-State: AOAM5339NqiSmtbWA7AC80xGp2Ixk5BmJEs0JxsPP+teEuyL5HK9KVC5 b38A31aqZN4nvC4mNV1oVXLIYjJTiGc= X-Google-Smtp-Source: ABdhPJy6SVt6b8C1Gou+3IxE48aNoD2YtMNqfZNsSOBOIbfTZWoSMNwyP49f0gMzsmAtYEjEFKUWog== X-Received: by 2002:a63:e813:: with SMTP id s19mr7145665pgh.33.1600853935827; Wed, 23 Sep 2020 02:38:55 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id gm17sm4564464pjb.46.2020.09.23.02.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 02:38:55 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" , Eric Sunshine , Taylor Blau , Junio C Hamano , Chris Torek , Andreas Schwab Subject: [PATCH v2 1/3] hooks--pre-push.sample: modernize script Date: Wed, 23 Sep 2020 02:38:43 -0700 Message-Id: <95dd0b19ba45ebe364235fa62e18aad932506fc9.1600853895.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.28.0.760.g8d73e04208 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The preferred form for a command substitution is $() over ``. Use this form for the command substitution in the sample hook. The preferred form for conditional tests is to use `test` over []. Replace [] with `test`. Finally, replace all instances of "sha" with "oid". Signed-off-by: Denton Liu --- templates/hooks--pre-push.sample | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample index 6187dbf439..d0f30190ac 100755 --- a/templates/hooks--pre-push.sample +++ b/templates/hooks--pre-push.sample @@ -14,7 +14,7 @@ # Information about the commits which are being pushed is supplied as lines to # the standard input in the form: # -# +# # # This sample shows how to prevent push of commits where the log message starts # with "WIP" (work in progress). @@ -24,25 +24,25 @@ url="$2" z40=0000000000000000000000000000000000000000 -while read local_ref local_sha remote_ref remote_sha +while read local_ref local_oid remote_ref remote_oid do - if [ "$local_sha" = $z40 ] + if test "$local_oid" = $z40 then # Handle delete : else - if [ "$remote_sha" = $z40 ] + if test "$remote_oid" = $z40 then # New branch, examine all commits - range="$local_sha" + range="$local_oid" else # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" + range="$remote_oid..$local_oid" fi # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` - if [ -n "$commit" ] + commit=$(git rev-list -n 1 --grep '^WIP' "$range") + if test -n "$commit" then echo >&2 "Found WIP commit in $local_ref, not pushing" exit 1 From patchwork Wed Sep 23 09:38:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11794419 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 80DAB112C for ; Wed, 23 Sep 2020 09:39:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 629382371F for ; Wed, 23 Sep 2020 09:39:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="twprkCyr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgIWJjA (ORCPT ); Wed, 23 Sep 2020 05:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIWJi5 (ORCPT ); Wed, 23 Sep 2020 05:38:57 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B17AC0613CE for ; Wed, 23 Sep 2020 02:38:57 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id u3so2877350pjr.3 for ; Wed, 23 Sep 2020 02:38:57 -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=aKUQW6AJ67TDxeKFE8lBYlSpxope2iA8F8Iyakiw5L8=; b=twprkCyr64UiFz9mnWJUbN15wazHKAhU9aCbH8gQcyiUG81ULoPkAAimSRMzjZICok RSq4x/QzFF4eF1CDciZxQjiVBvggxD3aGSQszs22lHc56BMQa3D9iv1939F6DVeWl9Dk fxT/m3NbJI8yaD159mwbR5DTmxQA38rHdTTYVMw64slCW0v1xPF/Ku2lER8nGY5RjA58 L3ZZ8pR/5PK0FNhnOB6L0uM4GFk+gfWVRhVysxKeoO9E4NHrqItrBQYKyG/UK9xDTUDt JeGQPxv1bpLn9tbzGE61zVu3jB44wbBb2oAORXS0a0R4quLKYRzOdIgssIIjrcNuPijp NLPA== 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=aKUQW6AJ67TDxeKFE8lBYlSpxope2iA8F8Iyakiw5L8=; b=ATzazv1NY8+04kJCrRNHaDmR09iHb83qKNJ28N/Q92+J53JjNc4QM6l0Ln8VE5+d5r u4bUHTsOWY+gjr7cTOnRdqYzO5qJyTnW28PqvCD3ludc9HFDX7+yCFqr+hJwgHC4EHy+ 3j8mi8fMi3TTv59OEHOoTIRKjQndu7UOZBNW5h9H4flASHfpEXxkT8AiWfqT2ZTVebYV lXDfA9SLUwosMZ/bsGPvTIox5tHvJt6hENd96NSpkKoFDOqlG/516SCkudxl+cIdxLzJ DjM1edFtFPH33ME172xaFAkZXA/w+hcHzDLuqjW6IJwLl/uMZNDCsOklWEgYi8Ekqtey QnZA== X-Gm-Message-State: AOAM530mygNcoqtBNbWv5mtgpY/Qri+096q4OMkHjbzylKBQ1YPGTAQ6 YHemYTh1q3fWynqTJR9WjV7Wi/CBHLA= X-Google-Smtp-Source: ABdhPJzwhcpihm02wOafPwpxRJaO5bPbL2LecjvYWfFMkXFmJMT6hHblUqtwKv0yQhwu9gmd+M+TXA== X-Received: by 2002:a17:90b:4a47:: with SMTP id lb7mr7434258pjb.196.1600853936923; Wed, 23 Sep 2020 02:38:56 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id gm17sm4564464pjb.46.2020.09.23.02.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 02:38:56 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" , Eric Sunshine , Taylor Blau , Junio C Hamano , Chris Torek , Andreas Schwab Subject: [PATCH v2 2/3] hooks--pre-push.sample: use hash-agnostic zero OID Date: Wed, 23 Sep 2020 02:38:44 -0700 Message-Id: X-Mailer: git-send-email 2.28.0.760.g8d73e04208 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The pre-push sample hook has the zero OID hardcoded as 40 zeros. However, with the introduction of SHA-256 support, this assumption no longer holds true. Replace the hardcoded $z40 with a call to git hash-object --stdin --- templates/hooks--pre-push.sample | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample index d0f30190ac..4ce688d32b 100755 --- a/templates/hooks--pre-push.sample +++ b/templates/hooks--pre-push.sample @@ -22,16 +22,16 @@ remote="$1" url="$2" -z40=0000000000000000000000000000000000000000 +zero=$(git hash-object --stdin X-Patchwork-Id: 11794415 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 E43DB139F for ; Wed, 23 Sep 2020 09:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C150B23600 for ; Wed, 23 Sep 2020 09:39:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PeZN8tS/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbgIWJjA (ORCPT ); Wed, 23 Sep 2020 05:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbgIWJi6 (ORCPT ); Wed, 23 Sep 2020 05:38:58 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93EC6C0613D1 for ; Wed, 23 Sep 2020 02:38:58 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id f1so6525162plo.13 for ; Wed, 23 Sep 2020 02:38:58 -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=/OA852YvvEb3sow70b0eYaOPFRAhD5IR13DjJ1Pxp68=; b=PeZN8tS//JlwD9E83QgaLJom4+os4V4wC0lxaIZlKZcT3QG7DGgud+BUlgqO2R8RlN FBZvixF2IwM2KkOBKmOx0SJyLyeSkbh6IFPOAs+KP8ANP/ZBW/m+QkUPO1jwz8FV/+OO FihzmKL6L+58BvF5eo5mIV1sVEM9pDIPHmk8/xDFyCQ3XoKTsTxZiBJA7CE/TdfY1up8 GFecZotJ0Tw8xMIk078BUCbzZQPsZ3qYWxUdAWETkzadi59f9t14RPjD1FuLW4CwXgIh ylq5V8PSw2n7g8CGSc0KuzE92zd3NTrGs4tffMr/gF0G9RLl4+ZJoC8DCvfcmVNaFkER 28kA== 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=/OA852YvvEb3sow70b0eYaOPFRAhD5IR13DjJ1Pxp68=; b=Xu5nXlCoq/L/Ln52YgfvJHKdnFo1XtS4Si09Q+K1Cm0aoDM9eho9gZZZv/aOWV/EVg 06VNiJ8FMwRf3oqtm0fB5GsF5C0Nj6XJukWaToXRKiMypDJa/Ap8z5lv09WlMsAQN6pa 0XoOZ1aqceJfl4aFA/Fgqs/TyjdA0+V0IoF9QYtJVivVkzwYWAIeZADeo21mO3MDgCjH Tv0O3op9v0PtcAmXFrQASdWWmIMGOZaO0Kw+OSw6PrzjkhkzdqBnP4QBJy9oJgUnWvEY YH2oBRXx80QkWA2aJMrC2HkKEzFP8X9JARYbIcoMn/vOmpzw9CkNqu3jX5BqCjtP0kjG bHUw== X-Gm-Message-State: AOAM533be+5L6qSI1atuw8wvAd/T4kDhQjzu8uBtuJb/sg9gBTbsovrx nxnVb5CKkajGdhCzv4mpilMGa9olutg= X-Google-Smtp-Source: ABdhPJxNuyNUuv/ClaJ8NlwBZ3QlcbGgHnngVr1+1p7F9OpDvkE9eD2K1iCo4AVK9ZEBiVQwXWSRBA== X-Received: by 2002:a17:902:fe0e:b029:d1:e5ec:28d6 with SMTP id g14-20020a170902fe0eb02900d1e5ec28d6mr8590275plj.66.1600853937927; Wed, 23 Sep 2020 02:38:57 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id gm17sm4564464pjb.46.2020.09.23.02.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 02:38:57 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" , Eric Sunshine , Taylor Blau , Junio C Hamano , Chris Torek , Andreas Schwab Subject: [PATCH v2 3/3] hooks--update.sample: use hash-agnostic zero OID Date: Wed, 23 Sep 2020 02:38:45 -0700 Message-Id: <784135549f2fd23a5135cb2b6c2c5ba525885814.1600853895.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.28.0.760.g8d73e04208 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The update sample hook has the zero OID hardcoded as 40 zeros. However, with the introduction of SHA-256 support, this assumption no longer holds true. Replace the hardcoded $z40 with a call to git hash-object --stdin --- templates/hooks--update.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample index 5014c4b31c..c4d426bc6e 100755 --- a/templates/hooks--update.sample +++ b/templates/hooks--update.sample @@ -60,7 +60,7 @@ esac # --- Check types # if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" +zero=$(git hash-object --stdin