From 39ca30e004c973e57ccf7b907f32df7dedfc9a9d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Oct 2023 14:43:43 -0400 Subject: [PATCH] Windows: Consistently avoid ending output lines with CR This matches the behavior of git on Windows, which does not end lines with CR either. Previously, git-annex used to always write lines with putStrLn, so would output CR on Windows. Then parts of it changed to use ByteString.putStrLn, which does not output CR. That left its output inconsistent, sometimes within the same command. The point of this commit is to get back to consistency. Having the same behavior as git is a nice bonus. It would be much harder to make it consistently output CR, because every place it uses ByteString.putStrLn or similar would need to be changed. Sponsored-by: Nicholas Golder-Manning on Patreon --- CHANGELOG | 3 +++ Messages.hs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 584d19709d..2aaf0c2023 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,9 @@ git-annex (10.20230927) UNRELEASED; urgency=medium * importfeed: Use caching database to avoid needing to list urls on every run, and avoid using too much memory. * Improve memory use of --all when using annex.private. + * Windows: Consistently avoid ending output lines with CR. This matches + the behavior of git on Windows, which does not end lines with CR + either. * Windows: Fix CRLF handling in some log files. -- Joey Hess Tue, 10 Oct 2023 13:17:31 -0400 diff --git a/Messages.hs b/Messages.hs index 3bf1256ee1..6b6222a07b 100644 --- a/Messages.hs +++ b/Messages.hs @@ -5,7 +5,7 @@ - Licensed under the GNU AGPL version 3 or higher. -} -{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-} module Messages ( showStartMessage, @@ -265,6 +265,12 @@ setupConsole = do - a file or a pipe. -} hSetBuffering stdout LineBuffering hSetBuffering stderr LineBuffering +#ifdef mingw32_HOST_OS + {- Avoid outputting CR at end of line on Windows. git commands do + - not ouput CR there. -} + hSetNewlineMode stdout noNewlineTranslation + hSetNewlineMode stderr noNewlineTranslation +#endif enableDebugOutput :: Annex () enableDebugOutput = do -- 2.30.2