git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Lesh <eclesh@ucla.edu>
To: jsipek@cs.sunysb.edu
Cc: git@vger.kernel.org, Eric Lesh <eclesh@ucla.edu>
Subject: [GUILT PATCH 1/5] get_series: Remove comments from end of series lines
Date: Mon, 30 Jul 2007 20:11:17 -0700	[thread overview]
Message-ID: <11858514812742-git-send-email-eclesh@ucla.edu> (raw)
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

  reply	other threads:[~2007-07-31  3:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-31  3:11 [GUILT PATCH v2 0/5] Add guards to guilt Eric Lesh
2007-07-31  3:11 ` Eric Lesh [this message]
2007-07-31  3:50   ` [GUILT PATCH 1/5] get_series: Remove comments from end of series lines Josef Sipek
2007-07-31  3:11 ` [GUILT PATCH 2/5] guilt-guard: Assign guards to patches in series Eric Lesh
2007-07-31  4:05   ` Josef Sipek
2007-08-09  7:34     ` Eric Lesh
2007-08-09  8:17       ` David Kastrup
2007-08-09  8:22         ` Thomas Adam
2007-08-09  8:43           ` David Kastrup
2007-08-09  8:53           ` Eric Lesh
2007-08-09  9:01         ` Eric Lesh
2007-08-09 13:47       ` Josef Sipek
2007-07-31  3:11 ` [GUILT PATCH 3/5] guilt-select: Select guards to apply when pushing patches Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 4/5] get_series: return guarded patches only Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 5/5] Guards test suite Eric Lesh
2007-07-31  3:42 ` [GUILT PATCH v2 0/5] Add guards to guilt Josef Sipek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11858514812742-git-send-email-eclesh@ucla.edu \
    --to=eclesh@ucla.edu \
    --cc=git@vger.kernel.org \
    --cc=jsipek@cs.sunysb.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).