1#! @BASH@ 2 3# This script is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License version 2 as 5# published by the Free Software Foundation. 6# 7# See the COPYING and AUTHORS files for more details. 8 9# Read in library functions 10if [ "$(type -t patch_file_name)" != function ] 11then 12 if ! [ -r $QUILT_DIR/scripts/patchfns ] 13 then 14 echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2 15 exit 1 16 fi 17 . $QUILT_DIR/scripts/patchfns 18fi 19 20usage() 21{ 22 printf $"Usage: quilt files [-v] [-a] [-l] [--combine patch] [patch]\n" 23 if [ x$1 = x-h ] 24 then 25 printf $" 26Print the list of files that the topmost or specified patch changes. 27 28-a List all files in all applied patches. 29 30-l Add patch name to output. 31 32-v Verbose, more user friendly output. 33 34--combine patch 35 Create a listing for all patches between this patch and 36 the topmost or specified patch. A patch name of \`-' is 37 equivalent to specifying the first applied patch. 38 39" 40 exit 0 41 else 42 exit 1 43 fi 44} 45 46options=`getopt -o vhal --long combine: -- "$@"` 47 48if [ $? -ne 0 ] 49then 50 usage 51fi 52 53eval set -- "$options" 54 55while true 56do 57 case "$1" in 58 -v) 59 opt_verbose=1 60 shift ;; 61 -a) 62 opt_all=1 63 shift ;; 64 -l) 65 opt_labels=1 66 shift ;; 67 -h) 68 usage -h ;; 69 --combine) 70 opt_all=1 71 if [ "$2" = - ] 72 then 73 : 74 else 75 first_patch=$(find_patch_in_series "$2") || exit 1 76 fi 77 shift 2 ;; 78 --) 79 shift 80 break ;; 81 esac 82done 83 84if [ $# -gt 1 ] 85then 86 usage 87fi 88 89last_patch=$(find_patch_in_series "$1") || exit 1 90 91if [ -n "$opt_all" -a -z "$first_patch" ] 92then 93 first_patch=$(applied_patches | head -n 1) 94fi 95 96if [ -n "$opt_all" ] 97then 98 set -- $(patches_before "$last_patch") "$last_patch" 99 while [ $# -ge 1 -a "$1" != "$first_patch" ] 100 do 101 shift 102 done 103 if [ $# -eq 0 ] 104 then 105 printf $"Patch %s not applied before patch %s\n" \ 106 "$(print_patch "$first_patch")" \ 107 "$(print_patch "$last_patch")" >&2 108 exit 1 109 fi 110 patches=( "$@" ) 111else 112 patches=( "$last_patch" ) 113fi 114 115list_files_in_patch() 116{ 117 local patch=$1 118 local status 119 local saved_IFS=$IFS 120 121 if [ -n "$opt_all" ] && [ -n "$opt_verbose" ] && [ -z "$opt_labels" ] 122 then 123 echo "$patch" 124 fi 125 if [ -n "$opt_verbose" ] && [ -z "$opt_labels" ] 126 then 127 use_status=yes 128 fi 129 # Note: If opt_labels is set, then use_status is not set. 130 IFS= 131 if is_applied "$patch" 132 then 133 files_in_patch "$patch" 134 else 135 filenames_in_patch "$patch" 136 fi | 137 sort | 138 while read file 139 do 140 if [ -n "$opt_labels" ] 141 then 142 if [ -n "$opt_verbose" ] 143 then 144 echo -n "[$patch] " 145 else 146 echo -n "$patch " 147 fi 148 fi 149 if [ -z "$use_status" ] 150 then 151 echo "$file" 152 else 153 status=" " 154 if [ -s $(backup_file_name "$patch" "$file") ] 155 then 156 if ! [ -s "$file" ] 157 then 158 status="-" 159 fi 160 else 161 if [ -s "$file" ] 162 then 163 status="+" 164 fi 165 fi 166 echo "$status $file" 167 fi 168 done 169 IFS=$saved_IFS 170} 171 172setup_pager 173 174for patch in "${patches[@]}" 175do 176 list_files_in_patch "$patch" 177done 178### Local Variables: 179### mode: shell-script 180### End: 181# vim:filetype=sh 182