[PATCH 0/2] git-am: add --message-id/--no-message-id options

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/2] git-am: add --message-id/--no-message-id options

Paolo Bonzini-2
From: Paolo Bonzini <[hidden email]>

This series adds a --message-id option to git-mailinfo and git-am.
git-am also gets an am.messageid configuration key to set the default,
and a --no-message-id option to override the configuration key.
(I'm not sure of the usefulness of a mailinfo.messageid option, so
I left it out; this follows the example of -k instead of --scissors).

This option can be useful in order to associate commit messages with
mailing list discussions.

If both --message-id and -s are specified, the Signed-off-by goes
last.  This is coming out more or less naturally out of the git-am
implementation, but is also tested in t4150-am.sh.

Paolo Bonzini (2):
  git-mailinfo: add --message-id
  git-am: add --message-id/--no-message-id

 Documentation/git-am.txt       | 11 +++++++++++
 Documentation/git-mailinfo.txt |  5 +++++
 builtin/mailinfo.c             | 22 +++++++++++++++++++++-
 git-am.sh                      | 21 +++++++++++++++++++--
 t/t4150-am.sh                  | 23 +++++++++++++++++++++++
 t/t5100-mailinfo.sh            |  4 ++++
 t/t5100/info0012--message-id   |  5 +++++
 t/t5100/msg0012--message-id    |  8 ++++++++
 t/t5100/patch0012--message-id  | 30 ++++++++++++++++++++++++++++++
 9 files changed, 126 insertions(+), 3 deletions(-)
 create mode 100644 t/t5100/info0012--message-id
 create mode 100644 t/t5100/msg0012--message-id
 create mode 100644 t/t5100/patch0012--message-id

--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] git-mailinfo: add --message-id

Paolo Bonzini-2
From: Paolo Bonzini <[hidden email]>

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 <[hidden email]>
---
 Documentation/git-mailinfo.txt |  5 +++++
 builtin/mailinfo.c             | 22 +++++++++++++++++++++-
 t/t5100-mailinfo.sh            |  4 ++++
 t/t5100/info0012--message-id   |  5 +++++
 t/t5100/msg0012--message-id    |  8 ++++++++
 t/t5100/patch0012--message-id  | 30 ++++++++++++++++++++++++++++++
 6 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 t/t5100/info0012--message-id
 create mode 100644 t/t5100/msg0012--message-id
 create mode 100644 t/t5100/patch0012--message-id

diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
index 164a3c6..2e99603 100644
--- a/Documentation/git-mailinfo.txt
+++ b/Documentation/git-mailinfo.txt
@@ -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
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 6a14d29..c8a47c1 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -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"))
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 9e1ad1c..60df10f 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -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
 
diff --git a/t/t5100/info0012--message-id b/t/t5100/info0012--message-id
new file mode 100644
index 0000000..ac1216f
--- /dev/null
+++ b/t/t5100/info0012--message-id
@@ -0,0 +1,5 @@
+Author: Dmitriy Blinov
+Email: [hidden email]
+Subject: Изменён список пакетов необходимых для сборки
+Date: Wed, 12 Nov 2008 17:54:41 +0300
+
diff --git a/t/t5100/msg0012--message-id b/t/t5100/msg0012--message-id
new file mode 100644
index 0000000..376e26e
--- /dev/null
+++ b/t/t5100/msg0012--message-id
@@ -0,0 +1,8 @@
+textlive-* исправлены на texlive-*
+docutils заменён на python-docutils
+
+Действительно, оказалось, что rest2web вытягивает за собой
+python-docutils. В то время как сам rest2web не нужен.
+
+Signed-off-by: Dmitriy Blinov <[hidden email]>
+Message-Id: <[hidden email]>
diff --git a/t/t5100/patch0012--message-id b/t/t5100/patch0012--message-id
new file mode 100644
index 0000000..36a0b68
--- /dev/null
+++ b/t/t5100/patch0012--message-id
@@ -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
--
2.1.0


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] git-am: add --message-id/--no-message-id

