[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    Re: [PATCH] filter-branch: Grok special characters in tag names
From:       Brandon Casey <casey () nrlssc ! navy ! mil>
Date:       2008-08-21 16:38:20
Message-ID: NWVPkDIELqWBHTU58gfzDqO8HR575ZDJVO2pYdPMtqv9aBLzMLvyZg () cipher ! nrlssc ! navy ! mil
[Download RAW message or body]

Johannes Sixt wrote:

> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 2688254..81392ad 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -412,15 +412,17 @@ if [ "$filter_tag_name" ]; then
>  		echo "$ref -> $new_ref ($sha1 -> $new_sha1)"
>  
>  		if [ "$type" = "tag" ]; then
> -			new_sha1=$(git cat-file tag "$ref" |
> +			new_sha1=$( ( printf 'object %s\ntype commit\ntag %s\n' \
> +						"$new_sha1" "$new_ref"
> +				git cat-file tag "$ref" |
>  				sed -n \
>  				    -e "1,/^$/{
> -					  s/^object .*/object $new_sha1/
> -					  s/^type .*/type commit/
> -					  s/^tag .*/tag $new_ref/
> +					  /^object /d
> +					  /^type /d
> +					  /^tag /d

Junio complained that my initial version of this was fragile which has
similarities with the above. Initially, I was blindly changing the first line
to contain "object...", second line to "type...", etc.

Would something like the following be equivalent _and_ clearer? Emphasis on "and"
because both are necessary, not because I strongly feel it to be so.

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index a324cf0..11c5c04 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -419,9 +419,12 @@ if [ "$filter_tag_name" ]; then
 			new_sha1=$(git cat-file tag "$ref" |
 				sed -n \
 				    -e "1,/^$/{
-					  s/^object .*/object $new_sha1/
-					  s/^type .*/type commit/
-					  s/^tag .*/tag $new_ref/
+					  /^object .*/c\\
+object $new_sha1
+					  /^type .*/c\\
+type commit
+					  /^tag .*/c\\
+tag $new_ref
 					}" \
 				    -e '/^-----BEGIN PGP SIGNATURE-----/q' \
 				    -e 'p' |


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

Configure | About | News | Add a list | Sponsored by KoreLogic