Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gert and git do not agree on what order to read the config #196

Open
zkamvar opened this issue Apr 6, 2023 · 1 comment
Open

gert and git do not agree on what order to read the config #196

zkamvar opened this issue Apr 6, 2023 · 1 comment

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Apr 6, 2023

It looks like {gert} prioritizes config items from top to bottom, but command line git prioritizes bottom to top in the case of duplicate keys.

I have a situation where I want to use a different set of credentials for a project. I found the IncludeIf directive for .gitconfig files from https://nicknisi.com/posts/git-includeif/ and I applied it like so:

[user]
    name="Clark"
    email=clark@email.com

[credential]
    helper=/path/to/helper

# ... gitconfig stuff ...

[includeIf "gitdir:/path/to/project"]
  path = ~/.gitconfig-pat

and in my ~/.gitconfig-pat I have it set up to use the GitHub credentials for "Bizarro" in which I provision a temporary PAT inside of an environmental variable called BIZARRO_TOKEN a la https://git-scm.com/docs/gitfaq#http-credentials-environment

[user]
    name="Bizarro"
    email=clark+bizarro@email.com

[credential]
    helper = '!f() {echo username=clark-is-not-bizarro && echo "password=${BIZARRO_TOKEN}"};f'

When I run git from /path/to/project in the command line, I can commit, push, and pull as "Bizarro", but if I open R and run {gert} from the same directory, I am recognized as "Clark".

If I move the IncludeIf statement to the top of the file, then {gert} will recognize "Bizarro", but git will recognise "Clark"

@jeroen
Copy link
Member

jeroen commented Apr 7, 2023

I think you need to ask this upstream in libgit2. We don't control any if this from gert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants