From patchwork Fri Sep 18 11:19:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11784699 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 9ED90618 for ; Fri, 18 Sep 2020 11:19:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7917521D92 for ; Fri, 18 Sep 2020 11:19:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TxNtUR1g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbgIRLTf (ORCPT ); Fri, 18 Sep 2020 07:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgIRLTe (ORCPT ); Fri, 18 Sep 2020 07:19:34 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42234C06174A for ; Fri, 18 Sep 2020 04:19:34 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 34so3273695pgo.13 for ; Fri, 18 Sep 2020 04:19:34 -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=RqByowbAp/WKK91LsRuCZSWcIkQDc5H71fNPjOa11t4=; b=TxNtUR1gqcHxBkL3zeKPw0srQqVlvNRGdAdNfoDzmAEtTkDOvk6aCXDovj1oGP0IZY NfJLdIV6o0BtbJOn2Mp1QfkqmeFJwFSvSm8eIS0xn1S/iupsfU+fsP5RcnajWtlijLK9 nx8OMQkwpwZ0rMEQh/poNDiDOR+gvGT47Gw5y0RDbNFvxB4OqIdVVS44N7haUqJ2LmCy fnmlEj1JDDfHR2shE+moBbn75U0PR042WrbU51m/skXcisG3A5q5zJruuAqbjbxLR2y3 /avq4CNh0YExINFr0u91gqTm4/Rif6wP2rYTbcqkP9KCTxUzxqtvECJ6JmJjEMJIisA7 McJA== 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=RqByowbAp/WKK91LsRuCZSWcIkQDc5H71fNPjOa11t4=; b=rlZInWO1fUx5heaLwCjIcS5CLtfF8u6ptFFzxs9dZIFbs6kRgVKwiwlr2JbCImXSVP 7lHK4DzjEpX910adjYMiF7CBaohLtRnFIZyxkeAi9u4BWrYmVNHJRoM3Ex5yJYvJyCuF LdgXJXAnqthGXu9QffkfzW8Yn/aiOBcHNDmV+1WK1SlZiQs3URL7Rei4tnh/shWg4Asc R6/B2l+hglRwUtYgugUGVxQ3CZfma2nwLHUsazuezSMTp251Y0XOD7tIwBB3hMGY9qYx kqLePGpGQoPPvbB/3J2xm94iByKOt8JtQ9Y4620dN0DLdwfmgN2y5rMhhd2zxiTsErst cRIg== X-Gm-Message-State: AOAM530xHY0I70oUiEXvOSNblrc0OhhSjRzvtwG12xNda+8niMBPdTXJ XNuK0HEoF8vlieHp5JPEsh+aN7PsnJc= X-Google-Smtp-Source: ABdhPJwZPXnC0YY78ekkq2b47Z85lyU4NPWmAa933JiJvQnv2HwHJ2Wd1CTATRbM5nOMDE0OaqissA== X-Received: by 2002:a63:5a5d:: with SMTP id k29mr26245205pgm.51.1600427973608; Fri, 18 Sep 2020 04:19:33 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id x4sm3034120pff.57.2020.09.18.04.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 04:19:33 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" Subject: [PATCH 1/4] hooks--pre-push.sample: prefer $() for command substitution Date: Fri, 18 Sep 2020 04:19:02 -0700 Message-Id: X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 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. Signed-off-by: Denton Liu --- templates/hooks--pre-push.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample index 6187dbf439..64b5707553 100755 --- a/templates/hooks--pre-push.sample +++ b/templates/hooks--pre-push.sample @@ -41,7 +41,7 @@ do fi # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` + commit="$(git rev-list -n 1 --grep '^WIP' "$range")" if [ -n "$commit" ] then echo >&2 "Found WIP commit in $local_ref, not pushing" From patchwork Fri Sep 18 11:19:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11784697 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 CB07A618 for ; Fri, 18 Sep 2020 11:19:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF7A221D92 for ; Fri, 18 Sep 2020 11:19:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="glr7iBMj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbgIRLTg (ORCPT ); Fri, 18 Sep 2020 07:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbgIRLTf (ORCPT ); Fri, 18 Sep 2020 07:19:35 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A33BC06174A for ; Fri, 18 Sep 2020 04:19:35 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id q4so2997886pjh.5 for ; Fri, 18 Sep 2020 04:19:35 -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=BHsWF7dJdbWokH4rE+MBlWYCUaAGHLxaSJocNbDCLBw=; b=glr7iBMj5pnGcvpBzfa4uGpresCA9EaXpSn1M4cLn/A+GYOhcW8Rb7DylycyvaJsZ7 jchLt2EgkcCbrL0eBpJjZRvPmAZtKj4C6/DGkMB7lpW87IZT9HeqDFY24uvhHa/L8T8q Hj0p26HeLO1wDQxoL1xitAW6ZMwR5rW0ctpVjfUWMQ6HyBfcdiJut/rwx0591a05H2Z1 0hR+UipdWx/+xFu6LsaAA4MV5e1h0jsj+CT21PalzjpqulT35krTjwD8ZQ+lIahwddmZ SXPVCto+rJz97axL/27Ah/d/bTwZR77AIkbtaig9kpSou7X3R+byKsQXZoDafIxNBrX+ lgjQ== 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=BHsWF7dJdbWokH4rE+MBlWYCUaAGHLxaSJocNbDCLBw=; b=SxO+CDlT4Iymkst4gteh4riNOT0hRNTUP/NRRN+xaOWMmkB9P6cQfxbuh4lfqlN35Y bmM9sgLs/olkEXWHkVzna2XuABttgDNnkkqwRxpe2JSVESwcEiV4cjMce2EfskLQT4Vc MmAYs+41CqspT/SIn+CfKkRvQLJpCBd5ueczJtFE6LFljmsbnII5ufbjrtMaVful96yn qhe16yZcojqBZ0wMe63beGATesbu7gX8MeWyq15Wi7zvdQ8rX08/pIhzAThnVhfqCHXc zDyP2Vs0/uSgAKXJgGJG4ngTbTjAhlV7+XM4XW6Xz122RFG6G8LFK9nThlA8CD2Mj/GX dHqg== X-Gm-Message-State: AOAM530cbR7zN2tmBUklh2ZXcM5cxZpHecxDAY0X2jFNdp2L3ls0oilD /5BKx5Qg9+nMI3vBNLHa7wasP9sr6kM= X-Google-Smtp-Source: ABdhPJwDyqRyZuJYmJFk+siUkohir/wv3JrCsXtBQqcWn0oHk7EiYsjUe1JudLJE5oZNp5ShgTd6sw== X-Received: by 2002:a17:90a:cf07:: with SMTP id h7mr12403704pju.142.1600427974651; Fri, 18 Sep 2020 04:19:34 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id x4sm3034120pff.57.2020.09.18.04.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 04:19:34 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" Subject: [PATCH 2/4] builtin/rev-parse: learn --null-oid Date: Fri, 18 Sep 2020 04:19:03 -0700 Message-Id: <004f2e4c92918a7a4e452d49e98ef15f1c5ac545.1600427894.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When a user needed the null OID for scripting purposes, it used to be very easy: hardcode 40 zeros. However, since Git started supporting SHA-256, this assumption became false which may break some scripts. Allow users to fix their broken scripts by providing users with a hash-agnostic method of obtaining the null OID. Signed-off-by: Denton Liu --- Documentation/git-rev-parse.txt | 4 ++++ builtin/rev-parse.c | 4 ++++ t/t1500-rev-parse.sh | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 19b12b6d43..b370d425d7 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -285,6 +285,10 @@ print a message to stderr and exit with nonzero status. Other Options ~~~~~~~~~~~~~ +--null-oid:: + Print the null OID (the OID containing all zeros). This OID is + used to represent a non-existent object. + --since=datestring:: --after=datestring:: Parse the date string, and output the corresponding diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index ed200c8af1..4e4ca99775 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -910,6 +910,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) } continue; } + if (!strcmp(arg, "--null-oid")) { + puts(oid_to_hex(&null_oid)); + continue; + } if (skip_prefix(arg, "--since=", &arg)) { show_datestring("--max-age=", arg); continue; diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 408b97d5af..8c1bd543ef 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -185,4 +185,10 @@ test_expect_success 'showing the superproject correctly' ' test_cmp expect out ' +test_expect_success 'rev-parse --null-oid' ' + echo "$(test_oid zero)" >expect && + git rev-parse --null-oid >actual && + test_cmp expect actual +' + test_done From patchwork Fri Sep 18 11:19:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11784701 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 596FE6CA for ; Fri, 18 Sep 2020 11:19:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CF9321D92 for ; Fri, 18 Sep 2020 11:19:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GDyBOfx4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgIRLTh (ORCPT ); Fri, 18 Sep 2020 07:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgIRLTg (ORCPT ); Fri, 18 Sep 2020 07:19:36 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDCEC06174A for ; Fri, 18 Sep 2020 04:19:36 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id y1so3283281pgk.8 for ; Fri, 18 Sep 2020 04:19:36 -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=OF+DcgfZVaY5a9qdI91H3wnJhvr2yxUA11R9BvhWr9U=; b=GDyBOfx4oVNW5brwqUKNJqFEViu5qw5TPUXYCUHBf55aptpE3BDKAvUtFGaqsxqzfL egIvsVrG1QxpncGJVmepUqemvkypT/wwkkQmuDIcgsILNL2qVY5Jy6aqmEO2e/gEIIpJ d3idvxO+d42TMLoTc8PoFTf7LglF2uRiW5NNrgpHaiEL/vfzmJrJt7BA8ttXVpkpQFNG ubrgg0vwTRg+myf85lM7WasBSH6xOtCXXNfcgnb3tEhCBQRoVOV6W93jdy61hFucuAk8 F43dAPLhRj2W5Msq623w92OfDiX68jx533pVKQ7bV3oE5TKUR1tuP9p+l6G4D6Y+zMcb anaQ== 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=OF+DcgfZVaY5a9qdI91H3wnJhvr2yxUA11R9BvhWr9U=; b=D0+36vlGT1vLDBhx5D+KXKRsiFL/MKzlwEUkp2CgggPOmIXdeH+Ljub3eoH+hElvbf mxDCZBJ+nU9mNg+8uFfV01fPumXvHYYjnbD5sBSf5mYZg7RpAn0ZP2JMWVMYxMx0IIED XOIwYVow5lCQPGYe59IDsZcBNX6MZ9xyGhS68cSljPTCNrPooSbjpMmxwbxQJVTGxLq8 sRLybHHsoxks789ad2eYNeiPRoOXe/b2Bwu+/vQsyjECEU764MdzqThAWVLFwJjshXUe 1NLlVkpyaKbqTzg8YSoKREs0gKCxYEWBMRZYSQln1HywabV5MNpemUn1YV5EGHVDHYzE 1ZUg== X-Gm-Message-State: AOAM5311GDKhZmKZIbNNYIDhqsiCMxRIE4B+MoNhsQcxWmnx25U5yhuo O+cnjiCSGikBssfs8VQlPJg+7Uo2cLQ= X-Google-Smtp-Source: ABdhPJyvTy6+mgJ8maMd3PE9H9tfm500yC+oEYjOLZgE76aCrZBa9YZSGdZkRGadh5bL2yF+ZuCIzw== X-Received: by 2002:a63:1c4a:: with SMTP id c10mr25668108pgm.22.1600427975611; Fri, 18 Sep 2020 04:19:35 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id x4sm3034120pff.57.2020.09.18.04.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 04:19:34 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" Subject: [PATCH 3/4] hooks--pre-push.sample: use hash-agnostic null OID Date: Fri, 18 Sep 2020 04:19:04 -0700 Message-Id: <9d6c2951ab0a2c2e92353c238b008538fe6a6327.1600427894.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 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 null 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 rev-parse --null-oid` so the sample hook becomes hash-agnostic. Signed-off-by: Denton Liu --- 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 64b5707553..b3bc5276bf 100755 --- a/templates/hooks--pre-push.sample +++ b/templates/hooks--pre-push.sample @@ -22,16 +22,16 @@ remote="$1" url="$2" -z40=0000000000000000000000000000000000000000 +null_oid="$(git rev-parse --null-oid)" while read local_ref local_sha remote_ref remote_sha do - if [ "$local_sha" = $z40 ] + if [ "$local_sha" = "$null_oid" ] then # Handle delete : else - if [ "$remote_sha" = $z40 ] + if [ "$remote_sha" = "$null_oid" ] then # New branch, examine all commits range="$local_sha" From patchwork Fri Sep 18 11:19:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11784703 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 C257A6CA for ; Fri, 18 Sep 2020 11:19:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A275121D92 for ; Fri, 18 Sep 2020 11:19:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LjNqk3nu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbgIRLTl (ORCPT ); Fri, 18 Sep 2020 07:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgIRLTh (ORCPT ); Fri, 18 Sep 2020 07:19:37 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CEBBC06174A for ; Fri, 18 Sep 2020 04:19:37 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id b124so3222995pfg.13 for ; Fri, 18 Sep 2020 04:19:37 -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=QI0CvwzbDt815bAj/1bM6TD12ES+6y22JgoOubeRZVw=; b=LjNqk3nulNwt6kS2PK47a+yM3OZoNin4QbgVOE1UNZQWqySYMN4I66F6QudkKV52hV SkFc70hspfnAdFHDD5crDKeN92KNaBaJ0w0bloQR49eKGBEa8YKn7TajwS7BKHLmgtth JzxctKWmhfbgWAVHtxm+4RL731tGGBQ5/Rh6aN9/k3aBOAifBrievK1zI/ctBG0FffcB Ucuvtr25vlxHU8BIoF88rOl7LW+LjPnHtuMvwG14cboBPWQvBWgVvCGUaI6eLpPMCsk4 3a/tkLM84PkwY5T8jQ64hKIwgVo/5Zs5dF+4eMmb/QgH6Tj7OkkCAK4aXxDWM9xyYrIu k2Eg== 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=QI0CvwzbDt815bAj/1bM6TD12ES+6y22JgoOubeRZVw=; b=rFpOMa2sueybFSzgeP+twG6m3MP74ifZrq+Mlitm4252CQ3PVrG3OZZMosaztlqY7f IwtTdEyrFuCis5PghGLAZH8cT085lCCQByAo/GccCplVoi7EgGBC9BsyRk7cQTVffuZ5 0C0SIXj6toY2EcyTX3dLydJpxLUK5MNSvMbQwQGg2cxblrtlhINEEs/X7gd7wZu4u2Xo WYujfsXeF35pHW/41rTTHJS/WGrYFQSzYNGjIPx0KqsGoSVNGiwwFCC9YWLn4U/Y/Mmq +pEy72Z3m/TaC6gaNc7O7lgwsHg510k48dkle9yXsx/UfhbzSPw55QmjWVYu9HdlNOrN 1KQQ== X-Gm-Message-State: AOAM533yqYDDZE5Yjk4/kJwqCgIlqDf/K8P73oB9OSMp+cS6lUNjDwv8 whi+vtK/Bjr3r68WFPcqjUTbzHTD7H0= X-Google-Smtp-Source: ABdhPJxKaFc9qtWVkvyleoRyjvu0ln7ee1tbndEIj2xMJ8hQwumtDhwFVPbCawboFBPCsPTmCKhmQQ== X-Received: by 2002:a62:19c4:0:b029:13e:d13d:a081 with SMTP id 187-20020a6219c40000b029013ed13da081mr30876132pfz.24.1600427976970; Fri, 18 Sep 2020 04:19:36 -0700 (PDT) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id x4sm3034120pff.57.2020.09.18.04.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 04:19:36 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: "brian m . carlson" Subject: [PATCH 4/4] hooks--update.sample: use hash-agnostic null OID Date: Fri, 18 Sep 2020 04:19:05 -0700 Message-Id: <42d282988961545fb1ab6405a08368d14ffa1450.1600427894.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 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 null 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 rev-parse --null-oid` so the sample hook becomes hash-agnostic. Signed-off-by: Denton Liu --- 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..5316362af5 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 rev-list --null-oid)" if [ "$newrev" = "$zero" ]; then newrev_type=delete else