Changes since v4 : * tweaked the wording of both commit messages to not call the behaviour a bug * added || return 1 in one test - that had already been squashed in by Junio ---------------------------------------------------------------------------- The ref-filter code does not correctly handle commit or tag messages that use CRLF as the line terminator. Such messages can be created with the --cleanup=verbatim option of git commit and git tag, or by using git commit-tree directly. The function find_subpos in ref-filter.c looks for two consecutive '\n' to find the end of the subject line, a sequence which is absent in messages using CRLF. This results in the whole message being parsed as the subject line (%(contents:subject)), and the body of the message (%(contents:body)) being empty. Moreover, in copy_subject, '\n' is replaced by space, but '\r' is untouched. This behaviour is a regression for git branch --verbose, which bisects down to 949af06 (branch: use ref-filter printing APIs, 2017-01-10). The first patch hardens the code in ref-filter.c to handle these messages more gracefully and adds a test script to check that the ref-filter and pretty APIs deal correctly with CRLF messages. The second patch adds tests that check the behaviour of git log andgit show in the presence of CRLF in messages, to prevent futur regressions. Cc: Michael J Gruber git@xxxxxxxxx [git@xxxxxxxxx], Matthieu Moy git@xxxxxxxxxxxxxxx [git@xxxxxxxxxxxxxxx], John Keeping john@xxxxxxxxxxxxx [john@xxxxxxxxxxxxx], Karthik Nayak karthik.188@xxxxxxxxx [karthik.188@xxxxxxxxx], Jeff King peff@xxxxxxxx [peff@xxxxxxxx], Alex Henrie alexhenrie24@xxxxxxxxx [alexhenrie24@xxxxxxxxx]cc: Eric Sunshine sunshine@xxxxxxxxxxxxxx [sunshine@xxxxxxxxxxxxxx]cc: Junio C Hamano gitster@xxxxxxxxx [gitster@xxxxxxxxx] Philippe Blain (2): ref-filter: handle CRLF at end-of-line more gracefully log, show: add tests for messages containing CRLF ref-filter.c | 36 ++++++----- t/t3920-crlf-messages.sh | 126 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 14 deletions(-) create mode 100755 t/t3920-crlf-messages.sh base-commit: a5fa49ff0a8f3252c6bff49f92b85e7683868f8a Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-576%2Fphil-blain%2Ffix-branch-verbose-crlf-v5 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-576/phil-blain/fix-branch-verbose-crlf-v5 Pull-Request: https://github.com/gitgitgadget/git/pull/576 Range-diff vs v4: 1: 03b2d7d78a ! 1: 06231c315f ref-filter: handle CRLF at end-of-line more gracefully @@ Commit message This impacts the output of `git branch`, `git tag` and `git for-each-ref`. - This bug is a regression for `git branch --verbose`, which + This behaviour is a regression for `git branch --verbose`, which bisects down to 949af0684c (branch: use ref-filter printing APIs, 2017-01-10). - Fix this bug in ref-filter by hardening the logic in `copy_subject` and - `find_subpos` to correctly parse messages containing CRLF. + Adjust the ref-filter code to be more lenient by hardening the logic in + `copy_subject` and `find_subpos` to correctly parse messages containing + CRLF. Add a new test script, 't3920-crlf-messages.sh', to test the behaviour of commands using either the ref-filter or the pretty APIs with messages 2: 75a87887be ! 2: f536fee695 log, show: add tests for messages containing CRLF @@ Metadata ## Commit message ## log, show: add tests for messages containing CRLF - A previous commit fixed a bug in ref-filter.c causing messages - containing CRLF to be incorrectly parsed and displayed. + A previous commit adjusted the code in ref-filter.c so that messages + containing CRLF are now correctly parsed and displayed. Add tests to also check that `git log` and `git show` correctly handle such messages, to prevent futur regressions if these commands are @@ t/t3920-crlf-messages.sh: test_crlf_subject_body_and_contents tag --list tag-crl + cut -d" " -f2- <tmp-branch >actual-branch && + cut -d" " -f2- <tmp-tag >actual-tag && + test_cmp expect actual-branch && -+ test_cmp expect actual-tag ++ test_cmp expect actual-tag || return 1 + done +' + -- gitgitgadget