diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index a4471d7b148..38bd75497a4 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -21,7 +21,7 @@ pub fn cli() -> Command { )) .arg(flag( "allow-dirty", - "Fix code even if the working directory is dirty", + "Fix code even if the working directory is dirty or has staged changes", )) .arg(flag( "allow-staged", @@ -86,6 +86,8 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { opts.filter = ops::CompileFilter::new_all_targets(); } + let allow_dirty = args.flag("allow-dirty"); + ops::fix( gctx, &ws, @@ -94,9 +96,9 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { edition: args.flag("edition"), idioms: args.flag("edition-idioms"), compile_opts: opts, - allow_dirty: args.flag("allow-dirty"), + allow_dirty, + allow_staged: allow_dirty || args.flag("allow-staged"), allow_no_vcs: args.flag("allow-no-vcs"), - allow_staged: args.flag("allow-staged"), broken_code: args.flag("broken-code"), requested_lockfile_path: lockfile_path, }, diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index 1530e77f48e..fdd2b33f1df 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -242,7 +242,7 @@ fn check_version_control(gctx: &GlobalContext, opts: &FixOptions) -> CargoResult bail!( "the working directory of this package has uncommitted changes, and \ `cargo fix` can potentially perform destructive changes; if you'd \ - like to suppress this error pass `--allow-dirty`, `--allow-staged`, \ + like to suppress this error pass `--allow-dirty`, \ or commit the changes to these files:\n\ \n\ {}\n\ diff --git a/src/doc/man/cargo-fix.md b/src/doc/man/cargo-fix.md index 2c25720db48..efb116d69a8 100644 --- a/src/doc/man/cargo-fix.md +++ b/src/doc/man/cargo-fix.md @@ -93,7 +93,7 @@ Fix code even if a VCS was not detected. {{/option}} {{#option "`--allow-dirty`" }} -Fix code even if the working directory has changes. +Fix code even if the working directory has changes (including staged changes). {{/option}} {{#option "`--allow-staged`" }} diff --git a/src/doc/man/generated_txt/cargo-fix.txt b/src/doc/man/generated_txt/cargo-fix.txt index 9b056183afa..f15544bfa29 100644 --- a/src/doc/man/generated_txt/cargo-fix.txt +++ b/src/doc/man/generated_txt/cargo-fix.txt @@ -84,7 +84,8 @@ OPTIONS Fix code even if a VCS was not detected. --allow-dirty - Fix code even if the working directory has changes. + Fix code even if the working directory has changes (including staged + changes). --allow-staged Fix code even if the working directory has staged changes. diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md index eefcd8a51b9..1a05599b488 100644 --- a/src/doc/src/commands/cargo-fix.md +++ b/src/doc/src/commands/cargo-fix.md @@ -89,7 +89,7 @@ edition.
--allow-dirty
-
Fix code even if the working directory has changes.
+
Fix code even if the working directory has changes (including staged changes).
--allow-staged
diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1 index b96c1e46ad1..f9896b8025a 100644 --- a/src/etc/man/cargo-fix.1 +++ b/src/etc/man/cargo-fix.1 @@ -103,7 +103,7 @@ Fix code even if a VCS was not detected. .sp \fB\-\-allow\-dirty\fR .RS 4 -Fix code even if the working directory has changes. +Fix code even if the working directory has changes (including staged changes). .RE .sp \fB\-\-allow\-staged\fR diff --git a/tests/testsuite/cargo_fix/help/stdout.term.svg b/tests/testsuite/cargo_fix/help/stdout.term.svg index 3268041f100..1c860989650 100644 --- a/tests/testsuite/cargo_fix/help/stdout.term.svg +++ b/tests/testsuite/cargo_fix/help/stdout.term.svg @@ -1,4 +1,4 @@ - +