git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Ævar Arnfjörð Bjarmason  <avarab@gmail.com>
Cc: Philipp Gortan <philipp@gortan.org>,
	Git Mailing List <git@vger.kernel.org>,
	Philip Oakley <philipoakley@iee.org>
Subject: Re: git-gui ignores core.hooksPath
Date: Wed, 14 Jun 2017 15:15:55 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1.1706141457500.171564@virtualbox> (raw)
In-Reply-To: <CACBZZX6H4wxQ7hrO1Y1u6Qyr5gpK9GeCxpv-x2q3Eq2WCbkK8Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3563 bytes --]

Hi,

On Fri, 2 Jun 2017, Ævar Arnfjörð Bjarmason wrote:

> On Fri, Jun 2, 2017 at 3:41 PM, Philipp Gortan <philipp@gortan.org> wrote:
>
> > I've been unhappy for quite a while that I had to configure the hooks
> > manually for each of my repos - until I found out recently that there
> > is the core.hooksPath config variable that (when set globally) allows
> > me to specify a hooks directory to be used for all my repositories.
> >
> > Now I was happy - for a few minutes, until I tested this feature in
> > git-gui, and realized that it doesn't work there.
> >
> > This seems to be caused by "proc githook_read", which says "set pchook
> > [gitdir hooks $hook_name]" instead of querying "git config
> > core.hooksPath" first - cf
> > https://github.com/git/git/blob/2cc2e70264e0fcba04f9ef791d144bbc8b501206/git-gui/git-gui.sh#L627
> >
> > Would be great if this could get fixed...

Indeed. Why don't you give it a try?

> This indeed is something that should be fixed, but git-gui development
> is managed outside of git.git, it's just occasionally pulled in. I'm
> not what the best place to contact is, but I've CC'd
> Philip Oakley who's been making recent commits to git-gui.git at
> http://repo.or.cz/git-gui.git/

Philip is in the same spot as I am: we both worked on Git GUI to improve
it for Git for Windows users, but Pat has been silent for over half a year
on all of our PRs.

In the meantime, I managed to get a couple of changes into git.git via
Junio, but the situation is far from ideal.

So what I settled on is to carry a couple of Git GUI patches in Git for
Windows' fork, until the time when the patches finally get accepted into
https://github.com/patthoyts/git-gui.

In this particular instance, the only question is whether to use `git
rev-parse --git-path hooks` or re-roll the core.hookspath logic in
git-gui.

Both approaches have their downsides:

- rev-parse --git-path was broken in subdirectories for a *really* long
  time. Since Git GUI is supposed to be relatively independent from the
  version of the installed git executable, that would imply a couple of
  ugly extra code just to make sure that it works correctly.

- duplicating the core.hookspath logic is prone to become stale over time,
  as Git may change the behavior (as it did with the core.hookspath
  setting).

The subdirectory problem of --git-path is actually not that bad, as Git
GUI cd's to the top-level directory anyway. So that bug does not affect
us. The only caveat is that --git-path was only introduced into v2.5.0,
and Git GUI has conditional code to even support pre-1.6.3 versions.

Happily, pre-1.6.3 versions are not supposed to handle core.hookspath in
the way v2.9.0 and later handle it.

So something like this *may* work:

-- snip --
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 37c1c5d227b..3067a3b000a 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -624,7 +624,11 @@ proc git_write {args} {
 }
 
 proc githook_read {hook_name args} {
-	set pchook [gitdir hooks $hook_name]
+	if {[package vcompare $::_git_version 2.5.0] >= 0} {
+		set pchook [git rev-parse --git-path "hooks/$hook_name"]
+	} else {
+		set pchook [gitdir hooks $hook_name]
+	}
 	lappend args 2>@1
 
 	# On Windows [file executable] might lie so we need to ask
-- snap --

Philipp, this is as far as I will go with this. If you truly desire this
to be fixed, please take it from here (read: test, fix and submit with a
good commit message).

Ciao,
Johannes

  parent reply index

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 13:41 Philipp Gortan
2017-06-02 14:21 ` Samuel Lijin
2017-06-02 16:38 ` Ævar Arnfjörð Bjarmason
2017-06-02 20:23   ` [PATCH] respect core.hooksPath, falling back to .git/hooks Philipp Gortan
2017-06-02 20:39     ` Philipp Gortan
2017-06-14 13:24     ` Johannes Schindelin
2017-06-02 23:00   ` git-gui ignores core.hooksPath Philip Oakley
2017-06-02 23:21     ` Philipp Gortan
2017-06-14 13:15   ` Johannes Schindelin [this message]
2017-06-14 13:25     ` Philipp Gortan
2018-04-10 15:00       ` Chris Maes
2018-04-10 22:06         ` Johannes Schindelin
2018-04-10 22:50         ` Junio C Hamano
2018-04-10 23:31           ` Ævar Arnfjörð Bjarmason
2018-04-11  0:44             ` Junio C Hamano
2018-06-05  5:48           ` Bert Wesarg
2018-06-11 21:58             ` Stefan Beller
2018-06-12  6:09               ` Johannes Sixt
2018-07-10 12:08       ` Johannes Schindelin
2018-07-10 15:18         ` Philip Oakley
  -- strict thread matches above, loose matches on Subject: below --
2017-02-04 17:14 git-gui ignores core.hookspath matthias.serfling

Reply instructions:

You may reply publically 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=alpine.DEB.2.21.1.1706141457500.171564@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=philipoakley@iee.org \
    --cc=philipp@gortan.org \
    /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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox