|
From: | Jim Porter |
Subject: | Re: build-aux/git-hooks/pre-push |
Date: | Mon, 1 May 2023 09:55:08 -0700 |
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.)
[Prev in Thread] | Current Thread | [Next in Thread] |