Re: [git-users] Post-checkout hook command line arguments

2022-09-22 Thread Konstantin Khomoutov
On Thu, Sep 22, 2022 at 12:38:16PM +0300, Konstantin Khomoutov wrote:

> > > .git/config:
> > >
> > > [filter "crypt"]
> > > clean = openssl enc -pbkdf2 -iter 1 -aes-256-cbc -in %f && 
> > > shred %f
> > > smudge = openssl enc -d -pbkdf2 -iter 1 -aes-256-cbc
> > > required
> > >
> > > .gitattributes
> > > *  filter=crypt
> [...]
> > But I still have a problem:
> > 
> > The clean filter seems to be run on git pull as well. Any ideas how to 
> > bypass this?
> > 
> 
> I can only provide an educated guess. `git pull` is basically `git fetch` plus
> `git merge` (or `git rebase` - depending on the command-line options).
[...]

...And by the way, do you really need a clean filter at all?
It's only needed to add new/modified files to Git.
>From the initial description of your task, it looked like your soultion is
for checking out already existing commits.

If so, you might try to get rid of this filter and use `git pull --ff-only`.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20220922094253.ohlhinb2ya7vlwak%40carbon.


Re: [git-users] Post-checkout hook command line arguments

2022-09-22 Thread Konstantin Khomoutov
On Wed, Sep 21, 2022 at 11:22:19PM -0700, Ronny Forberger wrote:

> > I solved it like this:
> >
> > .git/config:
> >
> > [filter "crypt"]
> > clean = openssl enc -pbkdf2 -iter 1 -aes-256-cbc -in %f && 
> > shred %f
> > smudge = openssl enc -d -pbkdf2 -iter 1 -aes-256-cbc
> > required
> >
> > .gitattributes
> > *  filter=crypt
[...]
> But I still have a problem:
> 
> The clean filter seems to be run on git pull as well. Any ideas how to 
> bypass this?
> 

I can only provide an educated guess. `git pull` is basically `git fetch` plus
`git merge` (or `git rebase` - depending on the command-line options).

Only `git merge` or `git rebase` want to look at the work tree, and they might
do so in order to detect whether it is "clean" in the sense it does not
contain any unstaged changes. When no smudge/clean trickery is involved, Git
might rely on the "stat" information obtained for the files in the woek tree:
if the modification time (and the size) of a file do not differ from those
recorded in the index, the file might be deemed to be unchanged; but if they
differ, Git has to go out of its way and calculate the hash sum of the
contents of the file in the work tree and compare it with the one recorded in
the index.
So, my guess is that when clean/smudge is involved, Git might be forced to
calculate the hash each time (or may be just after the first checkout?),
and that requires obtaining "clean" blobs which, in turn, requires running the
clean filter on them.

You could experiment with this hypothesis running various operations which
should logically require checking the work tree status while having
GIT_TRACE=1 in the environment - so see which commands get actually invoked.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20220922093816.ke7hsw756as77v4u%40carbon.


Re: [git-users] Post-checkout hook command line arguments

2022-09-22 Thread Ronny Forberger
But I still have a problem:

The clean filter seems to be run on git pull as well. Any ideas how to 
bypass this?

On Thursday, September 22, 2022 at 4:10:42 AM UTC+2 Ronny Forberger wrote:

