Thread (8 messages) flat view 8 messages, 4 authors, 2021-11-07

Re: [PATCH] gpg-interface: allow selecting key id with env variable

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-10-25 14:40:43

On Mon, Oct 25 2021, Fabian Stelzer wrote:
On 25.10.21 10:24, Marco Beck wrote:
quoted
On Mon, Oct 25, 2021 at 09:31:33AM +0200, Fabian Stelzer wrote:
quoted
[includeIf "gitdir:~/projects/work/"]
 path = ".gitconfig.work"
Yeah, that's what I added to my config recently just for signing key
selection. I'm using direnv[1] for some time now to switch between
different "profiles" (more than just Git settings) by just setting
some environment variables and it was nice to have everything in one
place. That's why I disliked adding the includeIf to my .gitconfig.

Thanks anyway,
Marco

[1] https://direnv.net/
If you insist on using environment variables there is:
GIT_CONFIG_KEY_<n>
GIT_CONFIG_VALUE_<n>

https://git-scm.com/docs/git-config

A bit clunky in my opinion but you can set any config variable via env vars:

e.g.:
GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.name GIT_CONFIG_VALUE_0=testing
Although to be fair that's quite clunky if you're setting N number of
these.

Marco: Would the "include by env" method discussed in the thread at
https://lore.kernel.org/git/patch-1.1-1fe6f60d2bf-20210924T005553Z-avarab@gmail.com (local)
be a better fit for what you're trying to do here, and eliminate the
need for you to have an env variable setting for this config key in
particular?

Anyway, aside from that I wonder if we shouldn't just have this env
variable anyway for consistency with the user.name, user.email
etc. equivalents, which we probaby wouldn't add today if they didn't
exist, but since we have them already...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help