git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Robert Foss <robert.foss@linaro.org>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	git@vger.kernel.org, "Drew DeVault" <sir@cmpwn.com>,
	"Rafael Aquini" <aquini@redhat.com>,
	"Marcelo Arenas Belón" <carenas@gmail.com>
Subject: Re: [PATCH v1] git-send-email: Respect core.hooksPath setting
Date: Mon, 22 Mar 2021 22:13:05 +0100	[thread overview]
Message-ID: <CAG3jFysGE-Wq2ReXmNa2VGPOWMW_MDn++Xv_WvAYW9EiQjAbdA@mail.gmail.com> (raw)
In-Reply-To: <875z1jqgpq.fsf@evledraar.gmail.com>

Hey Ævar,

Thank you for the quick feedback.

On Mon, 22 Mar 2021 at 17:46, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
>
> On Mon, Mar 22 2021, Robert Foss wrote:
>
> > get-send-email currently makes the assumption that the
> > 'sendemail-validate' hook exists inside of the repository.
> >
> > Since the introduction of `core.hooksPath` configuration option in
> > v2.9, this is no longer true.
> >
> > Instead of assuming a hardcoded repo relative path, query
> > git for the actual path of the hooks directory.
> >
> > Signed-off-by: Robert Foss <robert.foss@linaro.org>
> > ---
> >
> >
> > This patch does not include a test for this bug fix.
> > This is entirely due to me not being able to think up a way
> > to test this. So I'm very much open to suggestions.
>
> There's an "invoke hook" test in t9001-send-email.sh which should be
> easy to tweak (or mostly copy/pasted to another test) to run the same
> way once the hook is moved from .git/hooks to somedir/ and -c
> core.hooksPath=somedir is set.

Ack


>
> >  git-send-email.perl | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index 1f425c0809..3934dceb70 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -1942,8 +1942,9 @@ sub validate_patch {
> >       my ($fn, $xfer_encoding) = @_;
> >
> >       if ($repo) {
> > -             my $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),
> > -                                         'sendemail-validate');
> > +             my $hook_path = $repo->command('rev-parse', '--git-path', 'hooks');
> > +             chomp($hook_path);
> > +             my $validate_hook = catfile($hook_path, 'sendemail-validate');
>
> This looks like it work, small nits:
>
> 1. This would be better in perl/Git.pm, it already has various accessors
>    etc. for these rev-parse'd values. You could just pass a a new
>    GetHooksPath => 1 to Git->repository() and if so populate this, then
>    call that as $repo->git_path_hooks.

I reworked this, but being a level 1 perl coder I don't quite grok the
"GetHooksPath => 1 to Git->repository()" part of your suggestion.

https://github.com/robertfoss/git/commit/9388d1f66b8d182f0dcc869f627736596af382da

This is what I came up with.

>
> 2. FWIW it's more idiomatic in perl to just do : chomp(my $x = y()); not
>    my $x = y(); chomp $x. The chomp operator works in-place, but once
>    you'd use the helpers in Git.pm for this they'd do all that for you.
>
> >               my $hook_error;
> >               if (-x $validate_hook) {
> >                       my $target = abs_path($fn);
>

Ack

      reply	other threads:[~2021-03-22 21:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 16:20 [PATCH v1] git-send-email: Respect core.hooksPath setting Robert Foss
2021-03-22 16:46 ` Ævar Arnfjörð Bjarmason
2021-03-22 21:13   ` Robert Foss [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAG3jFysGE-Wq2ReXmNa2VGPOWMW_MDn++Xv_WvAYW9EiQjAbdA@mail.gmail.com \
    --to=robert.foss@linaro.org \
    --cc=aquini@redhat.com \
    --cc=avarab@gmail.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sir@cmpwn.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 public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).