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

Re: [PATCH] filter-branch: Grok special characters in tag names

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Aug 21, 2008, 19:07 UTC
Message-ID
<200808212107.33474.johannes.sixt@telecom.at>
In-Reply-To
<NWVPkDIELqWBHTU58gfzDqO8HR575ZDJVO2pYdPMtqv9aBLzMLvyZg@cipher.nrlssc.navy.mil>
On Donnerstag, 21. August 2008, Brandon Casey wrote:
Show 25 quoted lines
> 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.

I don't see what's wrong with that. "object" must be the first line anyway, otherwise git mktag chokes.

Show 23 quoted lines
> 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' |
This looks fine, too. (The '.*' in /^foo .*/c\\ is unnecessary.)
-- Hannes
Previous: Brandon CaseyNext: Brandon Casey
Message 3 of 6 in “filter-branch: Grok special characters in tag names”
  1. filter-branch: Grok special characters in tag namesJohannes Sixt, Aug 21, 2008
  2. Brandon CaseyAug 21, 2008
  3. Johannes SixtAug 21, 2008
  4. Brandon CaseyAug 21, 2008
  5. Junio C HamanoAug 21, 2008
  6. Brandon CaseyAug 21, 2008

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.