{"thread":{"id":"15600","subject":"[PATCH] [TOPGIT] Use git-mailinfo to extract author informations from .topmsg","startedAt":"2008-09-19T21:27:57Z","lastAt":"2008-09-19T21:27:57Z","messageCount":1,"participants":["Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91147","messageId":"1221859677-8558-1-git-send-email-ukleinek@strlen.de","threadId":"15600","inReplyTo":null,"subject":"[PATCH] [TOPGIT] Use git-mailinfo to extract author informations from .topmsg","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@strlen.de","sentAt":"2008-09-19T21:27:57Z","receivedAt":"2008-09-19T21:27:57Z","isPatch":true,"sender":{"key":"ukleinek@strlen.de","avatar":"https://gravatar.com/avatar/71e008a89bd4c9d95c03e4823fa14b01e7f658bfc746c8a735286b945417f2d6?d=mp&s=160"},"body":"This has the benefit that the [PATCH] prefixes are stripped and so it\nmight help to prevent you sending mails with two prefixes.  (As happend\nto me after I git-format-patch'd an exported series and sent it out with\ngit-send-email.)\n\nMoreover it should make the code more robust and it allows to remove a\nhelper function.\nAnd it allows you to set add a Date: line to .topmsg which is then used\nas author date.\n\nSigned-off-by: Uwe Kleine-König <ukleinek@strlen.de>\n---\n tg-export.sh |   45 +++++++++++++--------------------------------\n 1 files changed, 13 insertions(+), 32 deletions(-)\n\ndiff --git a/tg-export.sh b/tg-export.sh\nindex 654b38b..335f698 100644\n--- a/tg-export.sh\n+++ b/tg-export.sh\n@@ -38,17 +38,6 @@ trap 'rm -rf \"$playground\"' EXIT\n \n ## Collapse driver\n \n-# Trusty Cogito code:\n-load_author()\n-{\n-\tif [ -z \"$GIT_AUTHOR_NAME\" ] && echo \"$1\" | grep -q '^[^< ]'; then\n-\t\texport GIT_AUTHOR_NAME=\"$(echo \"$1\" | sed 's/ *<.*//')\"\n-\tfi\n-\tif [ -z \"$GIT_AUTHOR_EMAIL\" ] && echo \"$1\" | grep -q '<.*>'; then\n-\t\texport GIT_AUTHOR_EMAIL=\"$(echo \"$1\" | sed 's/.*<\\(.*\\)>.*/\\1/')\"\n-\tfi\n-}\n-\n # pretty_tree NAME\n # Output tree ID of a cleaned-up tree without tg's artifacts.\n pretty_tree()\n@@ -69,19 +58,16 @@ collapsed_commit()\n \t>\"$playground/^body\"\n \n \t# Get commit message and authorship information\n-\tgit cat-file blob \"$name:.topmsg\" >\"$playground/^msg\"\n-\twhile read line; do\n-\t\tif [ -z \"$line\" ]; then\n-\t\t\t# end of header\n-\t\t\tcat >\"$playground/^body\"\n-\t\t\tbreak\n-\t\tfi\n-\t\tcase \"$line\" in\n-\t\tFrom:*) load_author \"${line#From: }\";;\n-\t\tSubject:*) echo \"${line#Subject: }\" >>\"$playground/^pre\";;\n-\t\t*) echo \"$line\" >>\"$playground/^post\";;\n-\t\tesac\n-\tdone <\"$playground/^msg\"\n+\tgit cat-file blob \"$name:.topmsg\" | git mailinfo \"$playground/^msg\" /dev/null > \"$playground/^info\"\n+\n+\tGIT_AUTHOR_NAME=\"$(sed -n '/^Author/ s/Author: //p' \"$playground/^info\")\"\n+\tGIT_AUTHOR_EMAIL=\"$(sed -n '/^Email/ s/Email: //p' \"$playground/^info\")\"\n+\tGIT_AUTHOR_DATE=\"$(sed -n '/^Date/ s/Date: //p' \"$playground/^info\")\"\n+\tSUBJECT=\"$(sed -n '/^Subject/ s/Subject: //p' \"$playground/^info\")\"\n+\n+\ttest -n \"$GIT_AUTHOR_NAME\" && export GIT_AUTHOR_NAME\n+\ttest -n \"$GIT_AUTHOR_EMAIL\" && export GIT_AUTHOR_EMAIL\n+\ttest -n \"$GIT_AUTHOR_DATE\" && export GIT_AUTHOR_DATE\n \n \t# Determine parent\n \tparent=\"$(cut -f 1 \"$playground/$name^parents\")\"\n@@ -95,14 +81,9 @@ collapsed_commit()\n \t\t\t$(for p in $parent; do echo -p $p; done))\"\n \tfi\n \n-\t{\n-\t\tif [ -s \"$playground/^pre\" ]; then\n-\t\t\tcat \"$playground/^pre\"\n-\t\t\techo\n-\t\tfi\n-\t\tcat \"$playground/^body\"\n-\t\t[ ! -s \"$playground/^post\" ] || cat \"$playground/^post\"\n-\t} | git commit-tree \"$(pretty_tree \"$name\")\" -p \"$parent\"\n+\t(printf '%s\\n\\n' \"$SUBJECT\"; cat \"$playground/^msg\") |\n+\tgit stripspace |\n+\tgit commit-tree \"$(pretty_tree \"$name\")\" -p \"$parent\"\n \n \techo \"$name\" >>\"$playground/^ticker\"\n }\n-- \n1.5.6.5\n"}]}