git-filter-repo
git-filter-repo copied to clipboard
Why `--force` flag instead of interactively confirming?
On "FRESH CLONE SAFETY CHECK AND --FORCE" section, the following is stated:
In short, it’s perfectly fine to use ‘--force` to override the safety checks as long as you’re okay with filter-repo irreversibly rewriting the contents of the current repository. It is a really bad idea to get in the habit of always specifying --force; if you do, one day you will run one of your commands in the wrong directory like I did, and you won’t have the safety check anymore to bail you out. Also, it is definitely NOT okay to recommend --force on forums, Q&A sites, or in emails to other users without first carefully explaining that --force means putting your repositories’ data at risk. I am especially bothered by people who suggest the flag when it clearly is NOT needed; they are needlessly putting other peoples' data at risk.
This (as the rest of the documentation and the program itself) is great, but it got me thinking: Why does this flag exist in the first place? Why not just display a message that explains what the tool will do and request a Y/N confirmation from the user? This way:
- People will not get into the habit of using
--force. - Nobody will be able to recommend it on forums.
since the flag won't exist in the first place.
You might say it is beneficial for scripting. I would still say that the flag is not needed. Anybody that wants to force it on a script can write an elaborate script that will detect the asking of this confirmation and pass Y to it. This way, this "workaround" wouldn't be recommended in forums either, since:
- It would be cumbersome.
- It is not needed in the first place. All the user needs to do is to interactively confirm or deny.
Or, the flag can be kept for scripting, but it can be a NO-OP when the command is being run interactively (not from a script), since the interactive Y/N confirmation will cover this case in interactive usage.