Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Brooke Kuhlmann <brooke@alchemists.io>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: Git 2.45.1 - What is the right way to clone with global hooks disabled?
Date: Thu, 16 May 2024 07:05:12 -0600	[thread overview]
Message-ID: <30AB54F7-DB53-40AC-BB43-1544A8128AB2@alchemists.io> (raw)
In-Reply-To: <5b3b0882-eb98-558b-3fd1-40cc4cec3ba0@gmx.de>

Hey Brian and Johannes, thanks for your feedback. 🙇🏻‍♂️

Brian, true, the Git LFS issues don't necessarily help me.

Johannes, yes, your patch would definitely be of great help to me. Thanks for doing that!


> On May 16, 2024, at 6:13 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 
> Hi Brooke,
> 
> On Wed, 15 May 2024, Brooke Kuhlmann wrote:
> 
>> With the release of Git 2.45.1, I can no longer do this when cloning
>> trusted repositories (my own) for build and deployment purposes:
>> 
>> git clone --config core.hooksPath=/dev/null https://github.com/bkuhlmann/infusible
> 
> Ah, that's a clever trick. The clone protections try to prevent overriding
> the `core.hooksPath` with a valid (but not intended by the user) path.
> What you are doing is to specifically turn hooks off *1*.
> 
> I plan on sending out a patch series later either today or tomorrow to
> address a couple of regressions introduced by v2.45.1, and this patch
> would address your specific scenario:
> 
> -- snip --
> diff --git a/config.c b/config.c
> index 85b37f2ee09..380f7777a6e 100644
> --- a/config.c
> +++ b/config.c
> @@ -1527,6 +1527,7 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
> 
> 	if (!strcmp(var, "core.hookspath")) {
> 		if (current_config_scope() == CONFIG_SCOPE_LOCAL &&
> +		    (!value || (*value && strcmp(value, "/dev/null"))) &&
> 		    git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0))
> 			die(_("active `core.hooksPath` found in the local "
> 			      "repository config:\n\t%s\nFor security "
> diff --git a/t/t1350-config-hooks-path.sh b/t/t1350-config-hooks-path.sh
> index f6dc83e2aab..1eae346a6e3 100755
> --- a/t/t1350-config-hooks-path.sh
> +++ b/t/t1350-config-hooks-path.sh
> @@ -41,4 +41,8 @@ test_expect_success 'git rev-parse --git-path hooks' '
> 	test .git/custom-hooks/abc = "$(cat actual)"
> '
> 
> +test_expect_success 'core.hooksPath=/dev/null' '
> +	git clone -c core.hooksPath=/dev/null . no-templates
> +'
> +
> test_done
> 
>> I have automation in place where I want my global Git Hooks to be
>> ignored when cloning like this. The solution is to do this:
>> 
>> GIT_CLONE_PROTECTION_ACTIVE=false git clone --config core.hooksPath=/dev/null https://github.com/bkuhlmann/infusible
>> 
>> ...but is there a better, more secure, way to clone a repository while
>> ignoring any global Git Hooks from firing without a lot of effort?
> 
> That is certainly a good work-around for now. Thank you for the report! I
> hope that we can address your use case in v2.45.2, hopefully soon.
> 
> Thanks,
> Johannes


  reply	other threads:[~2024-05-16 13:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 15:53 Git 2.45.1 - What is the right way to clone with global hooks disabled? Brooke Kuhlmann
2024-05-15 22:25 ` brian m. carlson
2024-05-16 14:59   ` Junio C Hamano
2024-05-16 12:13 ` Johannes Schindelin
2024-05-16 13:05   ` Brooke Kuhlmann [this message]
2024-05-16 14:56   ` Junio C Hamano
2024-05-17 13:08     ` Johannes Schindelin

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=30AB54F7-DB53-40AC-BB43-1544A8128AB2@alchemists.io \
    --to=brooke@alchemists.io \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    /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.
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).