From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Basil Contovounesios Newsgroups: gmane.emacs.devel Subject: Re: build-aux/git-hooks/pre-push Date: Thu, 04 May 2023 12:37:35 +0200 Message-ID: <87ttwspekw.fsf@tcd.ie> References: <875y9cef96.fsf.ref@yahoo.com> <875y9cef96.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39741"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Po Lu , emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 04 12:38:43 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1puWME-000AC1-90 for ged-emacs-devel@m.gmane-mx.org; Thu, 04 May 2023 12:38:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puWLT-0006L9-2F; Thu, 04 May 2023 06:37:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puWLL-0006Kx-CD for emacs-devel@gnu.org; Thu, 04 May 2023 06:37:47 -0400 Original-Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1puWLG-0005so-9V for emacs-devel@gnu.org; Thu, 04 May 2023 06:37:43 -0400 Original-Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5144a9c11c7so213556a12.2 for ; Thu, 04 May 2023 03:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; t=1683196660; x=1685788660; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=iMcT6KSnXNAjoSEXkp2rWFpOMZscl3LYvtEtxgEb+0c=; b=Az0qi51n2xDXRtS6fKEcOYHQCm1V0gieeQsE4OqBXSkD0AId3uEOl1BqhmhDA6Hj+Q DvDedzoa82PXOZhbPa8ZcNxiiVGtrAqaJEpJj5YthpX0EE6E2gQyxVB0gF+ChKuIbk8B Wqu3C/QOamY38/vXzwGVQY+7RZNGHzGPnu/cs3X6x1FYxfTPW5hJyd9CqQ+zRXgeL9yP PqYD4u+KUHL2fNdVh9A3RqBZuaSl++EX01D0PmhbqBCS0op8r+2CsQ822gdEdTHJaSWy iWlEpvuVS5r3nUfdWbZFmrHon/JbgKxG2WISkrcndowzLOA4IiwE4MJNyOOh+ihYM50A Pm5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683196660; x=1685788660; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iMcT6KSnXNAjoSEXkp2rWFpOMZscl3LYvtEtxgEb+0c=; b=ghbuEBoy+stEeMbRYgc1JuawBPj7HwkMHl4NoiJ15Jd85twDcBLnvoE6UKnq09xFO4 NhWHfE2kW91rfbgSshpIdPWtkuDPFb5gKRwE2gq+Wc0t7+2REUlr8d5jMLWjUFq7cZfk KhYOWUPYETTG9dkWahQUYlmpUWXfuRYYvwtQpQyefa+FqvZYc98AhJK2bdOizViZtYSA 7T3ommmeD9UCX9mldVpJ2D2/DIXgtuSkXqKrTEwVktKEH8S7RmCXJ7qE4aQsdQ7DWg1M FnsODJ/G6LtROtMNcPLl7Wl03JXNVc8PbB2Rw/Ui8ux6P2YRfQm7CeQHZVqC2lD0K/t2 2eaQ== X-Gm-Message-State: AC+VfDy4/HQ0fffAehxEfuZAhVFNTkzZxBOI1JlsfMZJwxIeZti57yRE 5hf3NrKQO2ZiRgzuJi6Oy5yMTQ== X-Google-Smtp-Source: ACHHUZ4qN8VxwjGOXSp9XVWHj6HF1VoBg1uZXT3ObPWq0lQt/kcuXP8HtXNL81pQswJRXTXx2Fy7kA== X-Received: by 2002:a17:902:c40a:b0:1a5:f9b:27bd with SMTP id k10-20020a170902c40a00b001a50f9b27bdmr4304851plk.34.1683196659752; Thu, 04 May 2023 03:37:39 -0700 (PDT) Original-Received: from localhost ([162.210.129.5]) by smtp.gmail.com with ESMTPSA id q6-20020a17090311c600b001a4fecf79e4sm9794421plh.49.2023.05.04.03.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 03:37:39 -0700 (PDT) In-Reply-To: (Jim Porter's message of "Mon, 1 May 2023 09:55:08 -0700") Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=contovob@tcd.ie; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305829 Archived-At: Jim Porter [2023-05-01 09:55 -0700] wrote: > On 4/30/2023 11:29 PM, Po Lu wrote: >> This script apparently loses when pushing from a separate worktree, >> where .git is a file containing the name of the repository the worktree >> was created from. > > Thanks for catching this bug. > >> The following adjustment seems to fix it. However, I don't know much >> about git. Objections? >> diff --git a/build-aux/git-hooks/pre-push b/build-aux/git-hooks/pre-push >> index 8e8277cba4f..8a2866f9d4c 100755 >> --- a/build-aux/git-hooks/pre-push >> +++ b/build-aux/git-hooks/pre-push >> @@ -83,4 +83,4 @@ $awk -v origin_name="$1" ' >> # Print every SHA after oldref, up to (and including) newref. >> system("git rev-list --first-parent --reverse " oldref ".." newref) >> } >> -' | $awk -v reason=pre-push -f .git/hooks/commit-msg-files.awk >> +' | $awk -v reason=pre-push -f build-aux/git-hooks/commit-msg-files.awk >> > > That won't quite work in general, since it would mean that if you check out an > old branch, "build-aux/git-hooks/commit-msg-files.awk" won't exist, and then the > hook will fail. Instead, I pushed a change to replace ".git" with > "${GIT_DIR:-.git}", which is (as far as I can tell) the right way to do this. > > (The fallback to ".git" in the expansion is purely defensive, just in case > there's some old Git version that doesn't set that variable.) I have a clone of emacs.git under ~/.local/src/emacs, where the master branch is checked out under the same name. Then I have a worktree under ~/.local/src/emacs-29, where the emacs-29 branch is checked out in a branch named wt/emacs-29. I get the following when I try to push from that worktree: $ git push upstream wt/emacs-29:emacs-29 gawk: fatal: cannot open source file `/home/blc/.local/src/emacs/.git/worktrees/emacs-29/hooks/commit-msg-files.awk' for reading: No such file or directory error: failed to push some refs to 'git.savannah.gnu.org:/srv/git/emacs.git' So maybe we should be defensive about the existence of this hook? Or am I doing something wrong? Thanks, -- Basil