diffpkg: allow to choose between unified context and two columns
This commit is contained in:
parent
6bd7e70e68
commit
b9dadc5576
|
@ -47,6 +47,8 @@ _diffpkg_args=(
|
|||
'(-p --pkginfo)'{-p,--pkginfo}'[.PKGINFO diff mode]'
|
||||
'(-b --buildinfo)'{-b,--buildinfo}'[.BUILDINFO diff mode]'
|
||||
'(-m --makepkg-config)'{-m,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
|
||||
'(-u -U --unified)'{-u,-U,--unified}'[Output 3 lines of unified context]'
|
||||
'(-y --side-by-side)'{-y,--side-by-side}'[Output in two columns]'
|
||||
'(-v --verbose)'{-v,--verbose}'[Provide more detailed/unfiltered output]'
|
||||
'(-h --help)'{-h,--help}'[Display usage]'
|
||||
'*:packages:_devtools_completions_all_packages'
|
||||
|
|
|
@ -36,6 +36,15 @@ Options
|
|||
*-h, --help*::
|
||||
Show a help text
|
||||
|
||||
Output Options
|
||||
--------------
|
||||
|
||||
*-u, -U, --unified*::
|
||||
Output 3 lines of unified context
|
||||
|
||||
*-y, --side-by-side*::
|
||||
Output in two columns
|
||||
|
||||
Modes
|
||||
-----
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ usage() {
|
|||
-v, --verbose Provide more detailed/unfiltered output
|
||||
-h, --help Show this help text
|
||||
|
||||
OUTPUT OPTIONS
|
||||
-u, -U, --unified Output 3 lines of unified context
|
||||
-y, --side-by-side Output in two columns
|
||||
|
||||
MODES
|
||||
-l, --list Activate content list diff mode (default)
|
||||
-d, --diffoscope Activate diffoscope diff mode
|
||||
|
@ -42,6 +46,9 @@ DIFFOSCOPE=0
|
|||
PKGINFO=0
|
||||
BUILDINFO=0
|
||||
|
||||
DIFFMODE=--side-by-side
|
||||
DIFFOPTIONS=(--expand-tabs)
|
||||
|
||||
# option checking
|
||||
while (( $# )); do
|
||||
case $1 in
|
||||
|
@ -73,6 +80,14 @@ while (( $# )); do
|
|||
VERBOSE=1
|
||||
shift
|
||||
;;
|
||||
-u|-U|--unified)
|
||||
DIFFMODE=--unified
|
||||
shift
|
||||
;;
|
||||
-y|--side-by-side)
|
||||
DIFFMODE=--side-by-side
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
|
@ -86,6 +101,15 @@ while (( $# )); do
|
|||
esac
|
||||
done
|
||||
|
||||
if (( VERBOSE )); then
|
||||
if [[ $DIFFMODE == --unified ]]; then
|
||||
DIFFMODE="--unified=99999"
|
||||
fi
|
||||
else
|
||||
DIFFOPTIONS+=(--suppress-common-lines)
|
||||
fi
|
||||
DIFFOPTIONS+=("${DIFFMODE}")
|
||||
|
||||
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
|
||||
TARLIST=1
|
||||
fi
|
||||
|
@ -128,25 +152,27 @@ diff_pkgs() {
|
|||
[[ -f $oldpkg ]] || die "No such file: %s" "${oldpkg}"
|
||||
[[ -f $newpkg ]] || die "No such file: %s" "${newpkg}"
|
||||
|
||||
DIFFOPTIONS+=(--label "${oldpkg}" --label "${newpkg}")
|
||||
|
||||
if (( TARLIST )); then
|
||||
tar_list "$oldpkg" > "$TMPDIR/filelist-old"
|
||||
tar_list "$newpkg" > "$TMPDIR/filelist"
|
||||
|
||||
sdiff -s "$TMPDIR/filelist-old" "$TMPDIR/filelist"
|
||||
diff "${DIFFOPTIONS[@]}" "$TMPDIR/filelist-old" "$TMPDIR/filelist"
|
||||
fi
|
||||
|
||||
if (( PKGINFO )); then
|
||||
bsdtar xOqf "$oldpkg" .PKGINFO > "$TMPDIR/pkginfo-old"
|
||||
bsdtar xOqf "$newpkg" .PKGINFO > "$TMPDIR/pkginfo"
|
||||
|
||||
sdiff -s "$TMPDIR/pkginfo-old" "$TMPDIR/pkginfo"
|
||||
diff "${DIFFOPTIONS[@]}" "$TMPDIR/pkginfo-old" "$TMPDIR/pkginfo"
|
||||
fi
|
||||
|
||||
if (( BUILDINFO )); then
|
||||
bsdtar xOqf "$oldpkg" .BUILDINFO > "$TMPDIR/buildinfo-old"
|
||||
bsdtar xOqf "$newpkg" .BUILDINFO > "$TMPDIR/buildinfo"
|
||||
|
||||
sdiff -s "$TMPDIR/buildinfo-old" "$TMPDIR/buildinfo"
|
||||
diff "${DIFFOPTIONS[@]}" "$TMPDIR/buildinfo-old" "$TMPDIR/buildinfo"
|
||||
fi
|
||||
|
||||
if (( DIFFOSCOPE )); then
|
||||
|
|
Loading…
Reference in New Issue