-
Notifications
You must be signed in to change notification settings - Fork 321
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
jjconfig.toml should be opened recursively from the current dir #616
Comments
I've meant to add support for repo-level and workspace-level configs , as well as system-level configs. I just haven't gotten around to it yet. That's what Git and Mercurial do anyway. What you're suggesting seems a little different in that it you could create a hierarchy of projects, so you might have this:
That's an interesting idea. Did you get that setup working with Git? It looks like it has support for |
Apparently the same question was just asked on the Git mailing list and on Git for Windows. |
This is just similar to how git finds its |
Yes, understood. If we add this feature, we'll have to remember to take both performance and security into account. It would mean that we're always walking up to the root directory, which is probably fine. It would also mean that we trust users who have write access to parent directories, which seems fine to me, but note that the Git-for-Windows devs considered that a security vulnerability. |
Seems like a valid concern on systems where random users can write anywhere. Probably windows build should disallow searching in the root directory (and if you think a bit, probably on other systems too - i do not see a useful case where .git should be created in the root directory at all, unless you try to version your entire files tree across all mounted filesystems). |
To clarify, the reason I thought it doesn't seem bad to trust files in parent directories is that I thought permissions are almost always set up so people who can write to the root directory can probably write to your system configs anyway. But maybe it's not unusual for users to have write access to |
FWIW, I was wanting the same (config for different email addresses per repo), but am totally fine with a non-recursive solution just like in git, like /.jj/config.toml. Could that part be implemented first? |
Yes, I think it's very likely that we'll add support for per-repo configs first. I'm not sure if I'll have time to prioritize it myself soon, but that depends on what we'll end up needing internally (because then I get to work on it during the week). |
Had a look through some of the code. There's a bit of a snag with the sequence of operations, that currently I think instead the sequence of events needs to be:
|
Thanks! I think what you propose makes sense. I think that was also my conclusion when I looked into it a bit a while ago. For step 2, we'll need to do some early parsing of the command line arguments, so we can resolve the Git had a recent security bug that they fixed (IIRC) by adding a config that's read before step 2 above (the config controls how the workspace root is resolved). I don't think we need to support early reading like that yet, but it might be good to keep in mind. We may also want to insert another level of configs later, namely for workspaces. It seems like it wouldn't be much that you'd want to configure per workspace, but it might be good to keep that, too, in mind. In particular, I think the repo-level config should live in By the way, I'm not sure that the The difference between @yuja (who's also spent a lot of time on VCS development), do you have any thoughts on any of the above? |
I think some early config object is needed at step 2 to resolve command aliases. I don't think aliases (and some other global options) need to be set in
IMO,
Mercurial stores https://www.mercurial-scm.org/repo/hg/file/6.3.1/mercurial/hg.py#l1489 |
That's a good argument for removing it from there. I guess we'll have the same problem if the canonical place is in
Interesting, that code doesn't even look familiar to me (but I am very forgetful). The
Yes, no need for it yet, just trying to keep it mind. |
Since per-repo config may contain CLI settings, it must be visible to CLI. Therefore, UserSettings::with_repo() -> RepoSettings isn't used, and its implementation is nullified by this commit. #616
Although For the recursive solution, perhaps jj could do what EditorConfig does to mitigate the security vulnerability: Recursion stops when an I would also be happy with the non-recursive Git-style solution, because that's what I do in Git: # ~/.gitconfig
[includeIf "gitdir/i:C:/src/personal/**"]
path = ~/.gitconfig.personal # ~/.gitconfig.personal
[user]
email = [email protected] In TOML, maybe that could use an array of tables? user.email = "[email protected]"
# read ~/.jjconfig.personal.toml for any repo under C:\src\personal\
[[include]]
path-regex = "^c:/src/personal/"
file = "~/.jjconfig.personal.toml"
# read ~/.jjconfig.work.toml for any repo under C:\src\work\
[[include]]
path-regex = "^c:/src/work/"
file = "~/.jjconfig.work.toml" Or, since this project seems to prefer dotted notation, it could be a table where the name is ignored: include.personal.path-regex = "^c:/src/personal/"
include.personal.file = "~/.jjconfig.personal.toml"
include.work.path-regex = "^c:/src/work/"
include.work.file = "~/.jjconfig.work.toml" Either syntax could allow for adding different criteria in the future, like how git has # always include ~/.jjconfig.local.toml if it exists
[[include]]
file = "~/.jjconfig.local.toml"
# include if the repo uses a git backing store
[[include]]
backing-store = "git"
file = "~/.jjconfig.git.toml" |
I like something like the git |
Just dropping an idea. In addition to [[scoped]]
scoped.path = "~/work"
user.email = "[email protected]"
[[scoped]]
scoped.path = "~/oss"
user.email = "[email protected]" |
This is one of the first things that I looked for when Per-repo config is a solution in the meantime but I'm an idiot and will often forget to set it up in newly cloned or created repos. |
fwiw I've implemented a generic tool called relconf (GitHub repo, crate on crates.io) that generates config based on the current The main caveat there is that relconf needs a separate config file and can only merge entire files, not insert and allow overrides at a later point in the same file like
Personally I don't like overriding my config like that anyway so it doesn't bother me. I realize it's just another workaround but for me it does the trick until jj eventually adds native support Here's the relconf config I use right now, the rest in documented in the relconf README: tools:
- name: jj
format: toml
rootconfig: ~/.jjconfig.toml
inject:
- env-name: JJ_CONFIG
path: ~/.config/jj/merged.toml
subconfigs:
- path: ~/.config/jj/always.toml
- path: ~/.config/jj/customer.toml
when:
- directory: ~/workspace/customer-gitlab
match-subdirectories: true |
Description
The email/user name configuration does not have to be global, there are several repos where I commit from different email addresses.
It would make sense to traverse directories up looking for a config file, before looking in the ~/.config/ etc.
Steps to Reproduce the Problem
The text was updated successfully, but these errors were encountered: