Re: [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]

 



On Mon, Jul 30, 2007 at 08:11:17PM -0700, Eric Lesh wrote:
...
> @@ -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"
>  }

I haven't tested it, but I believe that this change would be very
bad...suppose you have series with patches "foo" and "foo-2". Now if you try
to remove foo, the regexp would end up being:

"^foo[ ]*#*"

This would match both patches!
  
>  # 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)

This could match multiple lines.

> +	new=$(echo "$old" | sed -e "s,^$1,$2,")

One more comment about sed...there are a number of place in guilt that take
patch names and create regexps from them, but don't make sure things get
properly escaped. I guess all the sed changes should be done in one go.

Also, beware that this is in a function, so setting $new and $old affects
the _all_ of guilt. One way around it would be a force subshell to execute
using parenthesis around the contents of the function body.

> +	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
>  }

Good :)

Jeff.

-- 
NT is to UNIX what a doughnut is to a particle accelerator.
-
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