> I solved it like this:
>
> .git/config:
>
> [filter "crypt"]
> clean = openssl enc -pbkdf2 -iter 1 -aes-256-cbc -in %f && 
> shred %f
> smudge = openssl enc -d -pbkdf2 -iter 1 -aes-256-cbc
> required
>
> .gitattributes
> *  filter=crypt
> On Monday, September 12, 2022 at 9:37:11 PM UTC+2 Ronny Forberger wrote:
>
>> OK, thanks, I will maybe give it a try.
>>
>> On Monday, September 12, 2022 at 6:25:41 PM UTC+2 Konstantin Khomoutov 
>> wrote:
>>
>>> On Mon, Sep 12, 2022 at 08:15:14AM -0700, Ronny Forberger wrote: 
>>>
>>> [...] 
>>> > I am trying to implement some encryption function with 
>>> ansible-vault 
>>> > into git hooks. 
>>> > For decryption, I need the list of files passed on the command 
>>> line 
>>> [...] 
>>> > I mean, I just want a list of files that are passed to the git 
>>> checkout 
>>> > command, not any related to the history of a file or its state. 
>>>
>>> OK, I think it's not possible. 
>>>
>>> But then I think you're trying to approach the problem from a wrong 
>>> side: 
>>> I think you need to use the so-called "attributes". Git attributes allow 
>>> setting up "clean" and "smudge" filters for files which are under the 
>>> control 
>>> of Git: the first type of filters allow to change the blobs as found in 
>>> the 
>>> work tree, and the second type of filters do the reverse - take a blob 
>>> as 
>>> recorded in a commit, and change it in whatever way required to update 
>>> the 
>>> matching file in the work tree. 
>>>
>>> IMO, using smudge filters for decoding files is what is really needed. 
>>>
>>> You can run `git help attributes` to learn about this feature. 
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/bc0050c3-c0fd-4677-9a59-de61ebbfa847n%40googlegroups.com.


Re: [git-users] Post-checkout hook command line arguments

2022-09-21 Thread Ronny Forberger
I solved it like this:

.git/config:

[filter "crypt"]
clean = openssl enc -pbkdf2 -iter 1 -aes-256-cbc -in %f && 
shred %f
smudge = openssl enc -d -pbkdf2 -iter 1 -aes-256-cbc
required

.gitattributes
*  filter=crypt
On Monday, September 12, 2022 at 9:37:11 PM UTC+2 Ronny Forberger wrote:

> OK, thanks, I will maybe give it a try.
>
> On Monday, September 12, 2022 at 6:25:41 PM UTC+2 Konstantin Khomoutov 
> wrote:
>
>> On Mon, Sep 12, 2022 at 08:15:14AM -0700, Ronny Forberger wrote:
>>
>> [...]
>> > I am trying to implement some encryption function with ansible-vault
>> > into git hooks.
>> > For decryption, I need the list of files passed on the command line 
>> [...]
>> > I mean, I just want a list of files that are passed to the git checkout 
>> > command, not any related to the history of a file or its state.
>>
>> OK, I think it's not possible.
>>
>> But then I think you're trying to approach the problem from a wrong side:
>> I think you need to use the so-called "attributes". Git attributes allow
>> setting up "clean" and "smudge" filters for files which are under the 
>> control
>> of Git: the first type of filters allow to change the blobs as found in 
>> the
>> work tree, and the second type of filters do the reverse - take a blob as
>> recorded in a commit, and change it in whatever way required to update the
>> matching file in the work tree.
>>
>> IMO, using smudge filters for decoding files is what is really needed.
>>
>> You can run `git help attributes` to learn about this feature.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/6dfd064e-b643-4aa0-adcb-b3a54599bc58n%40googlegroups.com.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread Ronny Forberger
OK, thanks, I will maybe give it a try.

On Monday, September 12, 2022 at 6:25:41 PM UTC+2 Konstantin Khomoutov 
wrote:

> On Mon, Sep 12, 2022 at 08:15:14AM -0700, Ronny Forberger wrote:
>
> [...]
> > I am trying to implement some encryption function with ansible-vault
> > into git hooks.
> > For decryption, I need the list of files passed on the command line 
> [...]
> > I mean, I just want a list of files that are passed to the git checkout 
> > command, not any related to the history of a file or its state.
>
> OK, I think it's not possible.
>
> But then I think you're trying to approach the problem from a wrong side:
> I think you need to use the so-called "attributes". Git attributes allow
> setting up "clean" and "smudge" filters for files which are under the 
> control
> of Git: the first type of filters allow to change the blobs as found in the
> work tree, and the second type of filters do the reverse - take a blob as
> recorded in a commit, and change it in whatever way required to update the
> matching file in the work tree.
>
> IMO, using smudge filters for decoding files is what is really needed.
>
> You can run `git help attributes` to learn about this feature.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/73e611f3-b9f8-43a6-b4bc-45a95f0c70fdn%40googlegroups.com.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread Konstantin Khomoutov
On Mon, Sep 12, 2022 at 08:15:14AM -0700, Ronny Forberger wrote:

