From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Petr Baudis <pasky@suse.cz>
To: Petr Baudis <pasky@suse.cz>
Cc: Bert Wesarg <bert.wesarg@googlemail.com>, git@vger.kernel.org
Subject: [TopGit PATCH] tg-patch: add From/Date: line to header and print to file
Date: Fri, 19 Sep 2008 11:55:01 +0200 [thread overview]
Message-ID: <1221818101-14333-2-git-send-email-bert.wesarg@googlemail.com> (raw)
In-Reply-To: <1221818101-14333-1-git-send-email-bert.wesarg@googlemail.com>
To make this more similar to git format-patch, I added a 'From' and
a 'Date:' header and let 'tg patch' print to a file (which is shown as output).
Regards
Bert
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
tg-patch.sh | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/tg-patch.sh b/tg-patch.sh
index 7a24718..5fc5cfd 100644
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -24,7 +24,26 @@ done
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"
-git cat-file blob "$name:.topmsg"
+subject="$(git cat-file blob "$name:.topmsg" | grep '^Subject: ' | sed -e 's/^Subject: //' -e 's/\[.*\] //')"
+file_name="$(echo "$subject" | tr -c '[[:alnum:]_.]' '_').patch"
+rev="$(git rev-parse --verify "refs/heads/$name" 2>/dev/null)"
+
+echo "$file_name"
+exec 3>&1
+exec 1>"$file_name"
+
+printf "From %s Mon Sep 17 00:00:00 2001\n" "$rev"
+now="$(date --rfc-2822)"
+git cat-file blob "$name:.topmsg" |
+ awk '
+ {
+ print
+ if (/^From:/ && !date_printed) {
+ printf "Date: %s\n", "'"$now"'"
+ date_printed = 1
+ }
+ }
+ '
echo
[ -n "$(git grep '^[-]--' "$name" -- ".topmsg")" ] || echo '---'
@@ -42,5 +61,9 @@ rm "$git_is_stupid"
echo '-- '
echo "tg: ($base_rev..) $name (depends on: $(git cat-file blob "$name:.topdeps" | paste -s -d' '))"
+
+exec 1>&3
+exec 3>&-
+
branch_contains "$name" "$base_rev" ||
echo "tg: The patch is out-of-date wrt. the base! Run \`$tg update\`."
--
tg: (7ec3927..) t/patch (depends on: t/queue-movement)
next prev parent reply other threads:[~2008-09-19 9:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-19 9:55 [TopGit PATCH] prev/next/tsort: commands to explore dependencies Bert Wesarg
2008-09-19 9:55 ` Bert Wesarg [this message]
2008-09-22 15:39 ` [TopGit PATCH] tg-patch: add From/Date: line to header and print to file Petr Baudis
2008-09-22 18:10 ` Bert Wesarg
2008-09-22 15:36 ` [TopGit PATCH] prev/next/tsort: commands to explore dependencies Petr Baudis
2008-09-22 17:32 ` Bert Wesarg
2008-09-22 20:10 ` Uwe Kleine-König
2008-09-22 20:18 ` Bert Wesarg
2008-09-24 15:23 ` Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1221818101-14333-2-git-send-email-bert.wesarg@googlemail.com \
--to=bert.wesarg@googlemail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).