[GUILT PATCH 1/5] get_series: Remove comments from end of series lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also make sure that series_remove_patch and series_rename_patch do the
right thing if there are comments on the line.

Signed-off-by: Eric Lesh <eclesh@xxxxxxxx>
---
 guilt                    |   15 ++++++++++++---
 regression/050-series.sh |    2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/guilt b/guilt
index 7f2b93c..700c167 100755
--- a/guilt
+++ b/guilt
@@ -178,7 +178,13 @@ get_series()
 	#	- whitespace only
 	#	- optional whitespace followed by '#' followed by more
 	#	  optional whitespace
-	grep -ve '^[[:space:]]*\(#.*\)*$' "$series"
+	# also remove comments from end of lines
+	sed -n -e "/^[[:space:]]*\(#.*\)*\$/ ! {
+		s/[[:space:]]*#.*\$//
+
+		p
+		}
+		" $series
 }
 
 # usage: do_make_header <hash>
@@ -290,14 +296,17 @@ series_insert_patch()
 # usage: series_remove_patch <patchname>
 series_remove_patch()
 {
-	grep -v "^$1\$" < "$series" > "$series.tmp"
+	grep -v "^$1[[:space:]]*#*" < "$series" > "$series.tmp"
 	mv "$series.tmp" "$series"
 }
 
 # usage: series_rename_patch <oldname> <newname>
 series_rename_patch()
 {
-	awk -v old="$1" -v new="$2" \
+	# Rename the patch, but preserve comments on the line
+	old=$(grep -e "^$1[[:space:]]*" $series)
+	new=$(echo "$old" | sed -e "s,^$1,$2,")
+	awk -v old="$old" -v new="$new" \
 		'{ if ($0 == old) print new; else print $0 }' \
 		"$series" > "$series.tmp"
 
diff --git a/regression/050-series.sh b/regression/050-series.sh
index eb23540..4c47e9d 100755
--- a/regression/050-series.sh
+++ b/regression/050-series.sh
@@ -26,7 +26,7 @@ modify
 add
 
 remove
-mode
+mode # and text
 #sure
 DONE
 }
-- 
1.5.2

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux