Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Now UTF-16 handling EOL fixup patch #42

Open
wants to merge 1 commit into
base: ned14-bad_eol_fix
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ enum class eol_conversion_t
{
None,
CRLFtoLF,
MaybeCRLFtoLF
MaybeCRLFtoLF,
SawUTF16
};

struct eol_conversion_state_t
Expand All @@ -427,6 +428,8 @@ extern "C"
auto& fast_import = *static_cast<git_fast_import*>(baton.git_fast_import_instance);
try
{
if(eol_conversion_t::None!=baton.conversion && memchr(data, 0, *len))
baton.conversion=eol_conversion_t::SawUTF16;
switch(baton.conversion)
{
case eol_conversion_t::MaybeCRLFtoLF:
Expand All @@ -452,8 +455,6 @@ extern "C"
{
// Quick sanity check: anything which will be interpreted as native EOL by git
// ought to never contain zeros. This also ought to catch any UTF-16 text.
if(memchr(data, 0, *len))
return svn_error_createf(APR_EOF, SVN_NO_ERROR, "Text contains zeros, might be UTF-16 text or a binary.");
if(!baton.firstrun)
return svn_error_createf(APR_EOF, SVN_NO_ERROR, "Earlier block was not CRLF, now it is. This is bad.");

Expand Down Expand Up @@ -628,6 +629,10 @@ void importer::convert_svn_file(
<< "In r" << revnum << ", text file '" << svn_path.str() << "' did not output " << file_length << " bytes."
<< std::endl;
}
if(eol_conversion_t::SawUTF16==baton.conversion)
Log::warn()
<< "In r" << revnum << ", text file '" << svn_path.str() << "' contained zeros and therefore was treated as binary."
<< std::endl;
}
fast_import << LF;
}
Expand Down