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

Bug Report: Multi-line trailers containing empty lines break parsing

From
MBMatthias Buehlmann <matthias.buehlmann@mabulous.com>
Date
Feb 15, 2021, 21:54 UTC
Message-ID
<CALz+XyW+XU++58eEYm5=jxTckK-VuuPoA-ecj4QCZw1o44JFUQ@mail.gmail.com>

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
    create a file containing multiline trailer:
    $ echo "Test" > test.txt
    $ git interpret-trailers --where end --if-exists addIfDifferent
--trailer "SingleLineTrailer: This is a single line trailer"
--in-place test.txt
    $ git interpret-trailers --where end --if-exists addIfDifferent
--trailer "MultiLineTrailer: This is"$'\n a folded multi-line\n
trailer' --in-place test.txt
    parse trailers:
    $ git interpret-trailers --parse test.txt
    SingleLineTrailer: This is a single line trailer
    MultiLineTrailer: This is a folded multi-line trailer
    (so far, all is as expected)
    now, adding multiline trailer containing empty line:
    $ git interpret-trailers --where end --if-exists addIfDifferent
--trailer "MultiLineTrailer: This is"$'\n a folded multi-line\n
trailer which\n \n contains an\n empty line' --in-place test.txt
    parse trailers again:
    $ git interpret-trailers --parse test.txt
What did you expect to happen? (Expected behavior)
I would expect the following output:
    $ git interpret-trailers --parse test.txt
    SingleLineTrailer: This is a single line trailer
    MultiLineTrailer: This is a folded multi-line trailer
    MultiLineTrailer: This is a folded multi-line trailer which
contains an empty line
What happened instead? (Actual behavior)
    no output is generated, but exit code is nevertheless 0:
    $ git interpret-trailers --parse test.txt
    $ echo $?
    0
What's different between what you expected and what actually happened?
    I would expect either to get an output or the call to exit non-zero
Anything else you want to add:
    According to my interpretation of the documentation of git
intepret-trailers, empty lines should be supported if properly folded,
in the same way as for example the PGP signature added to the commit
header contains a (properly folded) empty line

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.30.0.windows.2 cpu: x86_64 built from commit: f8cbc844b81bf6b9e72178bbe891a86c8bf5e9e7 sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh uname: Windows 10.0 18363 compiler info: gnuc: 10.2 libc info: no libc information available $SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe

[Enabled Hooks] post-commit

Next: Junio C Hamano
Message 1 of 12 in “Bug Report: Multi-line trailers containing empty lines break parsing”
  1. Matthias BuehlmannFeb 15, 2021
  2. Junio C HamanoFeb 16, 2021
  3. Taylor BlauFeb 16, 2021
  4. Junio C HamanoFeb 16, 2021
  5. Taylor BlauFeb 16, 2021
  6. Christian CouderMar 23, 2021
  7. Junio C HamanoMar 23, 2021
  8. Christian CouderMar 25, 2021
  9. ZheNing HuMar 25, 2021
  10. Junio C HamanoMar 25, 2021
  11. ZheNing HuMar 26, 2021
  12. Junio C HamanoMar 25, 2021

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.