File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Expand file tree Collapse file tree 3 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,33 @@ 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
+ match value {
165
+ ShowUntrackedFilesConfig :: All => Self :: Files ,
166
+ ShowUntrackedFilesConfig :: Normal => Self :: Collapsed ,
167
+ ShowUntrackedFilesConfig :: No => Self :: None ,
168
+ }
169
+ }
170
+ }
171
+
162
172
/// guarantees sorting
163
173
pub fn get_status (
164
174
repo_path : & RepoPath ,
165
175
status_type : StatusType ,
166
- _show_untracked : Option < ShowUntrackedFilesConfig > ,
176
+ show_untracked : Option < ShowUntrackedFilesConfig > ,
167
177
) -> Result < Vec < StatusItem > > {
168
178
scope_time ! ( "get_status" ) ;
169
179
170
- // TODO: take parameter `show_untracked` into account, trying to replicate the existing
171
- // behaviour.
172
-
173
180
let repo: gix:: Repository =
174
181
gix:: ThreadSafeRepository :: discover_with_environment_overrides ( repo_path. gitpath ( ) )
175
182
. map ( Into :: into) ?;
176
183
177
- let status = repo
178
- . status ( gix:: progress:: Discard ) ?
179
- . untracked_files ( gix:: status:: UntrackedFiles :: Files ) ;
184
+ let mut status = repo. status ( gix:: progress:: Discard ) ?;
185
+
186
+ if let Some ( config) = show_untracked {
187
+ status = status. untracked_files ( config. into ( ) ) ;
188
+ }
180
189
181
190
let mut res = Vec :: new ( ) ;
182
191
Original file line number Diff line number Diff line change @@ -289,6 +289,8 @@ mod tests {
289
289
File :: create ( root. join ( Path :: new ( "a/f3.txt" ) ) ) ?
290
290
. write_all ( b"foo" ) ?;
291
291
292
+ repo. config ( ) ?. set_str ( "status.showUntrackedFiles" , "all" ) ?;
293
+
292
294
assert_eq ! ( status_count( StatusType :: WorkingDir ) , 3 ) ;
293
295
294
296
stage_add_all ( repo_path, "a/d" , None ) . unwrap ( ) ;
@@ -351,6 +353,8 @@ mod tests {
351
353
File :: create ( root. join ( Path :: new ( "f3.txt" ) ) ) ?
352
354
. write_all ( b"foo" ) ?;
353
355
356
+ repo. config ( ) ?. set_str ( "status.showUntrackedFiles" , "all" ) ?;
357
+
354
358
assert_eq ! ( get_statuses( repo_path) , ( 3 , 0 ) ) ;
355
359
356
360
repo. config ( ) ?. set_str ( "status.showUntrackedFiles" , "no" ) ?;
You can’t perform that action at this time.
0 commit comments