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
This commit is contained in:
Joey Hess 2023-10-30 14:43:43 -04:00
parent eb42935e58
commit 39ca30e004
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 10 additions and 1 deletions

View file

@ -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 <id@joeyh.name> Tue, 10 Oct 2023 13:17:31 -0400

View file

@ -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