git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [TopGit PATCH 1/2] Factor out the template generation for the .topmsg file
@ 2008-08-08 18:19 Bert Wesarg
  2008-08-08 18:19 ` [TopGit PATCH 2/2] tg-import.sh: A dump quilt queue importer Bert Wesarg
  0 siblings, 1 reply; 4+ messages in thread
From: Bert Wesarg @ 2008-08-08 18:19 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Bert Wesarg, git

Provide a function for the .topmsg template file.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 tg-create.sh |   29 ++---------------------------
 tg.sh        |   30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/tg-create.sh b/tg-create.sh
index d47959b..e30a014 100644
--- a/tg-create.sh
+++ b/tg-create.sh
@@ -100,33 +100,8 @@ git checkout -b "$name"
 echo "$deps" | sed 's/ /\n/g' >"$root_dir/.topdeps"
 git add "$root_dir/.topdeps"
 
-# Print each config value for a key ($1, without "topgit." prefix)
-# with the given prefix ($2)
-get_multi_config()
-{
-	# escape any / in prefix for sed
-	prefix="$(echo "$2" | sed -e 's/\//\\\\\//g')"
-
-	git config --get-all topgit.$1 2>/dev/null |
-		sed -e "s/^/$prefix /g"
-}
-
-author="$(git var GIT_AUTHOR_IDENT)"
-author_addr="${author%> *}>"
-{
-	echo "From: $author_addr"
-	get_multi_config to  "To:"
-	get_multi_config cc  "Cc:"
-	get_multi_config bcc "Bcc:"
-	! subject_prefix="$(git config topgit.subjectprefix)" || subject_prefix="$subject_prefix "
-	echo "Subject: [${subject_prefix}PATCH] $name"
-	echo
-	cat <<EOT
-<patch description>
-
-Signed-off-by: $author_addr
-EOT
-} >"$root_dir/.topmsg"
+echo "<patch description>" |
+	make_topmsg "$name" >"$root_dir/.topmsg"
 git add "$root_dir/.topmsg"
 
 
diff --git a/tg.sh b/tg.sh
index 03a392b..8384b79 100644
--- a/tg.sh
+++ b/tg.sh
@@ -148,6 +148,36 @@ switch_to_base()
 	git symbolic-ref HEAD "$_base"
 }
 
+# Print each config value for a key ($1, without "topgit." prefix)
+# with the given prefix ($2)
+get_multi_config()
+{
+	# escape any / in prefix for sed
+	prefix="$(echo "$2" | sed -e 's/\//\\\\\//g')"
+
+	git config --get-all topgit.$1 2>/dev/null |
+		sed -e "s/^/$prefix /g"
+}
+
+# Make initial .topmsg template with content from stdin
+# optional first argument is subject line
+make_topmsg()
+{
+	author="$(git var GIT_AUTHOR_IDENT)"
+	author_addr="${author%> *}>"
+
+	echo "From: $author_addr"
+	get_multi_config to  "To:"
+	get_multi_config cc  "Cc:"
+	get_multi_config bcc "Bcc:"
+	! subject_prefix="$(git config topgit.subjectprefix)" || subject_prefix="$subject_prefix "
+	echo "Subject: [${subject_prefix}PATCH] $1"
+	echo
+	cat
+	echo
+	echo "Signed-off-by: $author_addr"
+}
+
 # Show the help messages.
 do_help()
 {
-- 
tg: (2a28314..) t/make-.topmsg-gen-a-function (depends on: t/support-for-multiple-to-cc-bcc-options)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-09  8:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-08 18:19 [TopGit PATCH 1/2] Factor out the template generation for the .topmsg file Bert Wesarg
2008-08-08 18:19 ` [TopGit PATCH 2/2] tg-import.sh: A dump quilt queue importer Bert Wesarg
2008-08-09  0:57   ` Petr Baudis
2008-08-09  7:56     ` Bert Wesarg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).