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

Re: [PATCH] bisect: fix replay of CRLF logs

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 7, 2020, 22:13 UTC
Message-ID
<CAPig+cTbvmGPjR85RupL4DZjzCwjeHxBqnbPg1+8Gd-Xmzf7CA@mail.gmail.com>
In-Reply-To
<pull.629.git.1588886980377.gitgitgadget@gmail.com>

On Thu, May 7, 2020 at 5:29 PM Christopher Warrington via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 20 quoted lines
> Sometimes bisect logs have CRLF newlines. (E.g., if they've been edited
> on a Windows machine and their LF-only nature wasn't preserved.)
> Previously, such log files would cause odd failures deep in the guts of
> git bisect, like "?? what are you talking about?" or "couldn't get the
> oid of the rev '...?'" (notice the trailing ?) as each line's CR ends up
> part of the final value read from the log.
>
> This commit fixes that by stripping CRs from the log before further
> processing.
> [...]
> Signed-off-by: Christopher Warrington <chwarr@microsoft.com>
> ---
> diff --git a/git-bisect.sh b/git-bisect.sh
> @@ -209,7 +209,11 @@ bisect_replay () {
> -       while read git bisect command rev
> +
> +       # We remove any CR in the input to handle bisect log files that have
> +       # CRLF line endings. The assumption is that CR within bisect
> +       # commands also don't matter.
> +       tr -d '\r' <"$file" | while read git bisect command rev

Due to portability concerns, I worry about using '\r' here. Indeed this would be its first use in this codebase. On the other hand, '\015' is heavily used (at least in the tests), so that would likely be a safer alternative.

Show 6 quoted lines
> @@ -231,7 +235,9 @@ bisect_replay () {
> -       done <"$file"
> +       done
> +
> +       get_terms
>         bisect_auto_next
Why the new get_terms() invocation? Is that leftover debugging gunk?
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> @@ -792,6 +792,13 @@ test_expect_success 'bisect replay with old and new' '
> +test_expect_success 'bisect replay with CRLF log' '
> +       awk 1 "ORS=\\r\\n" <log_to_replay.txt >log_to_replay_crlf.txt &&

This would be the first use of awk's ORS in this codebase, which may invite portability problems. In this codebase, the more typical way to do this is via a combination of 'sed' and 'tr', however, even better would be to take advantage of append_cr() from t/test-lib-functions.sh:

    appenc_cr <log_to_replay.txt >log_to_replay_crlf.txt &&
> +       git bisect replay log_to_replay_crlf.txt >bisect_result_crlf &&
> +       grep "$HASH2 is the first new commit" bisect_result_crlf &&
> +       git bisect reset
> +'
Previous: Christopher Warrington via GitGitGadgetNext: Jeff King
Message 2 of 13 in “bisect: fix replay of CRLF logs”
  1. bisect: fix replay of CRLF logsChristopher Warrington via GitGitGadget, May 7, 2020
  2. Eric SunshineMay 7, 2020
  3. Jeff KingMay 7, 2020
  4. Junio C HamanoMay 7, 2020
  5. Jeff KingMay 8, 2020
  6. Junio C HamanoMay 8, 2020
  7. Junio C HamanoMay 8, 2020
  8. Jeff KingMay 8, 2020
  9. Junio C HamanoMay 8, 2020
  10. brian m. carlsonMay 9, 2020
  11. Achim GratzMay 10, 2020
  12. Christopher Warrington (CHRISTOPHER)May 8, 2020
  13. Junio C HamanoMay 9, 2020

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.