git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Philipp Gortan <philipp@gortan.org>
Cc: philipoakley@iee.org, avarab@gmail.com, git@vger.kernel.org,
	matthias.serfling@googlemail.com
Subject: Re: [PATCH] respect core.hooksPath, falling back to .git/hooks
Date: Wed, 14 Jun 2017 15:24:02 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1.1706141516540.171564@virtualbox> (raw)
In-Reply-To: <20170602202301.6413-1-philipp@gortan.org>

Hi Philipp,

On Fri, 2 Jun 2017, Philipp Gortan wrote:

> Signed-off-by: Philipp Gortan <philipp@gortan.org>

I just saw this. I made sure that the thread to which I just replied did
not have any news from you, but you simply started a new thread ;-)

This commit message needs a little bit of love. Something along the lines:

	Since v2.9.0, Git knows about the config variable core.hookspath
	that allows overriding the path to the directory containing the
	Git hooks.

	Since v2.10.0, the `--git-path` option respects that config
	variable, too, so we may just as well use that command.

	For Git versions older than v2.5.0 (which was the first version to
	support the `--git-path` option for the `rev-parse` command), we
	simply fall back to the previous code.

(This assumes that you'll go with the approach I outlined in the other
thread, comparing the Git version to 2.5.0 and going with --git-path if
available.)

> ---
> 
> The following patch tries to fix git-gui to respect the core.hooksPath config
> variable, falling back to the old behavior.

That would also have been a decent commit message, if a bit short. But you
need to put this text before the `---` line, even before the
`Signed-off-by:` footer.

> diff --git a/git-gui.sh b/git-gui.sh
> index 5bc21b8..a5335b1 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -624,7 +624,10 @@ proc git_write {args} {
>  }
>  
>  proc githook_read {hook_name args} {
> -	set pchook [gitdir hooks $hook_name]
> +	if {[catch {set hooksdir [git config core.hooksPath]}]} {

Did you not mean [get_config core.hookspath] here, i.e. get_config and the
key all lower-case?

> +		set hooksdir [gitdir hooks]
> +	}
> +	set pchook [file join $hooksdir $hook_name]
>  	lappend args 2>@1
>  

The problem I see with that is, as I mentioned in the other thread, that
it duplicates the logic in config.c that may change at any stage.

Even worse: it is inconsistent with the way Git handles core.hooksPath, if
the installed `git` executable predates v2.9.0. Git GUI explicitly allows
for being used with a large range of Git versions.

In short: I think it would be better to go with the approach I outlined in
the other thread. I'll reproduce the patch (completely untested) here:

-- snipsnap --
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

  parent reply index

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 13:41 git-gui ignores core.hooksPath 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 [this message]
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
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

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.1706141516540.171564@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=matthias.serfling@googlemail.com \
    --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