summaryrefslogtreecommitdiffstats
path: root/quilt/previous.in
diff options
context:
space:
mode:
Diffstat (limited to 'quilt/previous.in')
-rw-r--r--quilt/previous.in70
1 files changed, 70 insertions, 0 deletions
diff --git a/quilt/previous.in b/quilt/previous.in
new file mode 100644
index 0000000..45d4ce8
--- /dev/null
+++ b/quilt/previous.in
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# See the COPYING and AUTHORS files for more details.
+
+# Read in library functions
+if [ "$(type -t patch_file_name)" != function ]
+then
+ if ! [ -r @LIB@/patchfns ]
+ then
+ echo "Cannot read library @LIB@/patchfns" >&2
+ exit 1
+ fi
+ . @LIB@/patchfns
+fi
+
+usage()
+{
+ echo "Usage: quilt previous [patch]"
+ if [ x$1 = x-h ]
+ then
+ cat <<EOF
+
+Print the name of the previous patch before the specified or topmost
+patch in the series file.
+
+EOF
+ exit 0
+ else
+ exit 1
+ fi
+}
+
+options=`getopt -o h -- "$@"`
+
+if [ $? -ne 0 ]
+then
+ usage
+fi
+
+eval set -- "$options"
+
+while true
+do
+ case "$1" in
+ -h)
+ usage -h ;;
+ --)
+ shift
+ break ;;
+ esac
+done
+
+if [ $# -gt 1 ]
+then
+ usage
+elif [ $# -eq 1 ]
+then
+ patch=$(stripit $1)
+else
+ patch=$(top_patch)
+fi
+
+if [ -n "$patch" ]
+then
+ patches_before $patch | tail -1
+fi