From 6bb55d4a5e9c119cc46854373d2cde5cc3dc6756 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Thu, 30 Jan 2003 22:59:26 +0000 Subject: Add -n option to print patch file name instead of patch name --- quilt.changes | 5 ++++- quilt/applied.in | 17 ++++++++++++++--- quilt/next.in | 13 ++++++++++--- quilt/patches.in | 9 ++++++++- quilt/previous.in | 11 +++++++++-- quilt/series.in | 9 ++++++++- quilt/top.in | 9 +++++++-- quilt/unapplied.in | 14 ++++++++++++-- 8 files changed, 72 insertions(+), 15 deletions(-) diff --git a/quilt.changes b/quilt.changes index 059b2bf..c8a963d 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,7 +1,10 @@ ------------------------------------------------------------------- -Thu Jan 30 23:15:36 +0100 2003 - agruen@suse.de +Thu Jan 30 23:56:21 +0100 2003 - agruen@suse.de - Also substitute @MKTEMP@. +- For improved scripting support, -n option to scripts that + print patch names prints the patch file name instead. This + is useful for selecting which patches to grep, etc. ------------------------------------------------------------------- Thu Jan 30 19:02:14 +0100 2003 - agruen@suse.de diff --git a/quilt/applied.in b/quilt/applied.in index 8bac6a4..4c7bd72 100644 --- a/quilt/applied.in +++ b/quilt/applied.in @@ -27,6 +27,8 @@ usage() Print a list of applied patches, or all patches up to and including the specified patch in the file series. +-n Print patch file names instead of patch names. + EOF exit 0 else @@ -34,7 +36,7 @@ EOF fi } -options=`getopt -o h -- "$@"` +options=`getopt -o nh -- "$@"` if [ $? -ne 0 ] then @@ -46,6 +48,9 @@ eval set -- "$options" while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -h) usage -h ;; --) @@ -66,6 +71,12 @@ fi if [ -n "$patch" ] then - patches_before $patch - echo $patch + for patch in $( + patches_before $patch + echo $patch + ) + do + [ -n "$opt_filenames" ] && patch=$(patch_file_name $patch) + echo $patch + done fi diff --git a/quilt/next.in b/quilt/next.in index f61f795..788f857 100644 --- a/quilt/next.in +++ b/quilt/next.in @@ -27,6 +27,8 @@ usage() Print the name of the next patch after the specified or topmost patch in the series file. +-n Print patch file names instead of patch names. + EOF exit 0 else @@ -34,7 +36,7 @@ EOF fi } -options=`getopt -o h -- "$@"` +options=`getopt -o nh -- "$@"` if [ $? -ne 0 ] then @@ -46,6 +48,9 @@ eval set -- "$options" while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -h) usage -h ;; --) @@ -66,7 +71,9 @@ fi if [ -z "$patch" ] then - cat_series | head -1 + next=$(cat_series | head -1) else - patches_after $patch | head -1 + next=$(patches_after $patch | head -1) fi +[ -n "$opt_filenames" ] && next=$(patch_file_name $next) +echo "$next" diff --git a/quilt/patches.in b/quilt/patches.in index 82aeac8..2f026fa 100644 --- a/quilt/patches.in +++ b/quilt/patches.in @@ -26,6 +26,8 @@ usage() Print the list of patches that modify the specified file. +-n Print the patch file names instead of the patch names. + -v Verbose, more user friendly output. EOF @@ -44,11 +46,13 @@ scan_patches() for patch in $(modified_files $file -- "$@" \ | cut -d $'\t' -f2) do + [ -n "$opt_filenames" ] && patch=$(patch_file_name $patch) + echo "$prefix$patch" done } -options=`getopt -o vh -- "$@"` +options=`getopt -o nvh -- "$@"` if [ $? -ne 0 ] then @@ -60,6 +64,9 @@ eval set -- "$options" while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -v) opt_verbose=1 shift ;; diff --git a/quilt/previous.in b/quilt/previous.in index 17d26be..9f156d6 100644 --- a/quilt/previous.in +++ b/quilt/previous.in @@ -27,6 +27,8 @@ usage() Print the name of the previous patch before the specified or topmost patch in the series file. +-n Print patch file names instead of patch names. + EOF exit 0 else @@ -34,7 +36,7 @@ EOF fi } -options=`getopt -o h -- "$@"` +options=`getopt -o nh -- "$@"` if [ $? -ne 0 ] then @@ -46,6 +48,9 @@ eval set -- "$options" while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -h) usage -h ;; --) @@ -66,5 +71,7 @@ fi if [ -n "$patch" ] then - patches_before $patch | tail -1 + previous=$(patches_before $patch | tail -1) + [ -n "$opt_filenames" ] && previous=$(patch_file_name $previous) + echo "$previous" fi diff --git a/quilt/series.in b/quilt/series.in index c91e0eb..0d45d94 100644 --- a/quilt/series.in +++ b/quilt/series.in @@ -26,7 +26,10 @@ usage() Print the names of all patches in the file series. +-n Print patch file names instead patch names. + -v Verbose, more user friendly output + EOF exit 0 else @@ -42,11 +45,12 @@ cat_patches() for patch in "$@" do + [ -n "$opt_filenames" ] && patch=$(patch_file_name $patch) echo "$prefix$patch" done } -options=`getopt -o vh -- "$@"` +options=`getopt -o nvh -- "$@"` if [ $? -ne 0 ] then @@ -60,6 +64,9 @@ opt_what=here while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -v) opt_verbose=1 shift ;; diff --git a/quilt/top.in b/quilt/top.in index 4e98a71..c7e1e12 100644 --- a/quilt/top.in +++ b/quilt/top.in @@ -34,7 +34,7 @@ EOF fi } -options=`getopt -o h -- "$@"` +options=`getopt -o nh -- "$@"` if [ $? -ne 0 ] then @@ -46,6 +46,9 @@ eval set -- "$options" while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -h) usage -h ;; --) @@ -59,4 +62,6 @@ then usage fi -top_patch +top=$(top_patch) +[ -n "$opt_filenames" ] && top=$(patch_file_name $top) +echo "$top" diff --git a/quilt/unapplied.in b/quilt/unapplied.in index bdacaa5..8a99bfa 100644 --- a/quilt/unapplied.in +++ b/quilt/unapplied.in @@ -27,6 +27,8 @@ usage() Print a list of patches that are not applied, or all patches that follow the specified patch in the series file. +-n Print patch file names instead of patch names. + EOF exit 0 else @@ -34,7 +36,7 @@ EOF fi } -options=`getopt -o h -- "$@"` +options=`getopt -o nh -- "$@"` if [ $? -ne 0 ] then @@ -46,6 +48,9 @@ eval set -- "$options" while true do case "$1" in + -n) + opt_filenames=1 + shift ;; -h) usage -h ;; --) @@ -69,4 +74,9 @@ then cat_series else patches_after $patch -fi +fi \ +| while read patch +do + [ -n "$opt_filenames" ] && patch=$(patch_file_name $patch) + echo "$patch" +done -- cgit