From: Jean Delvare
Subject: Consistently complain early if no series file is found If no series file is found, let all quilt commands which need it complain about it immediately. This aligns the behavior of the "pop", "series" and "snapshot" command with how all other commands behave. The "import", "new", "setup" and "upgrade" commands are not affected by this change, as they are legitimately called without a series file. A side effect of this change is that the "pop", "push", "top" and "next" commands will now return with error code 1 instead of 2 when called outside of a quilt-managed tree. Inspired by Martin Quinson. This fixes Debian bug #369908: https://bugs.debian.org/369908 Signed-off-by: Jean Delvare --- quilt/import.in | 3 +++ quilt/new.in | 3 +++ quilt/scripts/patchfns.in | 27 +++++++++++++++------------ quilt/setup.in | 3 ++- quilt/upgrade.in | 3 ++- test/no-series.test | 7 +++++-- test/three.test | 4 ++-- 7 files changed, 32 insertions(+), 18 deletions(-) --- a/quilt/import.in +++ b/quilt/import.in @@ -6,6 +6,9 @@ # # See the COPYING and AUTHORS files for more details. +# One of the few commands which does not need a series file +skip_series_check=1 + # Read in library functions if [ "$(type -t patch_file_name)" != function ] then --- a/quilt/new.in +++ b/quilt/new.in @@ -6,6 +6,9 @@ # # See the COPYING and AUTHORS files for more details. +# One of the few commands which does not need a series file +skip_series_check=1 + # Read in library functions if [ "$(type -t patch_file_name)" != function ] then --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -489,12 +489,7 @@ find_first_patch() local patch=$(cat_series | head -n 1) if [ -z "$patch" ] then - if [ -e "$SERIES" ] - then - printf $"No patches in series\n" >&2 - else - printf $"No series file found\n" >&2 - fi + printf $"No patches in series\n" >&2 return 1 fi @@ -506,12 +501,7 @@ find_last_patch() local patch=$(cat_series | tail -n 1) if [ -z "$patch" ] then - if [ -e "$SERIES" ] - then - printf $"No patches in series\n" >&2 - else - printf $"No series file found\n" >&2 - fi + printf $"No patches in series\n" >&2 return 1 fi @@ -1168,9 +1158,13 @@ then elif [ -f "$QUILT_PC/$QUILT_SERIES" ] then SERIES=$QUILT_PC/$QUILT_SERIES + # We know the file exists, no need to re-check later + skip_series_check=1 elif [ -f "$QUILT_SERIES" ] then SERIES=$QUILT_SERIES + # We know the file exists, no need to re-check later + skip_series_check=1 else SERIES=$QUILT_PATCHES/$QUILT_SERIES fi @@ -1193,6 +1187,15 @@ then exit 1 fi fi + +if [ -z "$skip_series_check" ] +then + if [ ! -f "$SERIES" ] + then + printf $"No series file found\n" >&2 + exit 1 + fi +fi ### Local Variables: ### mode: shell-script ### End: --- a/quilt/setup.in +++ b/quilt/setup.in @@ -6,8 +6,9 @@ # # See the COPYING and AUTHORS files for more details. -# Version check is irrelevant to this command. +# Version and series checks are irrelevant to this command. skip_version_check=1 +skip_series_check=1 # Read in library functions if [ "$(type -t patch_file_name)" != function ] --- a/quilt/upgrade.in +++ b/quilt/upgrade.in @@ -6,8 +6,9 @@ # # See the COPYING and AUTHORS files for more details. -# Don't abort in version check. +# Don't abort in version or series check. skip_version_check=1 +skip_series_check=1 # Read in library functions if [ "$(type -t patch_file_name)" != function ] --- a/test/no-series.test +++ b/test/no-series.test @@ -26,9 +26,9 @@ $ quilt next > No series file found $ quilt pop -> No patch removed +> No series file found $ quilt pop -v -> No patch removed +> No series file found $ quilt previous > No series file found @@ -42,9 +42,12 @@ $ quilt refresh > No series file found $ quilt series +> No series file found $ quilt series -v +> No series file found $ quilt snapshot +> No series file found $ quilt top > No series file found --- a/test/three.test +++ b/test/three.test @@ -29,9 +29,9 @@ > No series file found $ quilt pop - > No patch removed + > No series file found $ echo %{?} - > 2 + > 1 $ quilt new patch1.diff > Patch %{P}patch1.diff is now on top