Paolo Bonzini-2
In reply to this post by Paolo Bonzini-2
From: Paolo Bonzini <[hidden email]>

Parse the option and pass it directly to git-mailinfo.

Signed-off-by: Paolo Bonzini <[hidden email]>
---
 Documentation/git-am.txt | 11 +++++++++++
 git-am.sh                | 21 +++++++++++++++++++--
 t/t4150-am.sh            | 23 +++++++++++++++++++++++
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 9adce37..cfb74bc 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -57,6 +57,17 @@ OPTIONS
 --no-scissors::
  Ignore scissors lines (see linkgit:git-mailinfo[1]).
 
+-m::
+--message-id::
+ Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]),
+ so that the Message-ID header is added to the commit message.
+ The `am.messageid` configuration variable can be used to specify
+ the default behaviour.
+
+--no-message-id::
+ Do not add the Message-ID header to the commit message.
+ `no-message-id` is useful to override `am.messageid`.
+
 -q::
 --quiet::
  Be quiet. Only print error messages.
diff --git a/git-am.sh b/git-am.sh
index ee61a77..c92632f 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -17,6 +17,7 @@ s,signoff       add a Signed-off-by line to the commit message
 u,utf8          recode into utf8 (default)
 k,keep          pass -k flag to git-mailinfo
 keep-non-patch  pass -b flag to git-mailinfo
+m,message-id    pass -m flag to git-mailinfo
 keep-cr         pass --keep-cr flag to git-mailsplit for mbox format
 no-keep-cr      do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
 c,scissors      strip everything before a scissors line
@@ -371,13 +372,18 @@ 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=
+messageid= resolvemsg= resume= scissors= no_inbody_headers=
 git_apply_opt=
 committer_date_is_author_date=
 ignore_date=
 allow_rerere_autoupdate=
 gpg_sign_opt=
 
+if test "$(git config --bool --get am.messageid)" = true
+then
+    messageid=t
+fi
+
 if test "$(git config --bool --get am.keepcr)" = true
 then
     keepcr=t
@@ -400,6 +406,10 @@ it will be removed. Please do not use it anymore."
  utf8=t ;; # this is now default
  --no-utf8)
  utf8= ;;
+ -m|--message-id)
+ messageid=t ;;
+ --no-message-id)
+ messageid=f ;;
  -k|--keep)
  keep=t ;;
  --keep-non-patch)
@@ -567,6 +577,7 @@ Use \"git am --abort\" to remove it.")"
  echo "$sign" >"$dotest/sign"
  echo "$utf8" >"$dotest/utf8"
  echo "$keep" >"$dotest/keep"
+ echo "$messageid" >"$dotest/messageid"
  echo "$scissors" >"$dotest/scissors"
  echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
  echo "$GIT_QUIET" >"$dotest/quiet"
@@ -621,6 +632,12 @@ b)
 *)
  keep= ;;
 esac
+case "$(cat "$dotest/messageid")" in
+t)
+ messageid=-m ;;
+f)
+ messageid= ;;
+esac
 case "$(cat "$dotest/scissors")" in
 t)
  scissors=--scissors ;;
@@ -692,7 +709,7 @@ do
  get_author_ident_from_commit "$commit" >"$dotest/author-script"
  git diff-tree --root --binary --full-index "$commit" >"$dotest/patch"
  else
