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

stgit not finding user information #438

Open
immae opened this issue Apr 5, 2024 · 3 comments
Open

stgit not finding user information #438

immae opened this issue Apr 5, 2024 · 3 comments

Comments

@immae
Copy link

immae commented Apr 5, 2024

Hello,

I’m running stgit version 2.4.5 . Since a recent change in the way I’m handling my git config, stgit became unable to get my user.name and user.email information:

repo $ stg new                                                                                                                                                            
error: author identity unknown; please configure `user.name` and `user.email`.
repo $ git config --get user.email                                                                                                                                        
[email protected]
repo $ git config --get user.name
Immae

The change is as follows: my global git config used to have a [user] section.
Now I’m making use of a git feature to include conditional configuration:

[includeIf "hasconfig:remote.*.url:[email protected]:*/**"]
        path = ~/.config/git/perso.gitconfig
[includeIf "hasconfig:remote.*.url:[email protected]:*/**"]
        path = ~/.config/git/work.gitconfig

and the work.gitconfig / perso.gitconfig paths now contain the [user] section instead of the global git config.

This works just fine with normal git commands, but not with stgit. I suppose that stgit is doing a separate parsing of the git config file and misses that information. Is there any way to get that working?

Thanks in advance!

@jpgrayson
Copy link
Collaborator

StGit relies on gitoxide's gix-config library for parsing/interpreting git configuration. I successfully use [includeIf "gitdir:..."] in one of my environments, but have not used [includeIf "hasconfig:..."]. I suspect gix-config simply does not support hasconfig predicates yet.

A quick read of https://github.com/Byron/gitoxide/blob/main/gix-config/src/file/includes/types.rs#L122 seems to confirm that gitdir predicates are supported, but hasconfig is nowhere to be found.

@Byron: would love your thoughts on this.

@Byron
Copy link
Contributor

Byron commented Apr 9, 2024

Indeed, hasconfig isn't yet supported, and it's quite a special way of including files.

After thinking about it, I believe that it would perfectly lend itself to being resolved as part of this call, which already happens after most of the git configuration has been injected. Thus, it would work without any 'lookahead'. Of course, the devil is in the details here, but I am sure those can be figured out.

Since reading the git configuration faithfully is important to the correct functioning of any tool, I am prioritizing the implementation of hasconfig and will do so next time I get a chance. Thanks again for reeling me in - a thread like this is just what I need as motivation to implement it :).

PS: I have put it into this PR which is my catch-all that is merged from time to time, but also there to remind me what the big-picture goal is.

@immae
Copy link
Author

immae commented Apr 9, 2024

Thanks for your answers! Indeed "gitdir:..." syntax works and I can live with that (although not as concisely as hasconfig would do) until hasconfig gets supported.

I’d love to help but I’m not fluent enough with rust yet to do anything about it

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

3 participants