Skip to content

Commit

Permalink
Correct usages of sed in git-tag for Mac OS X
Browse files Browse the repository at this point in the history
Both `git-tag -l` and `git tag -v` fail on Mac OS X due to their
non-standard uses of sed.  Actually `git tag -v` fails because the
underlying git-tag-verify uses a non-standard sed command.

We now stick to only standard sed, which does make our sed scripts
slightly more complicated, but we can actually list tags with more
than 0 lines of additional context and we can verify signed tags
with gpg.  These major Git functions are much more important than
saving two or three lines of a simple sed script.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Jun 30, 2007
1 parent 124d3e4 commit bfc04bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 10 additions & 6 deletions git-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ do
[ "$LINES" -le 0 ] && { echo "$TAG"; continue ;}
OBJTYPE=$(git cat-file -t "$TAG")
case $OBJTYPE in
tag) ANNOTATION=$(git cat-file tag "$TAG" |
sed -e '1,/^$/d' \
-e '/^-----BEGIN PGP SIGNATURE-----$/Q' )
printf "%-15s %s\n" "$TAG" "$ANNOTATION" |
sed -e '2,$s/^/ /' \
-e "${LINES}q"
tag)
ANNOTATION=$(git cat-file tag "$TAG" |
sed -e '1,/^$/d' |
sed -n -e "
/^-----BEGIN PGP SIGNATURE-----\$/q
2,\$s/^/ /
p
${LINES}q
")
printf "%-15s %s\n" "$TAG" "$ANNOTATION"
;;
*) echo "$TAG"
;;
Expand Down
7 changes: 4 additions & 3 deletions git-verify-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ esac
trap 'rm -f "$GIT_DIR/.tmp-vtag"' 0

git-cat-file tag "$1" >"$GIT_DIR/.tmp-vtag" || exit 1

cat "$GIT_DIR/.tmp-vtag" |
sed '/-----BEGIN PGP/Q' |
sed -n -e '
/^-----BEGIN PGP SIGNATURE-----$/q
p
' <"$GIT_DIR/.tmp-vtag" |
gpg --verify "$GIT_DIR/.tmp-vtag" - || exit 1
rm -f "$GIT_DIR/.tmp-vtag"

0 comments on commit bfc04bb

Please sign in to comment.