summaryrefslogtreecommitdiff
path: root/git-filter-branch.sh
diff options
context:
space:
mode:
authorJohannes Sixt <johannes.sixt@telecom.at>2008-08-21 14:45:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-08-22 06:39:13 (GMT)
commita9da1663dfc869141749c768e9e0f52bb48218e3 (patch)
tree5e283122f98ba71812f09d7cc297e02a3ea52e05 /git-filter-branch.sh
parent5a4a088add3bdcbe86ae7e87964ce4025ddbc389 (diff)
downloadgit-a9da1663dfc869141749c768e9e0f52bb48218e3.zip
git-a9da1663dfc869141749c768e9e0f52bb48218e3.tar.gz
git-a9da1663dfc869141749c768e9e0f52bb48218e3.tar.bz2
filter-branch: Grok special characters in tag names
The tag rewriting code used a 'sed' expression to substitute the new tag name into the corresponding field of the annotated tag object. But this is problematic if the tag name contains special characters. In particular, if the tag name contained a slash, then the 'sed' expression had a syntax error. We now protect against this by using 'printf' to assemble the tag header. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-filter-branch.sh')
-rwxr-xr-xgit-filter-branch.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index a324cf0..2871a59 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -416,15 +416,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
}" \
-e '/^-----BEGIN PGP SIGNATURE-----/q' \
- -e 'p' |
+ -e 'p' ) |
git mktag) ||
die "Could not create new tag object for $ref"
if git cat-file tag "$ref" | \