git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
ELEric Lesh <eclesh@ucla.edu>
Date
Jul 31, 2007, 03:11 UTC
Message-ID
<11858514812742-git-send-email-eclesh@ucla.edu>
In-Reply-To
<1185851481190-git-send-email-eclesh@ucla.edu>

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@ucla.edu>
---
 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
Previous: Eric LeshNext: Josef Sipek
Message 2 of 16 in “Add guards to guilt”
  1. 0/5 Add guards to guiltEric Lesh, Jul 31, 2007
  2. 1/5 get_series: Remove comments from end of series linesEric Lesh, Jul 31, 2007
  3. Josef SipekJul 31, 2007
  4. 2/5 guilt-guard: Assign guards to patches in seriesEric Lesh, Jul 31, 2007
  5. Josef SipekJul 31, 2007
  6. Eric LeshAug 9, 2007
  7. David KastrupAug 9, 2007
  8. Thomas AdamAug 9, 2007
  9. David KastrupAug 9, 2007
  10. Eric LeshAug 9, 2007
  11. Eric LeshAug 9, 2007
  12. Josef SipekAug 9, 2007
  13. 3/5 guilt-select: Select guards to apply when pushing patchesEric Lesh, Jul 31, 2007
  14. 4/5 get_series: return guarded patches onlyEric Lesh, Jul 31, 2007
  15. 5/5 Guards test suiteEric Lesh, Jul 31, 2007
  16. Josef SipekJul 31, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.