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

Provide a way to disable Git modules in slow network drives #5672

Open
kdarkhan opened this issue Dec 30, 2023 · 3 comments
Open

Provide a way to disable Git modules in slow network drives #5672

kdarkhan opened this issue Dec 30, 2023 · 3 comments
Labels
✨ enhancement A new feature implementation.

Comments

@kdarkhan
Copy link

Feature Request

Is your feature request related to a problem? Please describe.

I have an issue when using starship on a slow network drive with git modules (git_branch, git_state, etc) enabled.

Example path of a slow drive /mnt/slow/drive which does not contain any git repos.
I often cd into a deep nested directory like /mnt/slow/drive/some/nested/dir. With git modules
disabled, starship works pretty well but hangs when they are enabled.

Describe the solution you'd like

I want a way to conditionally disable git modules in specific directories.
As far as I can tell, there are 2 ways it can be accomplished:

  1. I submitted Remove reset of match_ceiling_dir_or_error in apply_environment() Byron/gitoxide#1191 to gitoxide which should allow starship conditionally enable the flag match_ceiling_dir_or_error = true. I propose creating a new global config in starship which enables the flag. Users who want this feature then will be able to define GIT_CEILING_DIRECTORIES={list of whitelisted git dirs} which does not include /mnt/slow/drive.

    With those configs, starship will not be walking up the dirs to detect repo roots when in non-whitelisted dirs. You can see some discussion on this approach in chore(context): explicitly avoid erroring on no git-ceiling-dir-match #5645

  2. Another approach is defining configs similar to detect_folders for all git modules as described in https://starship.rs/config/#negative-matching. The desired behaviour will not be exactly the same as detect_folders because those filters usually need at least a single positive match for the module to be enabled. What I need is some way to blacklist specific directories and if not blacklisted, continue with regular logic of walking up the parent dir. If using that approach the config will probably need to be renamed to something else to avoid confusion with detect_folders.

I am willing to contribute a PR for resolving this and opening this issue to start a discussion on the best approach.

@kdarkhan kdarkhan added the ✨ enhancement A new feature implementation. label Dec 30, 2023
@jankatins
Copy link
Contributor

Another option would be to make each module get enabled/disabled via an env variable (e.g. STARSHIP_CONFIG__GIT_STATUS__DISABLED=true) and you could set this via direnv or some other magic.

This pr implements such an idea, but it's currently stuck: #4439

@kdarkhan
Copy link
Author

Thanks for the pointers. Ideally I would like to have this feature implemented without external tools. I don't use direnv but might consider switching to it if the other PR is merged.

@jankatins
Copy link
Contributor

While i can strongly recommend direnv for project setups per dir, you can get the same effect with a "cd" function in your bashrc/zshrc which would first check on which dir you are and then either set or unset the end var and then call "builtin cd". Or if you are in zsh with a precmd function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement A new feature implementation.
Projects
None yet
Development

No branches or pull requests

2 participants