From bf2a07ca502272ae28762b3fa9b0dd68db8dc7f0 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Sun, 6 Jun 2004 18:42:14 +0000 Subject: - Preserve the order of files in patches in the diff and refresh commands. Files added to a patch appear at the end of a patch. The files command also lists the files in the order in which they appear in patches. - Update to version 0.33. --- scripts/patchfns.in | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'scripts/patchfns.in') diff --git a/scripts/patchfns.in b/scripts/patchfns.in index 10775ba..154c544 100644 --- a/scripts/patchfns.in +++ b/scripts/patchfns.in @@ -479,6 +479,48 @@ files_in_patch() fi } +filenames_in_patch() +{ + local patch=$1 + local patch_file=$(patch_file_name $patch) + if [ -e "$patch_file" ] + then + local strip=$(patch_strip_level $patch) + @AWK@ ' + ($1 == "+++" || $1 == "---" || $1 == "***") && \ + $3 != "----" && $3 != "****" \ + { sub(/\t.*/, "") + sub(/^... /, "") + for (n=0 ; n<'"$strip"'; n++) + sub(/^([^/]+\/)/, "") + print $0 }' $patch_file + fi +} + +files_in_patch_ordered() +{ + local patch=$1 + + ( files_in_patch $patch + echo "-" + filenames_in_patch $patch + ) | awk ' + $1 == "-" { out=1 ; next } + !out { files[$0]=1 } + out { if ($0 in files && !($0 in printed)) { + print $0 + printed[$0]=1 + } + } + END { + for (file in files) { + if (!(file in printed)) + print file + } + } + ' +} + touched_by_patch() { local strip=$1 patch=$2 -- cgit