File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,13 @@ pub fn untracked_files_config_repo(
56
56
}
57
57
}
58
58
59
+ // This does not reflect how git works according to its docs that say: "If this variable is not
60
+ // specified, it defaults to `normal`."
61
+ //
62
+ // https://git-scm.com/docs/git-config#Documentation/git-config.txt-statusshowUntrackedFiles
63
+ //
64
+ // Note that this might become less relevant over time as more code gets migrated to `gitoxide`
65
+ // because `gitoxide` respects `status.showUntrackedFiles` by default.
59
66
Ok ( ShowUntrackedFilesConfig :: All )
60
67
}
61
68
Original file line number Diff line number Diff line change @@ -159,24 +159,37 @@ pub fn is_workdir_clean(
159
159
Ok ( statuses. is_empty ( ) )
160
160
}
161
161
162
+ impl From < ShowUntrackedFilesConfig > for gix:: status:: UntrackedFiles {
163
+ fn from ( value : ShowUntrackedFilesConfig ) -> Self {
164
+ use gix:: status:: UntrackedFiles ;
165
+
166
+ match value {
167
+ ShowUntrackedFilesConfig :: All => UntrackedFiles :: Files ,
168
+ ShowUntrackedFilesConfig :: Normal => {
169
+ UntrackedFiles :: Collapsed
170
+ }
171
+ ShowUntrackedFilesConfig :: No => UntrackedFiles :: None ,
172
+ }
173
+ }
174
+ }
175
+
162
176
/// guarantees sorting
163
177
pub fn get_status (
164
178
repo_path : & RepoPath ,
165
179
status_type : StatusType ,
166
- _show_untracked : Option < ShowUntrackedFilesConfig > ,
180
+ show_untracked : Option < ShowUntrackedFilesConfig > ,
167
181
) -> Result < Vec < StatusItem > > {
168
182
scope_time ! ( "get_status" ) ;
169
183
170
- // TODO: take parameter `show_untracked` into account, trying to replicate the existing
171
- // behaviour.
172
-
173
184
let repo: gix:: Repository =
174
185
gix:: ThreadSafeRepository :: discover_with_environment_overrides ( repo_path. gitpath ( ) )
175
186
. map ( Into :: into) ?;
176
187
177
- let status = repo
178
- . status ( gix:: progress:: Discard ) ?
179
- . untracked_files ( gix:: status:: UntrackedFiles :: Files ) ;
188
+ let mut status = repo. status ( gix:: progress:: Discard ) ?;
189
+
190
+ if let Some ( config) = show_untracked {
191
+ status = status. untracked_files ( config. into ( ) ) ;
192
+ }
180
193
181
194
let mut res = Vec :: new ( ) ;
182
195
You can’t perform that action at this time.
0 commit comments