Windows: Avoid terminating git-annex branch lines with \r\n when union merging.

This commit is contained in:
Joey Hess 2016-05-27 15:22:29 -04:00
parent 45308ec78b
commit 84f20c9f69
Failed to extract signature
4 changed files with 26 additions and 0 deletions

View file

@ -1,6 +1,8 @@
git-annex (6.20160528) UNRELEASED; urgency=medium
* Improve SHA*E extension extraction code.
* Windows: Avoid terminating git-annex branch lines with \r\n when
union merging and performing transitions.
-- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400

View file

@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
module Git.HashObject where
import Common
@ -39,6 +41,10 @@ hashFile h file = CoProcess.query h send receive
- interface does not allow batch hashing without using temp files. -}
hashBlob :: HashObjectHandle -> String -> IO Sha
hashBlob h s = withTmpFile "hash" $ \tmp tmph -> do
fileEncoding tmph
#ifdef mingw32_HOST_OS
hSetNewlineMode tmph noNewlineTranslation
#endif
hPutStr tmph s
hClose tmph
hashFile h tmp

View file

@ -92,3 +92,6 @@ I am running "git-annex version: 6.20160511-g4633f0b" on Windows, but I have bee
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Yes it is working very nicely on all my linux computers, and right now I am mostly concerned that I might have messed up the repository by trying out Windows :-(.
> [[fixed|done]]; repositories in this state are now handled appropriately
> by git-annex. And, I've fixed at least the places I was able to identify
> where '\r' slipped in. --[[Joey]]

View file

@ -0,0 +1,15 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2016-05-27T19:03:05Z"
content="""
Union merge on windows does indeed add \r onto lines.
Looks like hashBlob is at fault; it writes a string to a temp file,
and the IO layer does CRLF conversion at that point.
The git-annex branch transition code also uses hashBlob so would also
do it.
So I've reproduced the root cause of this now. Fixing..
"""]]