all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Basil Contovounesios <contovob@tcd.ie>
To: Jim Porter <jporterbugs@gmail.com>
Cc: Po Lu <luangruo@yahoo.com>,  emacs-devel@gnu.org
Subject: Re: build-aux/git-hooks/pre-push
Date: Thu, 04 May 2023 12:37:35 +0200	[thread overview]
Message-ID: <87ttwspekw.fsf@tcd.ie> (raw)
In-Reply-To: <e0e2ce4c-9a9b-7d8e-3d6f-90f9f8000397@gmail.com> (Jim Porter's message of "Mon, 1 May 2023 09:55:08 -0700")

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



  parent reply	other threads:[~2023-05-04 10:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <875y9cef96.fsf.ref@yahoo.com>
2023-05-01  6:29 ` build-aux/git-hooks/pre-push Po Lu
2023-05-01  6:33   ` build-aux/git-hooks/pre-push Po Lu
2023-05-02  5:35     ` build-aux/git-hooks/pre-push Jim Porter
2023-05-02  5:55       ` build-aux/git-hooks/pre-push Po Lu
2023-05-01 16:55   ` build-aux/git-hooks/pre-push Jim Porter
2023-05-02  0:08     ` build-aux/git-hooks/pre-push Po Lu
2023-05-04 10:37     ` Basil Contovounesios [this message]
2023-05-04 16:28       ` build-aux/git-hooks/pre-push Jim Porter
2023-05-04 16:42         ` build-aux/git-hooks/pre-push Basil Contovounesios
2023-05-04 16:56           ` build-aux/git-hooks/pre-push Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttwspekw.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=emacs-devel@gnu.org \
    --cc=jporterbugs@gmail.com \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.