- git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
+ git mailinfo $keep $no_inbody_headers $messageid $scissors $utf8 "$dotest/msg" "$dotest/patch" \
  <"$dotest/$msgnum" >"$dotest/info" ||
  stop_here $this
 
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 5edb79a..306e6f3 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -85,6 +85,7 @@ test_expect_success setup '
 
  git format-patch --stdout first >patch1 &&
  {
+ echo "Message-Id: <[hidden email]>" &&
  echo "X-Fake-Field: Line One" &&
  echo "X-Fake-Field: Line Two" &&
  echo "X-Fake-Field: Line Three" &&
@@ -536,4 +537,26 @@ test_expect_success 'am empty-file does not infloop' '
  test_i18ncmp expected actual
 '
 
+test_expect_success 'am --message-id really adds the message id' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout HEAD^ &&
+ git am --message-id patch1.eml &&
+ test_path_is_missing .git/rebase-apply &&
+ git cat-file commit HEAD | tail -n1 >actual &&
+ grep Message-Id patch1.eml >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success 'am --message-id -s signs off after the message id' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout HEAD^ &&
+ git am -s --message-id patch1.eml &&
+ test_path_is_missing .git/rebase-apply &&
+ git cat-file commit HEAD | tail -n2 | head -n1 >actual &&
+ grep Message-Id patch1.eml >expected &&
+ test_cmp expected actual
+'
+
 test_done
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Christian Couder-2
In reply to this post by Paolo Bonzini-2
On Tue, Nov 25, 2014 at 3:00 PM, Paolo Bonzini <[hidden email]> wrote:

> From: Paolo Bonzini <[hidden email]>
>
> This series adds a --message-id option to git-mailinfo and git-am.
> git-am also gets an am.messageid configuration key to set the default,
> and a --no-message-id option to override the configuration key.
> (I'm not sure of the usefulness of a mailinfo.messageid option, so
> I left it out; this follows the example of -k instead of --scissors).
>
> This option can be useful in order to associate commit messages with
> mailing list discussions.
>
> If both --message-id and -s are specified, the Signed-off-by goes
> last.  This is coming out more or less naturally out of the git-am
> implementation, but is also tested in t4150-am.sh.

Did you have a look at git interpret-trailers currently in master?

Best,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Paolo Bonzini


On 25/11/2014 17:27, Christian Couder wrote:

>> > From: Paolo Bonzini <[hidden email]>
>> >
>> > This series adds a --message-id option to git-mailinfo and git-am.
>> > git-am also gets an am.messageid configuration key to set the default,
>> > and a --no-message-id option to override the configuration key.
>> > (I'm not sure of the usefulness of a mailinfo.messageid option, so
>> > I left it out; this follows the example of -k instead of --scissors).
>> >
>> > This option can be useful in order to associate commit messages with
>> > mailing list discussions.
>> >
>> > If both --message-id and -s are specified, the Signed-off-by goes
>> > last.  This is coming out more or less naturally out of the git-am
>> > implementation, but is also tested in t4150-am.sh.
> Did you have a look at git interpret-trailers currently in master?

Hmm, now I have.

As far as I understand, all the git-am hooks are called on the commit
rather than the incoming email: all headers are lost by the time
git-mailinfo exits, including the Message-Id.  And you cannot call any
hook before git-mailinfo because git-mailinfo is where the
Content-Transfer-Encoding is processed.

How would you integrate git-interpret-trailers in git-mailinfo?

Paolo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Junio C Hamano
In reply to this post by Paolo Bonzini-2
Paolo Bonzini <[hidden email]> writes:

> From: Paolo Bonzini <[hidden email]>
>
> This series adds a --message-id option to git-mailinfo and git-am.
> git-am also gets an am.messageid configuration key to set the default,
> and a --no-message-id option to override the configuration key.
> (I'm not sure of the usefulness of a mailinfo.messageid option, so
> I left it out; this follows the example of -k instead of --scissors).
>
> This option can be useful in order to associate commit messages with
> mailing list discussions.
>
> If both --message-id and -s are specified, the Signed-off-by goes
> last.  This is coming out more or less naturally out of the git-am
> implementation, but is also tested in t4150-am.sh.

Nice.  So if you apply a message whose last sign-off is yourself
with both of these options, what would we see?

    1. S-o-b: you and then M-id: and then another S-o-b: you?
    2. M-id: and then S-o-b: you?
    3. S-o-b: you and then M-id:?

I do not offhand know which one of the above possibilities to favor
more over others myself.  Just asking to find out more about the
thinking behind the design.

Thanks.

>
> Paolo Bonzini (2):
>   git-mailinfo: add --message-id
>   git-am: add --message-id/--no-message-id
>
>  Documentation/git-am.txt       | 11 +++++++++++
>  Documentation/git-mailinfo.txt |  5 +++++
>  builtin/mailinfo.c             | 22 +++++++++++++++++++++-
>  git-am.sh                      | 21 +++++++++++++++++++--
>  t/t4150-am.sh                  | 23 +++++++++++++++++++++++
>  t/t5100-mailinfo.sh            |  4 ++++
>  t/t5100/info0012--message-id   |  5 +++++
>  t/t5100/msg0012--message-id    |  8 ++++++++
>  t/t5100/patch0012--message-id  | 30 ++++++++++++++++++++++++++++++
>  9 files changed, 126 insertions(+), 3 deletions(-)
>  create mode 100644 t/t5100/info0012--message-id
>  create mode 100644 t/t5100/msg0012--message-id
>  create mode 100644 t/t5100/patch0012--message-id
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Paolo Bonzini-2


On 25/11/2014 19:33, Junio C Hamano wrote:

>> > If both --message-id and -s are specified, the Signed-off-by goes
>> > last.  This is coming out more or less naturally out of the git-am
>> > implementation, but is also tested in t4150-am.sh.
> Nice.  So if you apply a message whose last sign-off is yourself
> with both of these options, what would we see?
>
>     1. S-o-b: you and then M-id: and then another S-o-b: you?
>     2. M-id: and then S-o-b: you?
>     3. S-o-b: you and then M-id:?
>
> I do not offhand know which one of the above possibilities to favor
> more over others myself.  Just asking to find out more about the
> thinking behind the design.

You currently get (1), which is arguably the most precise but definitely
the ugliest.

In this case (posting as maintainer), I would probably not use "git am
--message-id"; instead I would use an alias to add the Message-Id (with
git interpret-trailers!) after posting to the mailing list, resulting in
either (2) or (3).

