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<()>
154154 if let Ok ( repo) = git2:: Repository :: discover ( config. cwd ( ) ) {
155155 let mut repo_opts = git2:: StatusOptions :: new ( ) ;
156156 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 ) ;
165158 for status in repo. statuses ( Some ( & mut repo_opts) ) ?. iter ( ) {
166159 if let Some ( path) = status. path ( ) {
167160 match status. status ( ) {
Original file line number Diff line number Diff line change @@ -772,7 +772,7 @@ commit the changes to these files:
772772}
773773
774774#[ cargo_test]
775- fn errors_on_empty_repo ( ) {
775+ fn errors_about_untracked_files ( ) {
776776 let mut git_project = project ( ) . at ( "foo" ) ;
777777 git_project = git_project. file ( "src/lib.rs" , "pub fn foo() {}" ) ;
778778 let p = git_project. build ( ) ;
@@ -782,10 +782,15 @@ fn errors_on_empty_repo() {
782782 . with_status ( 101 )
783783 . with_stderr (
784784 "\
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+
789794" ,
790795 )
791796 . run ( ) ;
You can’t perform that action at this time.
0 commit comments