summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2021-06-10 17:14:19 +0200
committerJean Delvare <jdelvare@suse.de>2021-06-10 17:14:19 +0200
commitc539338458e4aa8b2d6c4c87b9192def3800d0b5 (patch)
treee403af8feb8b41061e1457379c31c7b11bfba4c2
parentca85fbd8202219737e14aaaff17d1c479536831f (diff)
downloadquilt-c539338458e4aa8b2d6c4c87b9192def3800d0b5.tar.gz
Delay sourcing patchfns until options have been processed
Commit 8b39a960afcf ("Consistently complain early if no series file is found") unexpectedly broke commands like "quilt add -h", because the check for a series file happens before the command line options are processed. This, in turn, breaks the generation of the quilt manual page, which relies on the output of each command when called with option -h. Reorder the code so that options are always processed first, and then patchfns is sourced. That way, option "-h" will work again even if not in a quilt working tree. Fixes: 8b39a960afcf ("Consistently complain early if no series file is found") Signed-off-by: Jean Delvare <jdelvare@suse.de>
-rw-r--r--quilt/add.in16
-rw-r--r--quilt/annotate.in17
-rw-r--r--quilt/applied.in16
-rw-r--r--quilt/delete.in16
-rw-r--r--quilt/diff.in32
-rw-r--r--quilt/edit.in16
-rw-r--r--quilt/files.in23
-rw-r--r--quilt/fold.in16
-rw-r--r--quilt/fork.in16
-rw-r--r--quilt/graph.in16
-rw-r--r--quilt/grep.in16
-rw-r--r--quilt/header.in16
-rw-r--r--quilt/import.in19
-rw-r--r--quilt/mail.in16
-rw-r--r--quilt/new.in16
-rw-r--r--quilt/next.in16
-rw-r--r--quilt/patches.in17
-rw-r--r--quilt/pop.in16
-rw-r--r--quilt/previous.in16
-rw-r--r--quilt/push.in20
-rw-r--r--quilt/refresh.in16
-rw-r--r--quilt/remove.in16
-rw-r--r--quilt/rename.in16
-rw-r--r--quilt/revert.in16
-rw-r--r--quilt/series.in16
-rw-r--r--quilt/setup.in38
-rw-r--r--quilt/snapshot.in16
-rw-r--r--quilt/top.in16
-rw-r--r--quilt/unapplied.in20
-rw-r--r--quilt/upgrade.in16
-rw-r--r--test/help.test91
31 files changed, 365 insertions, 264 deletions
diff --git a/quilt/add.in b/quilt/add.in
index 40e337a..16c822d 100644
--- a/quilt/add.in
+++ b/quilt/add.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt add [-P patch] {file} ...\n"
@@ -85,6 +77,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_applied_patch "$opt_patch") || exit 1
status=0
diff --git a/quilt/annotate.in b/quilt/annotate.in
index 6928f62..0b8c122 100644
--- a/quilt/annotate.in
+++ b/quilt/annotate.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt annotate [-P patch] {file}\n"
@@ -109,6 +101,15 @@ if [ $# -ne 1 ]
then
usage
fi
+
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
opt_file="$SUBDIR$1"
opt_patch=$(find_applied_patch "$opt_patch") || exit 1
diff --git a/quilt/applied.in b/quilt/applied.in
index 01a1745..2036441 100644
--- a/quilt/applied.in
+++ b/quilt/applied.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt applied [patch]\n"
@@ -54,6 +46,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_applied_patch "$1") || exit 1
setup_pager
diff --git a/quilt/delete.in b/quilt/delete.in
index 41ed0a3..5fad9e0 100644
--- a/quilt/delete.in
+++ b/quilt/delete.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt delete [-r] [--backup] [patch|-n]\n"
@@ -74,6 +66,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
if [ -n "$1" ]; then
patch=$(find_patch "$1") || exit 1
else
diff --git a/quilt/diff.in b/quilt/diff.in
index 72c2abe..e90dc33 100644
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -6,16 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
-setup_colors
-
usage()
{
printf $"Usage: quilt diff [-p n|-p ab] [-u|-U num|-c|-C num] [--combine patch|-z] [-R] [-P patch] [--snapshot] [--diff=utility] [--no-timestamps] [--no-index] [--sort] [--color[=always|auto|never]] [file ...]\n"
@@ -156,12 +146,7 @@ do
shift 2 ;;
--combine)
opt_combine=1
- if [ "$2" = - ]
- then
- first_patch=-
- else
- first_patch=$(find_applied_patch "$2") || exit 1
- fi
+ first_patch=$2
shift 2 ;;
-R)
opt_reverse=1
@@ -212,6 +197,21 @@ do
esac
done
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
+setup_colors
+
+if [ -n "$first_patch" -a "$first_patch" != - ]
+then
+ first_patch=$(find_applied_patch "$first_patch") || exit 1
+fi
+
QUILT_DIFF_OPTS="$QUILT_DIFF_OPTS $opt_format"
opt_files=( $(for file in "$@"; do echo "$SUBDIR${file#./}" ; done) )
diff --git a/quilt/edit.in b/quilt/edit.in
index 2d8e562..d36d327 100644
--- a/quilt/edit.in
+++ b/quilt/edit.in
@@ -8,14 +8,6 @@
: ${EDITOR:=vi}
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt edit file ...\n"
@@ -56,6 +48,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
quilt_command add "$@"
status=$?
if [ $status -ne 0 -a $status -ne 2 ]
diff --git a/quilt/files.in b/quilt/files.in
index 4349422..9d6a6d5 100644
--- a/quilt/files.in
+++ b/quilt/files.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt files [-v] [-a] [-l] [--combine patch] [patch]\n"
@@ -69,7 +61,7 @@ do
then
:
else
- first_patch=$(find_patch_in_series "$2") || exit 1
+ first_patch=$2
fi
shift 2 ;;
--)
@@ -83,6 +75,19 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
+if [ -n "$first_patch" ]
+then
+ first_patch=$(find_patch_in_series "$first_patch") || exit 1
+fi
+
last_patch=$(find_patch_in_series "$1") || exit 1
if [ -n "$opt_all" -a -z "$first_patch" ]
diff --git a/quilt/fold.in b/quilt/fold.in
index 6bca58f..1f664ca 100644
--- a/quilt/fold.in
+++ b/quilt/fold.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt fold [-R] [-q] [-f] [-p strip-level]\n"
@@ -80,6 +72,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
: ${opt_strip_level:=1}
[ -n "$opt_quiet" ] && patch_args="$patch_args -s"
[ -z "$opt_force" -o -n "$opt_quiet" ] && patch_args="$patch_args -f"
diff --git a/quilt/fork.in b/quilt/fork.in
index 4b0b6af..49d588a 100644
--- a/quilt/fork.in
+++ b/quilt/fork.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt fork [new_name]\n"
@@ -63,6 +55,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
top_patch=$(find_top_patch) || exit 1
if [ $# -eq 1 ]
diff --git a/quilt/graph.in b/quilt/graph.in
index e56be48..1854238 100644
--- a/quilt/graph.in
+++ b/quilt/graph.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt graph [--all] [--reduce] [--lines[=num]] [--edge-labels=files] [-T ps] [patch]\n"
@@ -106,6 +98,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
[ "$opt_format" = "ps" ] && check_external_tool dot graphviz -T
[ -n "$opt_reduce" ] && check_external_tool tred graphviz --reduce
diff --git a/quilt/grep.in b/quilt/grep.in
index e246c3d..020c354 100644
--- a/quilt/grep.in
+++ b/quilt/grep.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt grep [-h|options] {pattern}\n"
@@ -114,6 +106,14 @@ fi
# may pass a single filename to grep and cause it to omit the file name.
[ -z "$opt_h" ] && opt_H=-H
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
find "${myargs[@]:-.}" \( \
-path "./$QUILT_PATCHES/*" -o \
-path "./$QUILT_PC/*" \) -prune -o \
diff --git a/quilt/header.in b/quilt/header.in
index 2528022..b4c7867 100644
--- a/quilt/header.in
+++ b/quilt/header.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
: ${EDITOR:=vi}
usage()
@@ -114,6 +106,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_patch_in_series "$1") || exit 1
patch_file=$(patch_file_name $patch)
diff --git a/quilt/import.in b/quilt/import.in
index 209ed30..3f6df20 100644
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -9,14 +9,6 @@
# One of the few commands which does not need a series file
skip_series_check=1
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt import [-p num] [-R] [-P patch] [-f] [-d {o|a|n}] patchfile ...\n"
@@ -134,7 +126,7 @@ while true
do
case "$1" in
-P)
- opt_patch=${2#$QUILT_PATCHES/}
+ opt_patch=$2
shift 2 ;;
-p)
opt_strip=$2
@@ -165,6 +157,15 @@ then
exit 1
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
+[ -n "$opt_patch"] && opt_patch=${opt_patch#$QUILT_PATCHES/}
[ -n "$opt_strip" ] && patch_args="-p$opt_strip"
if [ -n "$opt_reverse" ]
then
diff --git a/quilt/mail.in b/quilt/mail.in
index b2cbe5a..592bee8 100644
--- a/quilt/mail.in
+++ b/quilt/mail.in
@@ -8,14 +8,6 @@
: ${EDITOR:=vi}
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt mail {--mbox file|--send} [-m text] [-M file] [--prefix prefix] [--sender ...] [--from ...] [--to ...] [--cc ...] [--bcc ...] [--subject ...] [--reply-to message] [--charset ...] [--signature file] [first_patch [last_patch]]\n"
@@ -270,6 +262,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
if [ $# -ge 1 ]
then
if [ "$1" = - ]
diff --git a/quilt/new.in b/quilt/new.in
index 3cc07eb..4906f66 100644
--- a/quilt/new.in
+++ b/quilt/new.in
@@ -9,14 +9,6 @@
# One of the few commands which does not need a series file
skip_series_check=1
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt new [-p n|-p ab] {patchname}\n"
@@ -84,6 +76,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
if [ "$QUILT_PATCHES" = "$QUILT_PC" ]
then
printf $"QUILT_PATCHES(%s) must differ from QUILT_PC(%s)\n" "$QUILT_PATCHES" "$QUILT_PC"
diff --git a/quilt/next.in b/quilt/next.in
index d23ed2d..3188cf5 100644
--- a/quilt/next.in
+++ b/quilt/next.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt next [patch]\n"
@@ -54,6 +46,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
next=$(find_unapplied_patch "$1") || exit
if [ -n "$next" ]
diff --git a/quilt/patches.in b/quilt/patches.in
index f4728f7..bb17a46 100644
--- a/quilt/patches.in
+++ b/quilt/patches.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
declare -a opt_files=()
usage()
@@ -124,6 +116,15 @@ if [ $# -lt 1 ]
then
usage
fi
+
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
while [ $# -ge 1 ]
do
opt_files[${#opt_files[@]}]="$SUBDIR$1"
diff --git a/quilt/pop.in b/quilt/pop.in
index 0a5ef19..a3f97a1 100644
--- a/quilt/pop.in
+++ b/quilt/pop.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt pop [-afRqv] [--refresh] [num|patch]\n"
@@ -208,6 +200,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
if [ -n "$opt_force" -a -n "$opt_refresh" ]
then
printf $"Options %s and %s are mutually exclusive\n" "-f" "--refresh"
diff --git a/quilt/previous.in b/quilt/previous.in
index 55d3cd6..588a985 100644
--- a/quilt/previous.in
+++ b/quilt/previous.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt previous [patch]\n"
@@ -54,6 +46,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_patch_in_series "$1") || exit 1
previous=$(applied_before "$patch" | tail -n 1)
diff --git a/quilt/push.in b/quilt/push.in
index 2a818cf..2a30a9a 100644
--- a/quilt/push.in
+++ b/quilt/push.in
@@ -6,16 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
-setup_colors
-
usage()
{
printf $"Usage: quilt push [-afqvm] [--fuzz=N] [--merge[=merge|diff3]] [--leave-rejects] [--color[=always|auto|never]] [--refresh] [num|patch]\n"
@@ -368,6 +358,16 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
+setup_colors
+
if [ -n "$opt_force" -a -n "$opt_refresh" ]
then
printf $"Options %s and %s are mutually exclusive\n" "-f" "--refresh"
diff --git a/quilt/refresh.in b/quilt/refresh.in
index c20ccfc..fd1ad7c 100644
--- a/quilt/refresh.in
+++ b/quilt/refresh.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt refresh [-p n|-p ab] [-u|-U num|-c|-C num] [-z[new_name]] [-f] [--no-timestamps] [--no-index] [--diffstat] [--sort] [--backup] [--strip-trailing-whitespace] [patch]\n"
@@ -146,6 +138,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
QUILT_DIFF_OPTS="$QUILT_DIFF_OPTS $opt_format"
patch=$(find_applied_patch "$1") || exit 1
diff --git a/quilt/remove.in b/quilt/remove.in
index 972721a..ca97318 100644
--- a/quilt/remove.in
+++ b/quilt/remove.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt remove [-P patch] {file} ...\n"
@@ -60,6 +52,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_applied_patch "$opt_patch") || exit 1
status=0
diff --git a/quilt/rename.in b/quilt/rename.in
index adeec3a..a62e45c 100644
--- a/quilt/rename.in
+++ b/quilt/rename.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt rename [-P patch] new_name\n"
@@ -70,6 +62,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_patch_in_series "$opt_patch") || exit 1
new_patch=${1#$QUILT_PATCHES/}
diff --git a/quilt/revert.in b/quilt/revert.in
index a94cdb8..83b59a9 100644
--- a/quilt/revert.in
+++ b/quilt/revert.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt revert [-P patch] {file} ...\n"
@@ -62,6 +54,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
patch=$(find_applied_patch "$opt_patch") || exit 1
status=0
diff --git a/quilt/series.in b/quilt/series.in
index 69d72e2..00ac701 100644
--- a/quilt/series.in
+++ b/quilt/series.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt series [--color[=always|auto|never]] [-v]\n"
@@ -85,6 +77,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
setup_pager
if [ -n "$opt_verbose$opt_color" ]
diff --git a/quilt/setup.in b/quilt/setup.in
index f199cec..fc0a2c9 100644
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -10,25 +10,6 @@
skip_version_check=1
skip_series_check=1
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
-if [ -n "$SUBDIR" ]
-then
- # Damn, found an enclosing quilt directory; don't follow its settings
- cd $SUBDIR
- unset SUBDIR
- unset QUILT_PC QUILT_PATCHES QUILT_SERIES
- : ${QUILT_PC:=.pc}
- : ${QUILT_PATCHES:=patches}
- : ${QUILT_SERIES:=series}
-fi
-
check_for_existing_directories()
{
local tag dir last_dir arg status=0
@@ -354,6 +335,25 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
+if [ -n "$SUBDIR" ]
+then
+ # Damn, found an enclosing quilt directory; don't follow its settings
+ cd $SUBDIR
+ unset SUBDIR
+ unset QUILT_PC QUILT_PATCHES QUILT_SERIES
+ : ${QUILT_PC:=.pc}
+ : ${QUILT_PATCHES:=patches}
+ : ${QUILT_SERIES:=series}
+fi
+
tmpfile=$(gen_tempfile)
add_exit_handler "rm -f $tmpfile"
diff --git a/quilt/snapshot.in b/quilt/snapshot.in
index 707c64b..ebc367c 100644
--- a/quilt/snapshot.in
+++ b/quilt/snapshot.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt snapshot [-d]\n"
@@ -61,6 +53,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
snap_subdir=.snap
# Clean up from previous snapshot
diff --git a/quilt/top.in b/quilt/top.in
index e559a20..1eb00e7 100644
--- a/quilt/top.in
+++ b/quilt/top.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt top\n"
@@ -54,6 +46,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
top=$(find_top_patch) || exit 2
print_patch $top
### Local Variables:
diff --git a/quilt/unapplied.in b/quilt/unapplied.in
index be62c33..2d14b54 100644
--- a/quilt/unapplied.in
+++ b/quilt/unapplied.in
@@ -6,14 +6,6 @@
#
# See the COPYING and AUTHORS files for more details.
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt unapplied [patch]\n"
@@ -52,7 +44,17 @@ done
if [ $# -gt 1 ]
then
usage
-elif [ $# -eq 1 ]
+fi
+
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
+if [ $# -eq 1 ]
then
start=$(find_patch_in_series "$1") || exit 1
patch=$(patch_after "$start")
diff --git a/quilt/upgrade.in b/quilt/upgrade.in
index b8b9332..dbf7d05 100644
--- a/quilt/upgrade.in
+++ b/quilt/upgrade.in
@@ -10,14 +10,6 @@
skip_version_check=1
skip_series_check=1
-# Read in library functions
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
- echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
- exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-
usage()
{
printf $"Usage: quilt upgrade\n"
@@ -60,6 +52,14 @@ then
usage
fi
+# Read in library functions
+if ! [ -r $QUILT_DIR/scripts/patchfns ]
+then
+ echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
+ exit 1
+fi
+. $QUILT_DIR/scripts/patchfns
+
if version_check
then
printf $"The quilt meta-data in %s are already in the version %s format; nothing to do\n" "$QUILT_PC/" "$DB_VERSION"
diff --git a/test/help.test b/test/help.test
new file mode 100644
index 0000000..4754a67
--- /dev/null
+++ b/test/help.test
@@ -0,0 +1,91 @@
+# We simulate a working tree root so that quilt does not attempt to find one
+# in a parent directory, as this would invalidate this test
+$ mkdir $QUILT_PC
+$ echo 2 > $QUILT_PC/.version
+
+$ quilt add -h | grep -c '^Usage:'
+> 1
+
+$ quilt annotate -h | grep -c '^Usage:'
+> 1
+
+$ quilt applied -h | grep -c '^Usage:'
+> 1
+
+$ quilt delete -h | grep -c '^Usage:'
+> 1
+
+$ quilt diff -h | grep -c '^Usage:'
+> 1
+
+$ quilt edit -h | grep -c '^Usage:'
+> 1
+
+$ quilt files -h | grep -c '^Usage:'
+> 1
+
+$ quilt fold -h | grep -c '^Usage:'
+> 1
+
+$ quilt fork -h | grep -c '^Usage:'
+> 1
+
+$ quilt graph -h | grep -c '^Usage:'
+> 1
+
+$ quilt grep -h | grep -c '^Usage:'
+> 1
+
+$ quilt header -h | grep -c '^Usage:'
+> 1
+
+$ quilt import -h | grep -c '^Usage:'
+> 1
+
+$ quilt mail -h | grep -c '^Usage:'
+> 1
+
+$ quilt new -h | grep -c '^Usage:'
+> 1
+
+$ quilt next -h | grep -c '^Usage:'
+> 1
+
+$ quilt patches -h | grep -c '^Usage:'
+> 1
+
+$ quilt pop -h | grep -c '^Usage:'
+> 1
+
+$ quilt previous -h | grep -c '^Usage:'
+> 1
+
+$ quilt push -h | grep -c '^Usage:'
+> 1
+
+$ quilt refresh -h | grep -c '^Usage:'
+> 1
+
+$ quilt remove -h | grep -c '^Usage:'
+> 1
+
+$ quilt rename -h | grep -c '^Usage:'
+> 1
+
+$ quilt series -h | grep -c '^Usage:'
+> 1
+
+$ quilt setup -h | grep -c '^Usage:'
+> 1
+
+$ quilt snapshot -h | grep -c '^Usage:'
+> 1
+
+$ quilt top -h | grep -c '^Usage:'
+> 1
+
+$ quilt unapplied -h | grep -c '^Usage:'
+> 1
+
+$ quilt upgrade -h | grep -c '^Usage:'
+> 1