I think (but I am not sure) that git-am could use a hook to rewrite (1)
into (2) or (3).

Paolo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Junio C Hamano
Paolo Bonzini <[hidden email]> writes:

> On 25/11/2014 19:33, Junio C Hamano wrote:
>>> > If both --message-id and -s are specified, the Signed-off-by goes
>>> > last.  This is coming out more or less naturally out of the git-am
>>> > implementation, but is also tested in t4150-am.sh.
>> Nice.  So if you apply a message whose last sign-off is yourself
>> with both of these options, what would we see?
>>
>>     1. S-o-b: you and then M-id: and then another S-o-b: you?
>>     2. M-id: and then S-o-b: you?
>>     3. S-o-b: you and then M-id:?
>>
>> I do not offhand know which one of the above possibilities to favor
>> more over others myself.  Just asking to find out more about the
>> thinking behind the design.
>
> You currently get (1), which is arguably the most precise but definitely
> the ugliest.
>
> In this case (posting as maintainer), I would probably not use "git am
> --message-id"; instead I would use an alias to add the Message-Id (with
> git interpret-trailers!) after posting to the mailing list, resulting in
> either (2) or (3).
>
> I think (but I am not sure) that git-am could use a hook to rewrite (1)
> into (2) or (3).

I actually do not think (1) is more (or less for that matter) ugly
compared to either of the others.

Thanks.  Let's queue these two series for the next cycle.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Christian Couder-2
In reply to this post by Paolo Bonzini
On Tue, Nov 25, 2014 at 6:01 PM, Paolo Bonzini <[hidden email]> wrote:

>
>
> On 25/11/2014 17:27, Christian Couder wrote:
>>> > From: Paolo Bonzini <[hidden email]>
>>> >
>>> > This series adds a --message-id option to git-mailinfo and git-am.
>>> > git-am also gets an am.messageid configuration key to set the default,
>>> > and a --no-message-id option to override the configuration key.
>>> > (I'm not sure of the usefulness of a mailinfo.messageid option, so
>>> > I left it out; this follows the example of -k instead of --scissors).
>>> >
>>> > This option can be useful in order to associate commit messages with
>>> > mailing list discussions.
>>> >
>>> > If both --message-id and -s are specified, the Signed-off-by goes
>>> > last.  This is coming out more or less naturally out of the git-am
>>> > implementation, but is also tested in t4150-am.sh.
>> Did you have a look at git interpret-trailers currently in master?
>
> Hmm, now I have.
>
> As far as I understand, all the git-am hooks are called on the commit
> rather than the incoming email: all headers are lost by the time
> git-mailinfo exits, including the Message-Id.  And you cannot call any
> hook before git-mailinfo because git-mailinfo is where the
> Content-Transfer-Encoding is processed.
>
> How would you integrate git-interpret-trailers in git-mailinfo?

I don't know exactly, but people may want to add trailers when they
run git-am, see:

http://thread.gmane.org/gmane.comp.version-control.git/251412/

and we decided that it was better to let something like git
interpret-trailers decide how they should be handled.

Maybe if git-interpret-trailers could be called from git-mailinfo with
some arguments coming from git-am, it could be configured with
something like:

git config trailer.Message-Id.command 'perl -ne '\''print $1 if
m/^Message-Id: (.*)$/'\'' $ARG'

So "git am --trailer 'Message-Id: msg-file' msg-file" would call "git
mailinfo ..." that would call "git interpret-trailers --trailer
'Message-Id: msg-file'" that would call "perl -ne 'print $1 if
m/^Message-Id: (.*)$/' msg-file" and the output of this command, let's
call it $id, would be put into a "Message-Id: $id" trailer in the
commit message.

This way there is nothing specific to Message-Id in the code and
people can decide using other trailer.Message-Id.* config variables
exactly where the Message-Id trailer would be in the commit message.

Best,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] git-am: add --message-id/--no-message-id

Junio C Hamano
In reply to this post by Paolo Bonzini-2
Paolo Bonzini <[hidden email]> writes:

> @@ -371,13 +372,18 @@ 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=
> +messageid= resolvemsg= resume= scissors= no_inbody_headers=

It is somewhat irritating to read a diff that adds new things to the
beginning of anything (a line, or a block of lines) that lists
things in no particular order, as it just adds cognitive burden.

>  git_apply_opt=
>  committer_date_is_author_date=
>  ignore_date=
>  allow_rerere_autoupdate=
>  gpg_sign_opt=
>  
> +if test "$(git config --bool --get am.messageid)" = true
> +then
> +    messageid=t
> +fi
> +
>  if test "$(git config --bool --get am.keepcr)" = true
>  then
>      keepcr=t
> @@ -400,6 +406,10 @@ it will be removed. Please do not use it anymore."
>   utf8=t ;; # this is now default
>   --no-utf8)
>   utf8= ;;
> + -m|--message-id)
> + messageid=t ;;
> + --no-message-id)
> + messageid=f ;;

This one, taken together with these two hunks ...

>   -k|--keep)
>   keep=t ;;
>   --keep-non-patch)
> @@ -567,6 +577,7 @@ Use \"git am --abort\" to remove it.")"
>   echo "$sign" >"$dotest/sign"
>   echo "$utf8" >"$dotest/utf8"
>   echo "$keep" >"$dotest/keep"
> + echo "$messageid" >"$dotest/messageid"
>   echo "$scissors" >"$dotest/scissors"
>   echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
>   echo "$GIT_QUIET" >"$dotest/quiet"
> @@ -621,6 +632,12 @@ b)
>  *)
>   keep= ;;
>  esac
> +case "$(cat "$dotest/messageid")" in
> +t)
> + messageid=-m ;;
> +f)
> + messageid= ;;
> +esac

... makes the result look questionable.  The variable is initialized
to empty; when it is written out to $dotest/messageid and later read
back here, that empty value is not covered by this case statement.

Perhaps clearing messageid= upon seeing "--no-message-id" and using
"'t' or empty" makes the code a bit easier to follow?  I dunno.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] git-am: add --message-id/--no-message-id

Paolo Bonzini-2


On 26/11/2014 00:34, Junio C Hamano wrote:
> ... makes the result look questionable.  The variable is initialized
> to empty; when it is written out to $dotest/messageid and later read
> back here, that empty value is not covered by this case statement.
>
> Perhaps clearing messageid= upon seeing "--no-message-id" and using
> "'t' or empty" makes the code a bit easier to follow?  I dunno.

Possibly.  The other side is that it would be handled differently than
scissors and keep.  Changing everything is possible but would break
continuing a "git am" operation across an update, so I chose consistency.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Paolo Bonzini-2
In reply to this post by Christian Couder-2


On 25/11/2014 22:21, Christian Couder wrote:

> On Tue, Nov 25, 2014 at 6:01 PM, Paolo Bonzini <[hidden email]> wrote:
>>
>>
>> On 25/11/2014 17:27, Christian Couder wrote:
>>>>> From: Paolo Bonzini <[hidden email]>
>>>>>
>>>>> This series adds a --message-id option to git-mailinfo and git-am.
>>>>> git-am also gets an am.messageid configuration key to set the default,
>>>>> and a --no-message-id option to override the configuration key.
>>>>> (I'm not sure of the usefulness of a mailinfo.messageid option, so
>>>>> I left it out; this follows the example of -k instead of --scissors).
>>>>>
>>>>> This option can be useful in order to associate commit messages with
>>>>> mailing list discussions.
>>>>>
>>>>> If both --message-id and -s are specified, the Signed-off-by goes
>>>>> last.  This is coming out more or less naturally out of the git-am
>>>>> implementation, but is also tested in t4150-am.sh.
>>> Did you have a look at git interpret-trailers currently in master?
>>
>> Hmm, now I have.
>>
>> As far as I understand, all the git-am hooks are called on the commit
>> rather than the incoming email: all headers are lost by the time
>> git-mailinfo exits, including the Message-Id.  And you cannot call any
>> hook before git-mailinfo because git-mailinfo is where the
>> Content-Transfer-Encoding is processed.
>>
>> How would you integrate git-interpret-trailers in git-mailinfo?
>
> I don't know exactly, but people may want to add trailers when they
> run git-am, see:
>
> http://thread.gmane.org/gmane.comp.version-control.git/251412/
>
> and we decided that it was better to let something like git
> interpret-trailers decide how they should be handled.
>
> Maybe if git-interpret-trailers could be called from git-mailinfo with
> some arguments coming from git-am, it could be configured with
> something like:
>
> git config trailer.Message-Id.command 'perl -ne '\''print $1 if
> m/^Message-Id: (.*)$/'\'' $ARG'
>
> So "git am --trailer 'Message-Id: msg-file' msg-file" would call "git
> mailinfo ..." that would call "git interpret-trailers --trailer
> 'Message-Id: msg-file'" that would call "perl -ne 'print $1 if
> m/^Message-Id: (.*)$/' msg-file" and the output of this command, let's
> call it $id, would be put into a "Message-Id: $id" trailer in the
> commit message.

I think overloading trailer.Message-Id.command is not a good idea,
because it would prevent using "git interpret-trailers" to add a message
id manually ("git interpret-trailers --trailer message-id='<foo@bar>'").

Another possibility could be to add a third output file to git-mailinfo,
including all the headers.  Then a hook could be called with the headers
and commit message.

The question is: what would it be used for?  There aren't that many mail
headers, and most of them (From, Subject, Date) are recorded in the
commit anyway.  One idea could be to record who was a recipient of the
original message, even if no Cc line was added explicitly.  In most
projects, Cc is often added randomly, but I guess that's a valid
usecase.  I can certainly code the above hook instead of this approach
if Junio thinks it's better.

In the meanwhile, I have thought of a couple additions to "git
interpret-trailers" and I can submit patches for them.

Paolo

> This way there is nothing specific to Message-Id in the code and
> people can decide using other trailer.Message-Id.* config variables
> exactly where the Message-Id trailer would be in the commit message.
>
> Best,
> Christian.
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] git-am: add --message-id/--no-message-id options

Christian Couder-2
On Wed, Nov 26, 2014 at 10:07 AM, Paolo Bonzini <[hidden email]> wrote:

>
>
> On 25/11/2014 22:21, Christian Couder wrote:
>> On Tue, Nov 25, 2014 at 6:01 PM, Paolo Bonzini <[hidden email]> wrote:
>>>
>>> As far as I understand, all the git-am hooks are called on the commit
>>> rather than the incoming email: all headers are lost by the time
>>> git-mailinfo exits, including the Message-Id.  And you cannot call any
>>> hook before git-mailinfo because git-mailinfo is where the
>>> Content-Transfer-Encoding is processed.
>>>
>>> How would you integrate git-interpret-trailers in git-mailinfo?
>>
>> I don't know exactly, but people may want to add trailers when they
>> run git-am, see:
>>
>> http://thread.gmane.org/gmane.comp.version-control.git/251412/
>>
>> and we decided that it was better to let something like git
>> interpret-trailers decide how they should be handled.
>>
>> Maybe if git-interpret-trailers could be called from git-mailinfo with
>> some arguments coming from git-am, it could be configured with
>> something like:
>>
>> git config trailer.Message-Id.command 'perl -ne '\''print $1 if
>> m/^Message-Id: (.*)$/'\'' $ARG'
>>
>> So "git am --trailer 'Message-Id: msg-file' msg-file" would call "git
>> mailinfo ..." that would call "git interpret-trailers --trailer
>> 'Message-Id: msg-file'" that would call "perl -ne 'print $1 if
>> m/^Message-Id: (.*)$/' msg-file" and the output of this command, let's
>> call it $id, would be put into a "Message-Id: $id" trailer in the
>> commit message.
>
> I think overloading trailer.Message-Id.command is not a good idea,
> because it would prevent using "git interpret-trailers" to add a message
> id manually ("git interpret-trailers --trailer message-id='<foo@bar>'").

Well, it is possible to configure a trailer.Message-Id.command that
can detect if it is passed an existing file or not.
If it is passed an existing file, it could lookup the message id in
the file and print it, otherwise it would just print what it is
passed.

> Another possibility could be to add a third output file to git-mailinfo,
> including all the headers.  Then a hook could be called with the headers
> and commit message.

Yeah, but this hook could not do everything, because some people might
want to add trailers from the command line anyway.
So git interpret-trailers could be called once with the command line
arguments and once inside the hook.

If the user wants to have some processing done by some commands for
different trailers, it makes sense to have all the processing done by
commands specified in the trailer.<token>.command config variables,
instead of having some of it done by such config variables and other
done in some hooks.

> The question is: what would it be used for?  There aren't that many mail
> headers, and most of them (From, Subject, Date) are recorded in the
> commit anyway.  One idea could be to record who was a recipient of the
> original message, even if no Cc line was added explicitly.  In most
> projects, Cc is often added randomly, but I guess that's a valid
> usecase.  I can certainly code the above hook instead of this approach
> if Junio thinks it's better.

Yes, recording Cc'ed people in Cc: trailers is a very valid use case.
I don't think the trailer.<token>.command mechanism supports that well
if people want only one person per Cc: trailer.
That's something that could be improved in git-interpret-trailers.

> In the meanwhile, I have thought of a couple additions to "git
> interpret-trailers" and I can submit patches for them.

You are welcome to suggest and even more to submit patches for additions to it.
If you want, you can also have a look at some of these threads for
some things that have been suggested already:

http://thread.gmane.org/gmane.comp.version-control.git/259614/
thread.gmane.org/gmane.comp.version-control.git/259275/

Thanks,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html