Re: [PATCH v2] githooks: discuss Git operations in foreign repositories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 09, 2023 at 07:45:08PM +0000, Eric Sunshine via GitGitGadget wrote:

> Recommended best-practice[1,2,3,4,5,6] for avoiding this problem is for
> the hook to ensure that Git variables are unset before invoking Git
> commands in foreign repositories or other worktrees:
> 
>     unset $(git rev-parse --local-env-vars)
> 
> However, this advice is not documented anywhere. Rectify this
> shortcoming by mentioning it in githooks.txt documentation.
> 
> [1]: https://lore.kernel.org/git/YFuHd1MMlJAvtdzb@xxxxxxxxxxxxxxxxxxxxxxx/
> [2]: https://lore.kernel.org/git/20200228190218.GC1408759@xxxxxxxxxxxxxxxxxxxxxxx/
> [3]: https://lore.kernel.org/git/20190516221702.GA11784@xxxxxxxxxxxxxxxxxxxxx/
> [4]: https://lore.kernel.org/git/20190422162127.GC9680@xxxxxxxxxxxxxxxxxxxxx/
> [5]: https://lore.kernel.org/git/20180716183942.GB22298@xxxxxxxxxxxxxxxxxxxxx/
> [6]: https://lore.kernel.org/git/20150203163235.GA9325@xxxxxxxx/

Boy, I'm like a broken record.

The patch here looks good to me. The problem is wider than just hooks,
but it seems like that's going to be a common place for people to get
caught by it. So certainly this is going in the right direction.

The other place I've run into it is writing a script meant to be run as
an external command. E.g., running this:

  git --git-dir=/some/path my-external-command

means that "my-external-command" is going to have $GIT_DIR set. If it
wants to operate on another repository it needs to take care to clear
that from the environment.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux