From ea8b95f4df8a6b06aa393acd907f6400785661ff Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Tue, 10 Dec 2024 14:24:08 -0500 Subject: [PATCH 1/2] fix!: symlinks_to_directories_are_ignored_like_directories by value The methods of `gix::dirwalk::Options` are paired, where for each option `X` of `Options`, a method named like `X` takes and returns `self` by value, and a method `set_X` takes and returns `self` by mutable reference. But in `symlinks_to_directories_are_ignored_like_directories`, both took `self` by mutable reference. This fixes that. The effect of this fix is to allow building `Options` with a call to that method as the last factory method call (and using it where `Options` is accepted but `&mut Options` is not). Most code that consumes the crate should be unaffected, but: - Code where calls were ordered unnaturally to avoid putting such a call last should be able to be improved. - Code that used the method like its `set_*` countepart `set_symlinks_to_directories_are_ignored_like_directories` will be broken. That's what makes this fix a breaking change. Any such code can be fixed by modifying it to call the `set_*` version instead, which is probably what would have been intended anyway. --- gix/src/dirwalk/options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gix/src/dirwalk/options.rs b/gix/src/dirwalk/options.rs index dffb09a1972..71a0511f2b8 100644 --- a/gix/src/dirwalk/options.rs +++ b/gix/src/dirwalk/options.rs @@ -173,7 +173,7 @@ impl Options { /// if `true` it will be excluded as the symlink is considered a directory. /// /// In other words, for Git compatibility this flag should be `false`, the default, for `git2` compatibility it should be `true`. - pub fn symlinks_to_directories_are_ignored_like_directories(&mut self, toggle: bool) -> &mut Self { + pub fn symlinks_to_directories_are_ignored_like_directories(mut self, toggle: bool) -> Self { self.symlinks_to_directories_are_ignored_like_directories = toggle; self } From c0f4da5ef4791370c98f34f0eb3bb5773edbba32 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Tue, 10 Dec 2024 14:39:57 -0500 Subject: [PATCH 2/2] change: Adjust gix::dirwalk::Options::{X,set_X} parameter names This adjusts the names of parameters to `X` and `set_X` methods of `gix::dirwalk::Options` (where `X` is an option name) to use a systematic naming convention: - For the same option `X`, the `X` and `set_X` methods now always have the same name of the parameter that specifies a value for an option. - Options whose type is `bool` are named `toggle`, in keeping with the prevailing convention in this code. - Options of `Option` type are named `value` (this required no changes). - Options of a non-`Option` type `*Mode` -- currently this is just `EmissionMode` -- are named `mode`. --- gix/src/dirwalk/options.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gix/src/dirwalk/options.rs b/gix/src/dirwalk/options.rs index 71a0511f2b8..c72dc157148 100644 --- a/gix/src/dirwalk/options.rs +++ b/gix/src/dirwalk/options.rs @@ -115,13 +115,13 @@ impl Options { self } /// Controls the way untracked files are emitted. By default, this is happening immediately and without any simplification. - pub fn emit_untracked(mut self, toggle: EmissionMode) -> Self { - self.emit_untracked = toggle; + pub fn emit_untracked(mut self, mode: EmissionMode) -> Self { + self.emit_untracked = mode; self } /// Like [`emit_untracked()`](Self::emit_untracked), but only requires a mutably borrowed instance. - pub fn set_emit_untracked(&mut self, toggle: EmissionMode) -> &mut Self { - self.emit_untracked = toggle; + pub fn set_emit_untracked(&mut self, mode: EmissionMode) -> &mut Self { + self.emit_untracked = mode; self } /// If `toggle` is `true`, emit empty directories as well. Note that a directory also counts as empty if it has any @@ -180,8 +180,8 @@ impl Options { /// Like [`symlinks_to_directories_are_ignored_like_directories()`](Self::symlinks_to_directories_are_ignored_like_directories), /// but only requires a mutably borrowed instance. - pub fn set_symlinks_to_directories_are_ignored_like_directories(&mut self, value: bool) -> &mut Self { - self.symlinks_to_directories_are_ignored_like_directories = value; + pub fn set_symlinks_to_directories_are_ignored_like_directories(&mut self, toggle: bool) -> &mut Self { + self.symlinks_to_directories_are_ignored_like_directories = toggle; self } }