File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -154,14 +154,7 @@ fn check_version_control(config: &Config, opts: &FixOptions) -> CargoResult<()>
154
154
if let Ok ( repo) = git2:: Repository :: discover ( config. cwd ( ) ) {
155
155
let mut repo_opts = git2:: StatusOptions :: new ( ) ;
156
156
repo_opts. include_ignored ( false ) ;
157
- if repo. is_empty ( ) ? && !opts. allow_dirty {
158
- bail ! (
159
- "no commits found in the git repository, and \
160
- `cargo fix` can potentially perform destructive changes; if you'd \
161
- like to suppress this error pass `--allow-dirty`, \
162
- or commit your changes"
163
- )
164
- }
157
+ repo_opts. include_untracked ( true ) ;
165
158
for status in repo. statuses ( Some ( & mut repo_opts) ) ?. iter ( ) {
166
159
if let Some ( path) = status. path ( ) {
167
160
match status. status ( ) {
Original file line number Diff line number Diff line change @@ -772,7 +772,7 @@ commit the changes to these files:
772
772
}
773
773
774
774
#[ cargo_test]
775
- fn errors_on_empty_repo ( ) {
775
+ fn errors_about_untracked_files ( ) {
776
776
let mut git_project = project ( ) . at ( "foo" ) ;
777
777
git_project = git_project. file ( "src/lib.rs" , "pub fn foo() {}" ) ;
778
778
let p = git_project. build ( ) ;
@@ -782,10 +782,15 @@ fn errors_on_empty_repo() {
782
782
. with_status ( 101 )
783
783
. with_stderr (
784
784
"\
785
- error: no commits found in the git repository, \
786
- and `cargo fix` can potentially perform destructive changes; \
787
- if you'd like to suppress this error pass `--allow-dirty`, \
788
- or commit your changes
785
+ error: the working directory of this package has uncommitted changes, \
786
+ and `cargo fix` can potentially perform destructive changes; if you'd \
787
+ like to suppress this error pass `--allow-dirty`, `--allow-staged`, or \
788
+ commit the changes to these files:
789
+
790
+ * Cargo.toml (dirty)
791
+ * src/ (dirty)
792
+
793
+
789
794
" ,
790
795
)
791
796
. run ( ) ;
You can’t perform that action at this time.
0 commit comments