[...]
> I am trying to implement some encryption function with ansible-vault
> into git hooks.
> For decryption, I need the list of files passed on the command line 
[...]
> I mean, I just want a list of files that are passed to the git checkout 
> command, not any related to the history of a file or its state.

OK, I think it's not possible.

But then I think you're trying to approach the problem from a wrong side:
I think you need to use the so-called "attributes". Git attributes allow
setting up "clean" and "smudge" filters for files which are under the control
of Git: the first type of filters allow to change the blobs as found in the
work tree, and the second type of filters do the reverse - take a blob as
recorded in a commit, and change it in whatever way required to update the
matching file in the work tree.

IMO, using smudge filters for decoding files is what is really needed.

You can run `git help attributes` to learn about this feature.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20220912162534.wzynu766q4sm2jtg%40carbon.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread DANNY ROY
Danny Roy 1225 st-Edgar
Drummondville Québec Canada 
j2B-2W4

Envoyé de mon iPhone

> Le 12 sept. 2022 à 11:15, Ronny Forberger  
> a écrit :
> 
> I mean, I just want a list of files that are passed to the git checkout 
> command, not any related to the history of a file or its state.
> 
>> On Monday, September 12, 2022 at 4:17:08 PM UTC+2 Konstantin Khomoutov wrote:
>> On Mon, Sep 12, 2022 at 06:42:15AM -0700, Ronny Forberger wrote: 
>> 
>> [...] 
>> > > > I am trying to implement some encryption function with ansible-vault 
>> > > > into git hooks. 
>> > > > For decryption, I need the list of files passed on the command line to 
>> > > > git checkout command. I am using the post-checkout hook here. 
>> > > > I didn't find this information on the Internet. 
>> > > > 
>> > > > My post-checkout hook currently looks like: 
>> > > > 
>> > > > #!/bin/bash 
>> > > > set -eo pipefail 
>> > > > FILES=... 
>> > > > for f in $FILES; do 
>> > > > ansible-vault decrypt $f 
>> > > > done 
>> > > > 
>> > > > How can I access the command line arguments passed to git checkout in 
>> > > > the post-checkout hook? 
>> > > 
>> > > You cannot, but are the three parameters parsed to this hook not enough? 
>> > > 
>> > No, the parameters ($@) that are provided to the hook are not enough for 
>> > me. 
>> 
>> Still, can you explain why exactly? 
>> This is needed to exclude the possibility we're dealing with an XY Problem 
>> here. 
>> I mean, the argument to the post-checkout hook identify the previous state, 
>> the new state, and allow to distinguish between checking out a ref (a branch 
>> or a tag or a commit) and checking out the state of a particular file. 
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to git-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/git-users/19a543bc-30c3-4f9e-89ee-7e3642266748n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/FB917968-A637-4E40-BA46-7AF3A68D58DA%40gmail.com.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread Ronny Forberger
I mean, I just want a list of files that are passed to the git checkout 
command, not any related to the history of a file or its state.

On Monday, September 12, 2022 at 4:17:08 PM UTC+2 Konstantin Khomoutov 
wrote:

> On Mon, Sep 12, 2022 at 06:42:15AM -0700, Ronny Forberger wrote:
>
> [...]
> > > > I am trying to implement some encryption function with ansible-vault
> > > > into git hooks.
> > > > For decryption, I need the list of files passed on the command line 
> to
> > > > git checkout command. I am using the post-checkout hook here.
> > > > I didn't find this information on the Internet.
> > > > 
> > > > My post-checkout hook currently looks like:
> > > > 
> > > > #!/bin/bash
> > > > set -eo pipefail
> > > > FILES=...
> > > > for f in $FILES; do
> > > > ansible-vault decrypt $f
> > > > done
> > > > 
> > > > How can I access the command line arguments passed to git checkout in
> > > > the post-checkout hook?
> > >
> > > You cannot, but are the three parameters parsed to this hook not 
> enough?
> > >
> > No, the parameters ($@) that are provided to the hook are not enough for 
> me.
>
> Still, can you explain why exactly?
> This is needed to exclude the possibility we're dealing with an XY Problem
> here.
> I mean, the argument to the post-checkout hook identify the previous state,
> the new state, and allow to distinguish between checking out a ref (a 
> branch
> or a tag or a commit) and checking out the state of a particular file.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/19a543bc-30c3-4f9e-89ee-7e3642266748n%40googlegroups.com.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread Konstantin Khomoutov
On Mon, Sep 12, 2022 at 06:42:15AM -0700, Ronny Forberger wrote:

[...]
> > > I am trying to implement some encryption function with ansible-vault
> > > into git hooks.
> > > For decryption, I need the list of files passed on the command line to
> > > git checkout command. I am using the post-checkout hook here.
> > > I didn't find this information on the Internet.
> > > 
> > > My post-checkout hook currently looks like:
> > > 
> > > #!/bin/bash
> > > set -eo pipefail
> > > FILES=...
> > > for f in $FILES; do
> > > ansible-vault decrypt $f
> > > done
> > > 
> > > How can I access the command line arguments passed to git checkout in
> > > the post-checkout hook?
> >
> > You cannot, but are the three parameters parsed to this hook not enough?
> >
> No, the parameters ($@) that are provided to the hook are not enough for me.

Still, can you explain why exactly?
This is needed to exclude the possibility we're dealing with an XY Problem
here.
I mean, the argument to the post-checkout hook identify the previous state,
the new state, and allow to distinguish between checking out a ref (a branch
or a tag or a commit) and checking out the state of a particular file.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20220912141701.3uekpifhs4eqf7ei%40carbon.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread Ronny Forberger
No, the parameters ($@) that are provided to the hook are not enough for me.

On Monday, September 12, 2022 at 3:06:33 PM UTC+2 Konstantin Khomoutov 
wrote:

> On Fri, Sep 09, 2022 at 07:56:56PM -0700, Ronny Forberger wrote:
>
> > I am trying to implement some encryption function with ansible-vault 
> into 
> > git hooks.
> > For decryption, I need the list of files passed on the command line to 
> git 
> > checkout command. I am using the post-checkout hook here.
> > I didn't find this information on the Internet.
> > 
> > My post-checkout hook currently looks like:
> > 
> > #!/bin/bash
> > set -eo pipefail
> > FILES=...
> > for f in $FILES; do
> > ansible-vault decrypt $f
> > done
> > 
> > How can I access the command line arguments passed to git checkout in 
> the 
> > post-checkout hook?
>
> You cannot, but are the three parameters parsed to this hook not enough?
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/ae1d6bae-8934-451e-9f9c-696fc741d4e6n%40googlegroups.com.


Re: [git-users] Post-checkout hook command line arguments

2022-09-12 Thread Konstantin Khomoutov
On Fri, Sep 09, 2022 at 07:56:56PM -0700, Ronny Forberger wrote:

> I am trying to implement some encryption function with ansible-vault into 
> git hooks.
> For decryption, I need the list of files passed on the command line to git 
> checkout command. I am using the post-checkout hook here.
> I didn't find this information on the Internet.
> 
> My post-checkout hook currently looks like:
> 
> #!/bin/bash
> set -eo pipefail
> FILES=...
> for f in $FILES; do
>   ansible-vault decrypt $f
> done
> 
> How can I access the command line arguments passed to git checkout in the 
> post-checkout hook?

You cannot, but are the three parameters parsed to this hook not enough?

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20220912130626.rls37aergr4hamtf%40carbon.


[git-users] Post-checkout hook command line arguments

2022-09-09 Thread Ronny Forberger
Hi,

I am trying to implement some encryption function with ansible-vault into 
git hooks.
For decryption, I need the list of files passed on the command line to git 
checkout command. I am using the post-checkout hook here.
I didn't find this information on the Internet.

My post-checkout hook currently looks like:

#!/bin/bash
set -eo pipefail
FILES=...
for f in $FILES; do
  ansible-vault decrypt $f
done

How can I access the command line arguments passed to git checkout in the 
post-checkout hook?

Thank you.

Best regards,
Ronny

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/39eb6f02-8b7e-4a2b-8bca-b55cccb3e22dn%40googlegroups.com.