git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[WIP-PATCH 0/2] send-email: refactor the email parser loop

From
SGSamuel GROOT <samuel.groot@grenoble-inp.org>
Date
May 27, 2016, 14:01 UTC
Message-ID
<20160527140104.11192-1-samuel.groot@grenoble-inp.org>

While working on the new option `quote-email`, we needed to parse an email file. Since the work is already done, but the parsing and data processing are in the same loop, we wanted to refactor the parser, to make the code more maintainable.

This is still WIP, and one of the main issue (and we need your advice on that), is that around 30 tests will fail, and most of them are false-negatives: to pass, they rely on the format of what is displayed by `git send-email`, not only data.

For example, several tests will fail because they do a strict compare between `git send-email`'s output and:

   (mbox) Adding cc: A<author@example.com>  from line 'Cc: A<author@example.com>, One<one@example.com>'
   (mbox) Adding cc: One<one@example.com>  from line 'Cc: A<author@example.com>, One<one@example.com>'
Though `git send-email` now outputs something like:
   (mbox) Adding cc: A<author@example.com>  from line 'Cc: A<author@example.com>'
   (mbox) Adding cc: One<one@example.com>  from line 'Cc: One<one@example.com>'

The new behavior is explained because parsing and processing are not done in the same function, and processing cannot know the exact line the data came from.

We can think of several solutions:
   1. Modify the parser, to give the script the knowledge of the exact
      line the data came from.
   2. Hack the tests: modify the script using the parser to artificially
      recreate the supposedly parsed line.
      (e.g. with a list.join(', ')-like function)
   3. Modify the tests to replace exact cmp by greps.

IMHO, we should consider option 3, since the tests should rely on data rather than exact outputs. It also makes the tests more maintainable, in the sense that they will be more resilient to future output modifications.

What do you think?
   [WIP-PATCH 1/2] send-email: create email parser subroutine
   [WIP-PATCH 2/2] send-email: use refactored subroutine to parse patches
git-send-email.perl | 284 ++++++++++++++++++++++++++++++++++++++++++++--------------------------------
  1 file changed, 164 insertions(+), 120 deletions(-)
Next: Samuel GROOT
Message 1 of 18 in “send-email: refactor the email parser loop”
  1. 0/2 send-email: refactor the email parser loopSamuel GROOT, May 27, 2016
  2. 1/2 send-email: create email parser subroutineSamuel GROOT, May 27, 2016
  3. Matthieu MoyMay 28, 2016
  4. Eric WongMay 28, 2016
  5. Samuel GROOTMay 29, 2016
  6. Matthieu MoyMay 29, 2016
  7. Samuel GROOTMay 30, 2016
  8. Samuel GROOTJun 2, 2016
  9. Eric WongJun 2, 2016
  10. 2/2 send-email: use refactored subroutine to parse patchesSamuel GROOT, May 27, 2016
  11. Eric WongMay 27, 2016
  12. Matthieu MoyMay 28, 2016
  13. Samuel GROOTMay 29, 2016
  14. Matthieu MoyMay 29, 2016
  15. Samuel GROOTMay 30, 2016
  16. Matthieu MoyMay 30, 2016
  17. Samuel GROOTMay 30, 2016
  18. Matthieu MoyMay 30, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.