summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5a4a088)
raw | patch | inline | side by side (parent: 5a4a088)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Thu, 21 Aug 2008 14:45:11 +0000 (16:45 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 22 Aug 2008 06:39:13 +0000 (23:39 -0700) |
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>
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>
git-filter-branch.sh | patch | blob | history | |
t/t7003-filter-branch.sh | patch | blob | history |
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index a324cf0596ee0f05831190ce724fe9134bc7f568..2871a59e3280584a2620a67f53e2e28dc808dac0 100755 (executable)
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
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" | \
index a0ab096c8fdee153a89a1428f85c9bf107badada..f92d414e63550cf4e0dcf3b3bc9776f1e23c8a6c 100755 (executable)
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
test_cmp expect actual
'
+test_expect_success 'Tag name filtering allows slashes in tag names' '
+ git tag -m tag-with-slash X/1 &&
+ git cat-file tag X/1 | sed -e s,X/1,X/2, > expect &&
+ git filter-branch -f --tag-name-filter "echo X/2" &&
+ git cat-file tag X/2 > actual &&
+ test_cmp expect actual
+'
+
test_done