stgit not finding user information
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!
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.
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.
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