From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: master d3ec68f5e43: ; Fix post-commit and pre-push hooks in worktrees again Date: Fri, 05 May 2023 11:28:43 +0800 Message-ID: References: <168321910568.3995.3571437191907192632@vcs2.savannah.gnu.org> <20230504165146.0F159C22EE0@vcs2.savannah.gnu.org> Reply-To: Ruijie Yu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15618"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.22; emacs 30.0.50 Cc: Emacs developers To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 05 05:43:26 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 1pumLt-0003vT-Tv for ged-emacs-devel@m.gmane-mx.org; Fri, 05 May 2023 05:43:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pumKz-00012C-Sx; Thu, 04 May 2023 23:42:30 -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 1pumKy-00011z-KU for emacs-devel@gnu.org; Thu, 04 May 2023 23:42:28 -0400 Original-Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pumKw-000152-NM for emacs-devel@gnu.org; Thu, 04 May 2023 23:42:28 -0400 Original-Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 30150dc5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 5 May 2023 03:42:24 +0000 (UTC) In-reply-to: <20230504165146.0F159C22EE0@vcs2.savannah.gnu.org> Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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:305844 Archived-At: Jim Porter writes: > branch: master > commit d3ec68f5e433e5792c1c63672c7b437bb29c5759 > Author: Jim Porter > Commit: Jim Porter > > ; Fix post-commit and pre-push hooks in worktrees again > > * build-aux/git-hooks/post-commit: > * build-aux/git-hooks/pre-push: Use "$(dirname $0)" to get the hooks > directory. > --- > build-aux/git-hooks/post-commit | 4 +++- > build-aux/git-hooks/pre-push | 4 +++- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/build-aux/git-hooks/post-commit b/build-aux/git-hooks/post-commit > index 05f2d778b5c..10f43b539ac 100755 > --- a/build-aux/git-hooks/post-commit > +++ b/build-aux/git-hooks/post-commit > @@ -34,6 +34,8 @@ > > ### Code: > > +HOOKS_DIR=$(dirname $0) > + >From the first look, it seems that we assume the worktree root dir name should never contains spaces. Is this intended? I guess the previous versions also assumed this (according to the ${GIT_DIR:-.git} in the quoted portion below), but I just wanted to be sure about it. Also, while looking into the build system (because I know make is always unhappy about spaces), I noticed these lines in Makefile (which is auto-generated from Makefile.in): --8<---------------cut here---------------start------------->8--- $ grep --line-number -e abs_ Makefile 192:abs_srcdir=/opt/src/emacs/base/emacs-30 266:buildlisppath=${abs_srcdir}/lisp 461: @for dir in '$(abs_srcdir)' '$(lispdir)' '$(archlibdir)'; do \ 497: @(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${abs_srcdir}"`; \ --8<---------------cut here---------------end--------------->8--- Notice that lines 461 and 497 protects against spaces (presumably), whereas line 266 doesn't. If we do expect spaces in git root, line 266 might be an issue. > # Prefer gawk if available, as it handles NUL bytes properly. > if type gawk >/dev/null 2>&1; then > awk="gawk" > @@ -42,4 +44,4 @@ else > fi > > git rev-parse HEAD | $awk -v reason=post-commit \ > - -f ${GIT_DIR:-.git}/hooks/commit-msg-files.awk > + -f $HOOKS_DIR/commit-msg-files.awk > diff --git a/build-aux/git-hooks/pre-push b/build-aux/git-hooks/pre-push > index 6ff59102fd7..8d5dde2bbaf 100755 > --- a/build-aux/git-hooks/pre-push > +++ b/build-aux/git-hooks/pre-push > @@ -31,6 +31,8 @@ > > ### Code: > > +HOOKS_DIR=$(dirname $0) > + > # Prefer gawk if available, as it handles NUL bytes properly. > if type gawk >/dev/null 2>&1; then > awk="gawk" > @@ -83,4 +85,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_DIR:-.git}/hooks/commit-msg-files.awk > +' | $awk -v reason=pre-push -f $HOOKS_DIR/commit-msg-files.awk -- Best, RY [Please note that this mail might go to spam due to some misconfiguration in my mail server -- still investigating.]