File 0001-patchfns-Extend-format-of-series-file.patch of Package quilt

From 59d6dcf97cd0740ad37051574b0b501e6fcec1fe Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@suse.de>
Date: Mon, 20 Mar 2017 09:51:26 -0700
Subject: [PATCH 1/5] patchfns: Extend format of series file

Support whitespace before patch file name
Interpret lines that begin with +- as comments (in fact, they are "guards")
Reuse leading space from previous entry when inserting a new entry

This effectively allows using series.conf directly as a series file. The
benefit is that the former doesn't need to be updated after using `quilt
import` and other functions that change the series file.
---
 quilt/scripts/patchfns.in | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

Index: quilt-0.68/quilt/scripts/patchfns.in
===================================================================
--- quilt-0.68.orig/quilt/scripts/patchfns.in
+++ quilt-0.68/quilt/scripts/patchfns.in
@@ -221,7 +221,7 @@ patch_in_series()
 
 	if [ -e "$SERIES" ]
 	then
-		grep -q "^$(quote_grep_re $patch)\([ \t]\|$\)" "$SERIES"
+		grep -q "^[[:space:]]*$(quote_grep_re $patch)\([ \t]\|$\)" "$SERIES"
 	else
 		return 1
 	fi
@@ -250,8 +250,11 @@ insert_in_series()
 	if [ -n "$before" ]
 	then
 		awk '
-		/^'"$(quote_awk_re $before)"'([ \t]|$)/ \
-				{ print "'"$patch$patch_args"'" }
+		/^[[:space:]]*'"$(quote_awk_re $before)"'([ \t]|$)/ \
+				{
+					match($0, "^([[:space:]]*)'"$(quote_awk_re $before | sed -e 's:\\:\\\\:g')"'([ \t]|$)", a)
+					print a[1] "'"$patch$patch_args"'"
+				}
 				{ print }
 		' "$SERIES" > $tmpfile
 		status=$?
@@ -280,7 +283,7 @@ remove_from_series()
 
 	tmpfile=$(gen_tempfile) || return 1
 	awk '
-	! /^'"$(quote_awk_re $patch)"'([ \t]|$)/ \
+	! /^[[:space:]]*'"$(quote_awk_re $patch)"'([ \t]|$)/ \
 				{ print }
 	' "$SERIES" > $tmpfile
 	if [ $? -ne 0 ]
@@ -298,7 +301,7 @@ rename_in_series()
 
 	tmpfile=$(gen_tempfile) || return 1
 	awk '
-	/^'"$(quote_awk_re $from)"'([ \t]|$)/ \
+	/^[[:space:]]*'"$(quote_awk_re $from)"'([ \t]|$)/ \
 		{ sub(/'"$(quote_awk_re $from)"'/, "'"${to//\"/\\\"}"'")
 		  good=1 }
 		{ print }
@@ -349,8 +352,10 @@ cat_series()
 {
 	if [ -e "$SERIES" ]
 	then
-		sed -e '/^#/d' -e 's/^[ '$'\t'']*//' \
-		    -e 's/[ '$'\t''].*//' -e '/^$/d' "$SERIES"
+		sed -e '/^[[:space:]]*[-#+]/d' \
+		    -e 's/^[ '$'\t'']*//' \
+		    -e 's/[ '$'\t''].*//' \
+		    -e '/^$/d' "$SERIES"
 	else
 		return 1
 	fi
@@ -526,9 +531,10 @@ find_patch()
 		fi
 
 		local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/}
-		local bre=$(quote_sed_re "$patch")
-		set -- $(sed -e "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\|\.lz\|\.zst\)\([ "$'\t'"]\|$\)/!d" \
-			       -e 's/[ '$'\t''].*//' "$SERIES")
+		set -- $(cat_series | awk '
+			/^'$(quote_awk_re $patch)'(.patch|.diff)?(.gz|.bz2|.xz|.lzma|.lz|.zst)?/ {
+				print $1
+				}')
 		if [ $# -eq 1 ]
 		then
 			echo $1
openSUSE Build Service is sponsored by