martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.15k stars 271 forks source link

FR: Allow inheriting user.name and user.email from Git #4048

Open sean-c-johnston opened 2 months ago

sean-c-johnston commented 2 months ago

Is your feature request related to a problem? Please describe. I have multiple git identities so that I can separate my personal and work GitHub accounts, managed using [includeIf] in git config, to load additional work/personal config files depending on the repo's path.

I would like to be able to accomplish this with jj as well, without relying on myself to remember to set up a per-repo config each time.

Describe the solution you'd like Provide an option in jj/config.toml which allows inheriting user name and email from git. e.g. user.inherit_from_git or similar.

I think this can be achieved using the git CLI: running git config user.name and git config user.email to let git resolve those values instead of implementing any logic to locate and handle .gitconfig files.

This could either:

These behaviours could even both be available - user.inherit_from_git = always or user.inherit_from_git = once for example.

Describe alternatives you've considered As mentioned, this could be handled in a per-repo configuration (but this is manual and error prone).

Additional context I think ultimately, adding more complex jj configuration options to allow similar setups is inevitable given that jj has its own backend which does not rely on git, but that seems like a lot more work.

In the meantime, this would allow users with multiple git identities to transition to jj much more easily.

jalil-salame commented 1 month ago

There should be no need to shell out to git config, gix-config should work well enough for this.

martinvonz commented 1 month ago

If we implement the continuous version of this, I think it should be implemented by copying the git config at the start of every command. The code that creates new commits should not have any git-specific logic.