-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Remove reset of match_ceiling_dir_or_error
in apply_environment()
#1191
Conversation
In https://github.com/Byron/gitoxide/pull/721/files, this reset was added which makes using [ThreadSafeRepository::discover_with_environment_overrides_opts]( https://github.com/Byron/gitoxide/blob/f7adf97bc6aa2bf82f906c4463b1cbb3f9cddae3/gix/src/discover.rs#L67) inconvenient. If the old behaviour of `match_ceiling_dir_or_error = false` desired, then it can be achieved by setting it on `options` just before calling `apply_environment()`. The inverse is not true, and `ThreadSafeRepository::discover_with_environment_overrides_opts` cannot enable this flag because `apply_environment` overrides it.
87576ea
to
85499e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the fix of the fix :)! In hindsight I realise that hardcoding it there seems to be a mistake particularly since the value can be set by the user.
I have added a note in a separate commit that will be visible after merging, so here it is for posterity:
/// ### Note
///
/// Consider to setmatch_ceiling_dir_or_error = false
/// to allow discovery if an outside environment variable sets non-matching ceiling directories for greater
/// compatibility with Git.
@davidkna This change affects starship
and I think the following patch can be applied right now to be safe when this trickles through with the next gix
upgrade.
diff --git a/src/context.rs b/src/context.rs
index 56074469..57c6921a 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -319,7 +319,10 @@ impl<'a> Context<'a> {
let shared_repo =
match ThreadSafeRepository::discover_with_environment_overrides_opts(
&self.current_dir,
- Default::default(),
+ gix::discover::upwards::Options {
+ match_ceiling_dir_or_error: false,
+ ..Default::default()
+ },
git_open_opts_map,
) {
Ok(repo) => repo,
Please do let me know if you think there were other reasons for hardcoding the value like this that aren't accounted for with this change - to me it seems sound.
Awesome, thanks. Reason I arrived at this issue was from |
Oh, that's interesting! It seems then you will want to talk to @davidkna to see how it remains configurable instead of hardcoding the same in |
Right, I will reach out to him. I am planning to add a new config option in The reason I want to have the |
This note should help to avoid to keep enforcing flags in places where they can't be 'unenforced' anymore, even if it means that users have to be aware of some necessary manual adjustments.
See: Byron/gitoxide#1191 Co-Authored-By: Sebastian Thiel <sebastian.thiel@icloud.com>
See: Byron/gitoxide#1191 Co-Authored-By: Sebastian Thiel <sebastian.thiel@icloud.com>
* build(deps): update rust crate gix to 0.57.0 * chore(context): explicitly avoid erroring on no git-ceiling-dir-match See: Byron/gitoxide#1191 Co-Authored-By: Sebastian Thiel <sebastian.thiel@icloud.com> --------- Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
In #721, this reset was added which makes using
ThreadSafeRepository::discover_with_environment_overrides_opts inconvenient.
If the old behaviour of
match_ceiling_dir_or_error = false
desired, then it can be achieved bysetting it on
options
just before callingapply_environment()
.The inverse is not true, and
ThreadSafeRepository::discover_with_environment_overrides_opts
cannot enable this flag because
apply_environment
overrides it.I am not sure if this change is the best approach to accomplish what I need.
Let me know if you think it is better to change
discover_with_environment_overrides_opts
so that
options
parameter is used as override instead of default.