fix(diffpkg): Fix scoping of DIFFOPTIONS when comparing split pkgs

`diff_pkgs` needs to use a local variable for its options, otherwise
they will accumulate for each package diffed.

Whem comparing split packages this lead to earlier mutated DIFFOPTIONS
containing too many labels which resulted in a failure.
This commit is contained in:
Jan Alexander Steffens (heftig) 2023-05-21 16:24:54 +02:00 committed by Levente Polyak
parent 1c399778f9
commit d759eadb50
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
1 changed files with 4 additions and 3 deletions

View File

@ -215,7 +215,8 @@ diff_pkgs() {
[[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}"
[[ -f $newpkg ]] || die "No such file: %s" "${newpkg}"
DIFFOPTIONS+=(--label "${oldpkg}" --label "${newpkg}")
local -a diffoptions
diffoptions=("${DIFFOPTIONS[@]}" --label "${oldpkg}" --label "${newpkg}")
if (( TARLIST )); then
tar_list "$oldpkg" > "$TMPDIR/old"
@ -236,7 +237,7 @@ diff_pkgs() {
# Resolve dynamic auto width one we know the content to diff
if [[ $DIFFWIDTH == --width=auto ]]; then
AUTOLENGTH=$(file_diff_columns "$TMPDIR/old" "$TMPDIR/new")
DIFFOPTIONS+=("--width=${AUTOLENGTH}")
diffoptions+=("--width=${AUTOLENGTH}")
fi
# Print a header for side-by-side view as it lacks labels
@ -244,7 +245,7 @@ diff_pkgs() {
printf -- "--- %s\n+++ %s\n" "${oldpkg}" "${newpkg}"
fi
diff "${DIFFOPTIONS[@]}" "$TMPDIR/old" "$TMPDIR/new"
diff "${diffoptions[@]}" "$TMPDIR/old" "$TMPDIR/new"
fi
if (( DIFFOSCOPE )); then