Open overhacked opened 3 years ago
https://gist.github.com/bdrewery/f36d2e6207ccc7aa7c0f6e3d0b891873 should fix it but I don't want to rush into passing it through. Need to think about what else it might impact.
If there is another git env var you can set to achieve this (that's not HOME
) you could export it from your poudriere.conf too.
Well, as of git 2.31 (unreleased), git will allow passing configuration options via environment variables (see also, on Stack Overflow). But that's pretty bleeding edge. 😐
Looking at ports.sh
, I think another workaround would be setting GIT_CMD
in poudriere.conf, too:
GIT_CMD='git -c credential.helper="store --file /root/.git-credentials"'
I haven't yet had a chance to test that, and the quoting is a bit weird because you would definitely have to pass the --file
option to git-credential-store because it uses HOME
to find .git-credentials
.
Tested. That syntax doesn't work. Still trying to figure out how to pass through a parameter that must have spaces.
Oof. It's ugly, but this works:
GIT_CMD='eval git -c credential.helper="store --file /root/.git-credentials"'
Here's another fun one. Since GIT_CMD
defaults to git
this should work too.
git() {
command git -c credential.helper="store --file /root/.git-credentials"
}
Turns out git already has an undocumented environment variable config:
export GIT_CONFIG_PARAMETERS=“‘credential.helper=store --file /root/.git-credentials’”
Prerequisites
Describe the bug
When Poudriere invokes a subcommand script,
HOME
is not one of the passed environment variables.git
's ability to read "global" config (~/.gitconfig
or$XDG_HOME/git/config
) breaks, because it relies on theHOME
environment variable rather than callinggetpwuid()
like openssh does.How to reproduce
git config --global credential.helper=store
git clone --depth-1 $REPO_URL
\ (you can pre-populate the url-encoded credentials in~/.git-credentials
, but running clone is the simplest way)git fetch -vv
from the cloned directory to prove that git doesn't ask for credentials again.poudriere ports -c -p credential_test -m git -U $REPO_URL
ports.sh
, it will ask for a username / password again even though they're already in~/.git-credentials
.Expected behavior
If
git config --global credential.helper=store
is set and there are valid credentials in~/.git-credentials
, actions to the same server should not prompt for credentials.Environment