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

RE: [EXTERNAL] Re: [PATCH 2/3] bisect: remove CR characters from revision in replay

From
CCChristopher Warrington (CHRISTOPHER) <christopher.warrington@microsoft.com>
Date
May 20, 2020, 20:59 UTC
Message-ID
<DM5PR00MB0439A347273E56C8697A587A9BB60@DM5PR00MB0439.namprd00.prod.outlook.com>
In-Reply-To
<20200520170843.GC20332@Carlos-MBP>
On 2020-05-20 at 10:09-07:00, Carlo Marcelo Arenas Belón wrote:
> IMHO it will be probably still cleaner to do `tr -d '\015'`, even if the
> patch below avoids all current issues from the testsuite.
My initial attempt to handle CRLF logs was shaped like this:
	tr -d '\r' <"$file" | while read ...

This introduces a subshell, so there were concerns about propagating variables and exits. So, Peff also suggested preprocessing to a file. Around the same time Junio tried using IFS, and that was simpler.

It would be pretty easy to tr -d '\r' >"$GIT_DIR/BISECT_REPLAY_LOG" (or some other name) and then read from that.

Two things I'm not sure of with such an approach:
1. Is $GIT_DIR the right place to put this? If not, is there a helper to
   create a temporary file? mktemp may not be available everywhere. I only
   see git-mergetool.sh using it and only behind the mergetool.writeToTemp
   variable.
2. How and when does this temp file need to be cleaned up? Looking at using
   something like trap "rm -f \"$temp_file\"" 0 will conflict with the traps
   that git-bisect.sh's bisect_start installs, and bisect_replay calls
   bisect_start. I could introduce a helper like
   maybe_unlink_temp_replay_log and invoke that from a trap installed in
   both bisect_replay and bisect_start.
   I looked at whether bisect.c's bisect_clean_state() is the right place to
   add such clean up: it does not look like the right place. It would result
   in the temp file getting deleted while it was being read. (git-bisect.sh
   -> bisect_replay()'s loop -> bisect_start() -> bisect--helper.c's
   bisect_start() -> bisect.c's bisect_clean_state()) Alas, not all file
   systems are OK with that happening.
Any guidance?
Here's a sketch that leaves cleanup on non-successful paths unaddressed.
bisect_replay () {
	file="$1"
	test "$#" -eq 1 || die "$(gettext "No logfile given")"
	test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
	git bisect--helper --bisect-reset || exit
	scrubbed_file="$GIT_DIR/BISECT_CLEANED_LOG"
	tr -d '\r' <"$file" >"scrubbed_file" || die "badness"
	while read git bisect command rev
	do ... done <"$scrubbed_file"
	rm -f "$scrubbed_file"
	bisect_auto_next

-- Christopher Warrington <chwarr@microsoft.com> Microsoft Corp.

Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 11 in “openbsd: fixes for 2.27.0-RC0”
  1. 0/3 openbsd: fixes for 2.27.0-RC0Carlo Marcelo Arenas Belón, May 20, 2020
  2. 1/3 t4216: avoid unnecessary subshell in test_bloom_filters_not_usedCarlo Marcelo Arenas Belón, May 20, 2020
  3. Junio C HamanoMay 20, 2020
  4. 2/3 bisect: remove CR characters from revision in replayCarlo Marcelo Arenas Belón, May 20, 2020
  5. Junio C HamanoMay 20, 2020
  6. Carlo Marcelo Arenas BelónMay 20, 2020
  7. Junio C HamanoMay 20, 2020
  8. Christopher Warrington (CHRISTOPHER)May 20, 2020
  9. Junio C HamanoMay 20, 2020
  10. 3/3 t5520: avoid alternation in grep's BRE (not POSIX)Carlo Marcelo Arenas Belón, May 20, 2020
  11. Junio C HamanoMay 20, 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.