summaryrefslogtreecommitdiffstats
path: root/inpatch.in
diff options
context:
space:
mode:
authorMartin Quinson <mquinson@debian.org>2003-01-21 09:38:50 +0000
committerMartin Quinson <mquinson@debian.org>2003-01-21 09:38:50 +0000
commit4d11e99bfc25e0261111d202a3a2afdf97daea5c (patch)
treee19e6147fa2a6b0e5039c46acf25fb3846eaf7be /inpatch.in
downloadquilt-4d11e99bfc25e0261111d202a3a2afdf97daea5c.tar.gz
Initial revision
Diffstat (limited to 'inpatch.in')
-rwxr-xr-xinpatch.in137
1 files changed, 137 insertions, 0 deletions
diff --git a/inpatch.in b/inpatch.in
new file mode 100755
index 0000000..9bd3058
--- /dev/null
+++ b/inpatch.in
@@ -0,0 +1,137 @@
+#!/bin/sh
+
+# Read in library functions
+if ! [ -r @LIB@/patchfns ]
+then
+ echo "Cannot read library @LIB@/patchfns" >&2
+ exit 1
+fi
+. @LIB@/patchfns
+
+usage()
+{
+ echo "Usage: inpatch [patchname]"
+ echo " inpatch -f filename"
+ if [ x$1 = x-h ]
+ then
+ cat <<EOF
+
+Print the list of files that the topmost or specified patch
+changes.
+
+-f Print which patches change the specified file.
+
+EOF
+ exit 0
+ else
+ exit 1
+ fi
+}
+
+options=`getopt -o f:h -- "$@"`
+
+if [ $? -ne 0 ]
+then
+ usage
+fi
+
+eval set -- "$options"
+
+while true
+do
+ case "$1" in
+ -f)
+ opt_file=$2
+ shift 2 ;;
+ -h)
+ usage -h ;;
+ --)
+ shift
+ break ;;
+ esac
+done
+
+if [ $# -gt 1 ]
+then
+ usage
+fi
+opt_patch=$1
+
+scan_patches()
+{
+ local patches=$* patch
+ for patch in $patches
+ do
+ refresh_file_list $patch
+ status=$?
+ if [ $status -eq 2 ]
+ then
+ if [ -z "$opt_quiet" ]
+ then
+ echo "Recreated file list for $patch" >&2
+ fi
+ elif [ $status -ne 0 ]
+ then
+ echo "Could not create file list for patch $patch" >&2
+ return 1
+ fi
+ done
+
+ grep -l -e "^$(quote_re $opt_file)\$" $(pc_file_name $patches) \
+ | sed -e 's:^\.pc/::' -e 's:/\.pc$::'
+}
+
+if [ -n "$opt_patch" ]
+then
+ patch=$(stripit "$opt_patch")
+else
+ patch=$(top_patch)
+ if [ -z "$patch" ]
+ then
+ echo "No patches applied" >&2
+ exit 1
+ fi
+fi
+
+if [ -z "$opt_file" ]
+then
+ if ! is_applied $patch
+ then
+ if ! patch_in_series
+ then
+ echo "Patch $patch not in series file" >&2
+ else
+ echo "Patch is not applied (no old/new status)" >&2
+ no_status=1
+ fi
+ fi
+
+ for file in $(files_in_patch $patch)
+ do
+ if [ -n "$no_status" -o -s $(backup_file_name $patch $file) ]
+ then
+ echo "$file"
+ else
+ echo "$file (new)"
+ fi
+ done
+else
+ #if [ -n "$opt_patch" ]
+ #then
+ # scan_patches $(patches_before $opt_patch) | sed -e 's/^/> /'
+ # scan_patches $opt_patch | sed -e 's/^/| /'
+ # scan_patches $(patches_after $opt_patch) | sed -e 's/^/< /'
+ #else
+ # series=$(cat_series)
+ # if [ -n "$series" ]
+ # then
+ # scan_patches $series | sed -e 's/^/< /'
+ # fi
+ #fi
+ series=$(cat_series)
+ if [ -n "$series" ]
+ then
+ scan_patches $series
+ #| sed -e 's/^'"$(quote_re $patch)"'$/\0 (here)/'
+ fi
+fi