* [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log
@ 2014-07-02 14:51 Avi Kivity
2014-07-02 15:03 ` Torsten Bögershausen
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2014-07-02 14:51 UTC (permalink / raw)
To: git
Some workflows prefer to track exactly which email message was used to
generate a commit. This can be used, for example, to generate an
automated acknowledgement when a patch is committed as a response to
the patch email, or as a reference to the thread which introduced the
patch.
Support this by adding a --message-id option (abbreviated as -m) to
git-am, which will then extract the message ID and append it to the
email commit log.
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
---
v4: adjust coding style
recover message_id variable after a resumed git-am
use sane_grep
drop unneeded grep error handling
v3: remove bashism and unneeded quoting
v2: adjust to pass test suite (t5100)
Documentation/git-am.txt | 6 ++++++
builtin/mailinfo.c | 2 +-
git-am.sh | 14 +++++++++++++-
t/t5100/info0004 | 1 +
t/t5100/info0005 | 1 +
t/t5100/info0012 | 1 +
6 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 9adce37..8a251a1 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -15,6 +15,7 @@ SYNOPSIS
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
[--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
+ [--message-id]
[(<mbox> | <Maildir>)...]
'git am' (--continue | --skip | --abort)
@@ -121,6 +122,11 @@ default. You can use `--no-utf8` to override this.
user to lie about the author date by using the same
value as the committer date.
+-m::
+--message-id::
+ Extract the Message-Id: header from the e-mail and
+ append it to the commit message's tag stanza.
+
--skip::
Skip the current patch. This is only meaningful when
restarting an aborted patch.
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index cf11c8d..f1e1fed 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -278,7 +278,7 @@ static void cleanup_space(struct strbuf *sb)
static void decode_header(struct strbuf *line);
static const char *header[MAX_HDR_PARSED] = {
- "From","Subject","Date",
+ "From","Subject","Date","Message-Id"
};
static inline int cmp_header(const struct strbuf *line, const char *hdr)
diff --git a/git-am.sh b/git-am.sh
index ee61a77..fd0181f 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -39,6 +39,7 @@ committer-date-is-author-date lie about committer date
ignore-date use current timestamp for author date
rerere-autoupdate update the index with reused conflict resolution if possible
S,gpg-sign? GPG-sign commits
+m,message-id copy the Message-Id: header to the commit's tag stanza
rebasing* (internal use for git-rebase)"
. git-sh-setup
@@ -371,7 +372,7 @@ split_patches () {
prec=4
dotest="$GIT_DIR/rebase-apply"
sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=
-resolvemsg= resume= scissors= no_inbody_headers=
+resolvemsg= resume= scissors= no_inbody_headers= message_id=
git_apply_opt=
committer_date_is_author_date=
ignore_date=
@@ -442,6 +443,8 @@ it will be removed. Please do not use it anymore."
gpg_sign_opt=-S ;;
--gpg-sign=*)
gpg_sign_opt="-S${1#--gpg-sign=}" ;;
+ -m|--message-id)
+ message_id=t ;;
--)
shift; break ;;
*)
@@ -565,6 +568,7 @@ Use \"git am --abort\" to remove it.")"
echo " $git_apply_opt" >"$dotest/apply-opt"
echo "$threeway" >"$dotest/threeway"
echo "$sign" >"$dotest/sign"
+ echo "$message_id" >"$dotest/message-id"
echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep"
echo "$scissors" >"$dotest/scissors"
@@ -651,6 +655,10 @@ then
else
SIGNOFF=
fi
+if test "$(cat "$dotest/message-id")" = t
+then
+ message_id=t
+fi
last=$(cat "$dotest/last")
this=$(cat "$dotest/next")
@@ -757,6 +765,10 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."
then
cat "$dotest/msg-clean"
fi
+ if test t = "$message_id"
+ then
+ sane_grep ^Message-Id: "$dotest/info"
+ fi
if test '' != "$ADD_SIGNOFF"
then
echo "$ADD_SIGNOFF"
diff --git a/t/t5100/info0004 b/t/t5100/info0004
index 616c309..f7e2983 100644
--- a/t/t5100/info0004
+++ b/t/t5100/info0004
@@ -2,4 +2,5 @@ Author: YOSHIFUJI Hideaki / 吉藤英明
Email: yoshfuji@linux-ipv6.org
Subject: GIT: Try all addresses for given remote name
Date: Thu, 21 Jul 2005 09:10:36 -0400 (EDT)
+Message-Id: <20050721.091036.01119516.yoshfuji@linux-ipv6.org>
diff --git a/t/t5100/info0005 b/t/t5100/info0005
index 46a46fc..592388f 100644
--- a/t/t5100/info0005
+++ b/t/t5100/info0005
@@ -2,4 +2,5 @@ Author: David Kågedal
Email: davidk@lysator.liu.se
Subject: Fixed two bugs in git-cvsimport-script.
Date: Mon, 15 Aug 2005 20:18:25 +0200
+Message-Id: <u5tacjjdpxq.fsf@lysator.liu.se>
diff --git a/t/t5100/info0012 b/t/t5100/info0012
index ac1216f..b5d89a1 100644
--- a/t/t5100/info0012
+++ b/t/t5100/info0012
@@ -2,4 +2,5 @@ Author: Dmitriy Blinov
Email: bda@mnsspb.ru
Subject: Изменён список пакетов необходимых для сборки
Date: Wed, 12 Nov 2008 17:54:41 +0300
+Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru>
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log
2014-07-02 14:51 [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log Avi Kivity
@ 2014-07-02 15:03 ` Torsten Bögershausen
2014-07-02 16:15 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Torsten Bögershausen @ 2014-07-02 15:03 UTC (permalink / raw)
To: Avi Kivity, git
> diff --git a/git-am.sh b/git-am.sh
> index ee61a77..fd0181f 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -39,6 +39,7 @@ committer-date-is-author-date lie about committer date
> ignore-date use current timestamp for author date
> rerere-autoupdate update the index with reused conflict resolution if possible
> S,gpg-sign? GPG-sign commits
> +m,message-id copy the Message-Id: header to the commit's tag stanza
> rebasing* (internal use for git-rebase)"
>
> . git-sh-setup
> @@ -371,7 +372,7 @@ split_patches () {
> prec=4
> dotest="$GIT_DIR/rebase-apply"
> sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=
> -resolvemsg= resume= scissors= no_inbody_headers=
> +resolvemsg= resume= scissors= no_inbody_headers= message_id=
> git_apply_opt=
> committer_date_is_author_date=
> ignore_date=
> @@ -442,6 +443,8 @@ it will be removed. Please do not use it anymore."
> gpg_sign_opt=-S ;;
> --gpg-sign=*)
> gpg_sign_opt="-S${1#--gpg-sign=}" ;;
> + -m|--message-id)
> + message_id=t ;;
> --)
> shift; break ;;
> *)
> @@ -565,6 +568,7 @@ Use \"git am --abort\" to remove it.")"
> echo " $git_apply_opt" >"$dotest/apply-opt"
> echo "$threeway" >"$dotest/threeway"
> echo "$sign" >"$dotest/sign"
> + echo "$message_id" >"$dotest/message-id"
> echo "$utf8" >"$dotest/utf8"
> echo "$keep" >"$dotest/keep"
> echo "$scissors" >"$dotest/scissors"
> @@ -651,6 +655,10 @@ then
> else
> SIGNOFF=
> fi
> +if test "$(cat "$dotest/message-id")" = t
Does the usage of '"' inside of '"' look good, or can we write like this:
if test $(cat "$dotest/message-id") = t
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log
2014-07-02 15:03 ` Torsten Bögershausen
@ 2014-07-02 16:15 ` Avi Kivity
0 siblings, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2014-07-02 16:15 UTC (permalink / raw)
To: Torsten Bögershausen, git
On 07/02/2014 06:03 PM, Torsten Bögershausen wrote:
>> @@ -565,6 +568,7 @@ Use \"git am --abort\" to remove it.")"
>> echo " $git_apply_opt" >"$dotest/apply-opt"
>> echo "$threeway" >"$dotest/threeway"
>> echo "$sign" >"$dotest/sign"
>> + echo "$message_id" >"$dotest/message-id"
>> echo "$utf8" >"$dotest/utf8"
>> echo "$keep" >"$dotest/keep"
>> echo "$scissors" >"$dotest/scissors"
>> @@ -651,6 +655,10 @@ then
>> else
>> SIGNOFF=
>> fi
>> +if test "$(cat "$dotest/message-id")" = t
> Does the usage of '"' inside of '"' look good, or can we write like this:
> if test $(cat "$dotest/message-id") = t
With your change, it will fail if the file is missing or empty.
Complex shell scripts cannot be made to look good. If that's a
requirement then the script should be rewritten in a reasonable language.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-02 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-02 14:51 [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log Avi Kivity
2014-07-02 15:03 ` Torsten Bögershausen
2014-07-02 16:15 ` Avi Kivity
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).