Skip to content

--allow-dirty to imply --allow-staged? #14176

Open

Description

Problem

cargo fix/clippy --fix don't modify git's staging area, so the requirement to specify --allow-staged if there are any staged files is very cautious. Technically the staged files are not stored directly in the working directory, and can't be overwritten by the fix commands.

OTOH "dirty" state is much more volatile, and potentially has file changes in the working directory that haven't been saved anywhere, and which could be irreversibly lost when files are modified. This makes --allow-dirty a much stronger option that implies the local state is unimportant and can be lost.

This makes use of --allow-dirty without --allow-staged a weird edge case. It says the local changes are unimportant and can be overwritten even if they're unrecoverable, except being extra cautious about existence of local changes that are safe, and won't be overwritten. It's like having a --force-overwrite flag, but requiring --allow-not-forced-non-overwrite flag too.

Proposed Solution

Having to add both --allow-dirty --allow-staged flags to the fix commands is verbose and a bit tedious to type. The extra --allow-staged flag could be avoided if the more destructive --allow-dirty also implied the lesser --allow-staged. Alternatively, maybe there could be a single option like --force/-f that implies both.

Notes

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-gitArea: anything dealing with gitC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-fixS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions