pacdiff: Add a "backup" option for saving overwritten files
This might not be deemed worthwhile or useful to others, but it would be convenient for my workflow so I thought I'd propose it.
My typical workflow when resolving pacdiff
merges is to:
-
(V)iew
them, - Save the old version as
$file.bak
(ie:/etc/pacman.conf.bak
), - Resolve differences on
$file.pacnew
, - and
(O)verwrite
.
This allows me to hold onto the old version of the file in case there's a problem with the updates and I need to quickly revert.
Given that it's pretty simple to add that as an optional step to pacdiff
's logic, I propose a new optional flag be added (-b/--backup
or similar) to supply this functionality. If the flag is specified, then during the (O)verwrite
step the existing file will be renamed with an appended .bak
extension before the .pacnew
file is renamed to replace the existing file.
Usage would be something like the following:
$ pacdiff -b
==> pacnew file found for /etc/pacman.conf
:: (V)iew, (M)erge, (S)kip, (R)emove pacnew, (O)verwrite with pacnew, (Q)uit: [v/m/s/r/o/q] v
2 files to edit
:: (V)iew, (M)erge, (S)kip, (R)emove pacnew, (O)verwrite with pacnew, (Q)uit: [v/m/s/r/o/q] o
renamed '/etc/pacman.conf' -> '/etc/pacman.conf.bak'
renamed '/etc/pacman.conf.pacnew' -> '/etc/pacman.conf'
As I don't have permission to fork or create a Merge Request here, please find in the expandable block below a proposed patch to add this functionality to pacdiff
.