Message ID | cover.1614858901.git.liu.denton@gmail.com |
---|---|
Headers | show |
Series | pacdiff: learn (M)erge mode | expand |
On March 4, 2021 6:55:44 AM EST, Denton Liu via pacman-contrib <pacman-contrib@lists.archlinux.org> wrote: > This series teaches pacdiff to perform 3-way merges on config files. > The > first two commits are small refactors to make final change more > readable. The final commit is what actually implements the meat of the > change. > > Changes since v1: > > * Add an example of $MERGEPROG usage > > * Always ask user if they'd like to use merge results (I've been > bitten > by the lack of this feature!) > > * Drop refactoring patch (it's been merged) > > Denton Liu (3): > pacdiff: Implement die() > pacdiff: Reduce repetition in input loop > pacdiff: Learn the (M)erge mode > > doc/pacdiff.8.txt | 9 ++++- > src/pacdiff.sh.in | 100 +++++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 96 insertions(+), 13 deletions(-) > > Range-diff against v1: > 1: 7c6223d < -: ------- pacdiff: Reindent awk script > 2: e377ae2 = 1: 4ddc2db pacdiff: Implement die() > 3: bdbe0b2 = 2: 0a53816 pacdiff: Reduce repetition in input loop > 4: cb73198 ! 3: ae12e25 pacdiff: Learn the (M)erge mode > @@ Commit message > given $MERGEPROG (`diff3 -m` by default). The base file is taken from > from the second-newest package in the cache. > > - > - ## Notes ## > - There are a few things I'd like some comments on: > - > - * Is there a better way of getting the base file? I assume that > - most people will run pacdiff right after an update but what if > - they run pacdiff after two or more updates? > - > - * How is the UI flow for the merge command? Do we want to let > - automerges write out without warning or do we want to do > - something else? > - > - * When displaying conflicts, I currently display a diff against > - the base and the merged version. Do we want to display a diff > - against the merged and the current version? > - > ## doc/pacdiff.8.txt ## > @@ doc/pacdiff.8.txt: Description > ----------- > @@ src/pacdiff.sh.in: Search Options: select one (default: > --pacmandb) > (default: /etc) > + MERGEPROG override the 3-way merge program: (default: > 'diff3 -m') > > - Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname > +-Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname > ++Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" > MERGEPROG="git merge-file -p" $myname > Example: $myname --output --locate > + > + EOF > @@ src/pacdiff.sh.in: print_existing_pacsave(){ > done > } > @@ src/pacdiff.sh.in: print_existing_pacsave(){ > + tar -xOf "$base_tar" "${file#/}" >"$base" > + if $mergeprog "$file" "$base" "$pacfile" >"$merged"; then > + msg2 "Merged without conflicts." > -+ else > -+ $diffprog "$file" "$merged" > -+ > -+ while :; do > -+ ask "Would you like to use the results of the merge? [y/n] " > -+ > -+ read c || return 1 > -+ case $c in > -+ y|Y) break ;; > -+ n|N) return 1 ;; > -+ *) msg2 "Invalid answer." ;; > -+ esac > -+ done > + fi > + > ++ $diffprog "$file" "$merged" > ++ > ++ while :; do > ++ ask "Would you like to use the results of the merge? [y/n] " > ++ > ++ read c || return 1 > ++ case $c in > ++ y|Y) break ;; > ++ n|N) return 1 ;; > ++ *) msg2 "Invalid answer." ;; > ++ esac > ++ done > ++ > + if ! cp -v "$merged" "$file"; then > + warning "Unable to write merged file to %s. Merged file is > preserved at %s" "$file" "$merged" > + return 1 Works great, thank you, pushed. -- Best, Daniel <https://danielcapella.com>