1
0
mirror of https://github.com/git/git.git synced 2024-09-28 11:11:18 +02:00

git-mailinfo: add --message-id

This option adds the content of the Message-Id header at the end of the
commit message prepared by git-mailinfo.  This is useful in order to
associate commit messages automatically with mailing list discussions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Paolo Bonzini 2014-11-25 15:00:55 +01:00 committed by Junio C Hamano
parent 652e759330
commit 452dfbed1a
6 changed files with 73 additions and 1 deletions

View File

@ -66,6 +66,11 @@ conversion, even with this flag.
-n::
Disable all charset re-coding of the metadata.
-m::
--message-id::
Copy the Message-ID header at the end of the commit message. This
is useful in order to associate commits with mailing list discussions.
--scissors::
Remove everything in body before a scissors line. A line that
mainly consists of scissors (either ">8" or "8<") and perforation

View File

@ -15,6 +15,7 @@ static const char *metainfo_charset;
static struct strbuf line = STRBUF_INIT;
static struct strbuf name = STRBUF_INIT;
static struct strbuf email = STRBUF_INIT;
static char *message_id;
static enum {
TE_DONTCARE, TE_QP, TE_BASE64
@ -24,6 +25,7 @@ static struct strbuf charset = STRBUF_INIT;
static int patch_lines;
static struct strbuf **p_hdr_data, **s_hdr_data;
static int use_scissors;
static int add_message_id;
static int use_inbody_headers = 1;
#define MAX_HDR_PARSED 10
@ -198,6 +200,12 @@ static void handle_content_type(struct strbuf *line)
}
}
static void handle_message_id(const struct strbuf *line)
{
if (add_message_id)
message_id = strdup(line->buf);
}
static void handle_content_transfer_encoding(const struct strbuf *line)
{
if (strcasestr(line->buf, "base64"))
@ -342,6 +350,14 @@ static int check_header(const struct strbuf *line,
ret = 1;
goto check_header_out;
}
if (cmp_header(line, "Message-Id")) {
len = strlen("Message-Id: ");
strbuf_add(&sb, line->buf + len, line->len - len);
decode_header(&sb);
handle_message_id(&sb);
ret = 1;
goto check_header_out;
}
/* for inbody stuff */
if (starts_with(line->buf, ">From") && isspace(line->buf[5])) {
@ -816,6 +832,8 @@ static int handle_commit_msg(struct strbuf *line)
}
if (patchbreak(line)) {
if (message_id)
fprintf(cmitmsg, "Message-Id: %s\n", message_id);
fclose(cmitmsg);
cmitmsg = NULL;
return 1;
@ -1013,7 +1031,7 @@ static int git_mailinfo_config(const char *var, const char *value, void *unused)
}
static const char mailinfo_usage[] =
"git mailinfo [-k|-b] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] msg patch < mail >info";
"git mailinfo [-k|-b] [-m | --message-id] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] msg patch < mail >info";
int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
@ -1032,6 +1050,8 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
keep_subject = 1;
else if (!strcmp(argv[1], "-b"))
keep_non_patch_brackets_in_subject = 1;
else if (!strcmp(argv[1], "-m") || !strcmp(argv[1], "--message-id"))
add_message_id = 1;
else if (!strcmp(argv[1], "-u"))
metainfo_charset = def_charset;
else if (!strcmp(argv[1], "-n"))

View File

@ -35,6 +35,10 @@ do
then
check_mailinfo $mail --no-inbody-headers
fi
if test -f "$TEST_DIRECTORY"/t5100/msg$mail--message-id
then
check_mailinfo $mail --message-id
fi
'
done

View File

@ -0,0 +1,5 @@
Author: Dmitriy Blinov
Email: bda@mnsspb.ru
Subject: Изменён список пакетов необходимых для сборки
Date: Wed, 12 Nov 2008 17:54:41 +0300

View File

@ -0,0 +1,8 @@
textlive-* исправлены на texlive-*
docutils заменён на python-docutils
Действительно, оказалось, что rest2web вытягивает за собой
python-docutils. В то время как сам rest2web не нужен.
Signed-off-by: Dmitriy Blinov <bda@mnsspb.ru>
Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru>

View File

@ -0,0 +1,30 @@
---
howto/build_navy.txt | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/howto/build_navy.txt b/howto/build_navy.txt
index 3fd3afb..0ee807e 100644
--- a/howto/build_navy.txt
+++ b/howto/build_navy.txt
@@ -119,8 +119,8 @@
- libxv-dev
- libusplash-dev
- latex-make
- - textlive-lang-cyrillic
- - textlive-latex-extra
+ - texlive-lang-cyrillic
+ - texlive-latex-extra
- dia
- python-pyrex
- libtool
@@ -128,7 +128,7 @@
- sox
- cython
- imagemagick
- - docutils
+ - python-docutils
#. на машине dinar: добавить свой открытый ssh-ключ в authorized_keys2 пользователя ddev
#. на своей машине: отредактировать /etc/sudoers (команда ``visudo``) примерно следующим образом::
--
1.5.6.5