{"thread":{"id":"8779","subject":"[PATCH] Correct usages of sed in git-tag for Mac OS X","startedAt":"2007-06-30T06:42:47Z","lastAt":"2007-06-30T07:03:07Z","messageCount":3,"participants":["Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"46068","messageId":"20070630064247.GA18041@spearce.org","threadId":"8779","inReplyTo":null,"subject":"[PATCH] Correct usages of sed in git-tag for Mac OS X","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-06-30T06:42:47Z","receivedAt":"2007-06-30T06:42:47Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Both `git-tag -l` and `git tag -v` fail on Mac OS X due to their\nnon-standard uses of sed.  Actually `git tag -v` fails because the\nunderlying git-tag-verify uses a non-standard sed command.\n\nWe now stick to only standard sed, which does make our sed scripts\nslightly more complicated, but we can actually list tags with more\nthan 0 lines of additional context and we can verify signed tags\nwith gpg.  These major Git functions are much more important than\nsaving two or three lines of a simple sed script.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n Boy, it would sure be nice if git-tag was written in a more portable\n programming language, such as C.  No more worries about sed working\n on one platform and not another.  ;-)\n\n t7004-tag.sh now passes all 65 tests here.\n\n git-tag.sh        |   16 ++++++++++------\n git-verify-tag.sh |    7 ++++---\n 2 files changed, 14 insertions(+), 9 deletions(-)\n\ndiff --git a/git-tag.sh b/git-tag.sh\nindex c840439..3917cd8 100755\n--- a/git-tag.sh\n+++ b/git-tag.sh\n@@ -51,12 +51,16 @@ do\n \t\t[ \"$LINES\" -le 0 ] && { echo \"$TAG\"; continue ;}\n \t\tOBJTYPE=$(git cat-file -t \"$TAG\")\n \t\tcase $OBJTYPE in\n-\t\ttag)\tANNOTATION=$(git cat-file tag \"$TAG\" |\n-\t\t\t\t       sed -e '1,/^$/d' \\\n-\t\t\t\t\t   -e '/^-----BEGIN PGP SIGNATURE-----$/Q' )\n-\t\t\tprintf \"%-15s %s\\n\" \"$TAG\" \"$ANNOTATION\" |\n-\t\t\t  sed -e '2,$s/^/    /' \\\n-\t\t\t      -e \"${LINES}q\"\n+\t\ttag)\n+\t\t\tANNOTATION=$(git cat-file tag \"$TAG\" |\n+\t\t\t\tsed -e '1,/^$/d' |\n+\t\t\t\tsed -n -e \"\n+\t\t\t\t\t/^-----BEGIN PGP SIGNATURE-----\\$/q\n+\t\t\t\t\t2,\\$s/^/    /\n+\t\t\t\t\tp\n+\t\t\t\t\t${LINES}q\n+\t\t\t\t\")\n+\t\t\tprintf \"%-15s %s\\n\" \"$TAG\" \"$ANNOTATION\"\n \t\t\t;;\n \t\t*)      echo \"$TAG\"\n \t\t\t;;\ndiff --git a/git-verify-tag.sh b/git-verify-tag.sh\nindex f2d5597..a54fd48 100755\n--- a/git-verify-tag.sh\n+++ b/git-verify-tag.sh\n@@ -37,8 +37,9 @@ esac\n trap 'rm -f \"$GIT_DIR/.tmp-vtag\"' 0\n \n git-cat-file tag \"$1\" >\"$GIT_DIR/.tmp-vtag\" || exit 1\n-\n-cat \"$GIT_DIR/.tmp-vtag\" |\n-sed '/-----BEGIN PGP/Q' |\n+sed -n -e '\n+\t/^-----BEGIN PGP SIGNATURE-----$/q\n+\tp\n+\t' <\"$GIT_DIR/.tmp-vtag\" |\n gpg --verify \"$GIT_DIR/.tmp-vtag\" - || exit 1\n rm -f \"$GIT_DIR/.tmp-vtag\"\n-- \n1.5.2.2.1414.g1e7d-dirty\n"},{"id":"46069","messageId":"7vzm2ic4g8.fsf@assigned-by-dhcp.pobox.com","threadId":"8779","inReplyTo":"20070630064247.GA18041@spearce.org","subject":"Re: [PATCH] Correct usages of sed in git-tag for Mac OS X","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-30T07:00:07Z","receivedAt":"2007-06-30T07:00:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> These major Git functions are much more important than\n> saving two or three lines of a simple sed script.\n\nThe size of the script does not worry me.  The number of sed\nprocesses originally did, but the old code also had two\ninvocations of sed, and I do not think you can implement the\n\"strip the header, and then emit ${LINES} lines\" behaviour\nwithout doing them in separate sed anyway, so I think this is\nfine.  But it makes me wonder why we are not using awk ;-)\n"},{"id":"46070","messageId":"20070630070307.GP32223@spearce.org","threadId":"8779","inReplyTo":"7vzm2ic4g8.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [PATCH] Correct usages of sed in git-tag for Mac OS X","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-06-30T07:03:07Z","receivedAt":"2007-06-30T07:03:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > These major Git functions are much more important than\n> > saving two or three lines of a simple sed script.\n> \n> The size of the script does not worry me.  The number of sed\n> processes originally did, but the old code also had two\n> invocations of sed, and I do not think you can implement the\n> \"strip the header, and then emit ${LINES} lines\" behaviour\n> without doing them in separate sed anyway, so I think this is\n> fine.  But it makes me wonder why we are not using awk ;-)\n\nOr perl.  ;-)\n\nBut the patch I just sent is sane.  And it all will hopefully go\naway when Carlos has his C version complete and passing the very\nlarge test suite he recently contributed.  So not really worth\nworrying about now that its working properly.\n\nBut yea, I changed the script the way I did to keep the number of sed\nprocesses per tag equal to what we had before.  Its not any better,\nbut its also not any worse and it at least runs on more systems.\n\n-- \nShawn.\n"}]}