git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* help request: unable to merge UTF-16-LE "text" file
@ 2022-04-19 19:36 Kevin Long
  2022-04-19 21:50 ` brian m. carlson
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Kevin Long @ 2022-04-19 19:36 UTC (permalink / raw)
  To: git

Greetings,

I've been struggling to merge branches because of a UTF-16-LE (with BOM?) file.

Windows 11 / git version 2.35.3.windows.1

The problem file is a .sln file (Visual Studio "solution"). Edited in
both branches. It is a "text" file, but is encoded as such:

FacilityMaster.sln: Unicode text, UTF-16, little-endian text, with
CRLF line terminators

I have tried several "working-tree-encoding" settings in
.gitattributes in my local working directory, to no avail yet:

*.sln working-tree-encoding=UTF-16-LE eol=CRLF, results in:
error: failed to encode 'FacilityMaster.sln' from UTF-16-LE to UTF-8
warning: Cannot merge binary files: FacilityMaster.sln (HEAD vs. master)

*.sln working-tree-encoding=UTF-16 eol=CRLF, results in:
warning: Cannot merge binary files: FacilityMaster.sln (HEAD vs. master)

*.sln working-tree-encoding=UTF-16-LE-BOM eol=CRLF
error: failed to encode 'FacilityMaster.sln' from UTF-16-LE-BOM to UTF-8
warning: Cannot merge binary files: FacilityMaster.sln (HEAD vs. master)


Hoping for some suggestions. I've also tried to save the file as UTF-8
in both branches, commit, then merge, but still that did not work. I
just want to merge it like a normal source code file.


Thank you,

Kevin Long

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: help request: unable to merge UTF-16-LE "text" file
@ 2024-01-12 20:34 Michael Litwak
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Litwak @ 2024-01-12 20:34 UTC (permalink / raw)
  To: kioplato@gmail.com; +Cc: git@vger.kernel.org, kevinlong206@gmail.com


This is in reply to the message at 
https://lore.kernel.org/all/20220422184211.5z67sxrgq2zm3tvd@compass/#t

Sent via MS Outlook - hope this reaches the online thread.

------------------------------------------------------------------------

On Windows, if you do

    git add

from an ordinary Command Prompt, it will fail to call iconv.exe to perform
the necessary text conversion.  I.E. your UTF-16LE with BOM file will not be
properly converted by Git to UTF-8 for its internal storage, leading to
subsequent encoding errors.

So, in addition to setting the working-tree-encoding of the file to 
UTF-16LE-BOM in .gitattributes prior to adding the file, be sure to run:

    git add   

from a git bash console when adding such files.

- Michael



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-12 20:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 19:36 help request: unable to merge UTF-16-LE "text" file Kevin Long
2022-04-19 21:50 ` brian m. carlson
2022-04-20 17:25 ` Erik Cervin Edin
2022-04-20 17:38   ` Kevin Long
2022-04-20 17:50   ` Junio C Hamano
2022-04-20 17:55     ` Erik Cervin Edin
2022-04-20 18:03       ` Erik Cervin Edin
2022-04-24  1:57     ` Chris Torek
2022-04-22 18:42 ` Plato Kiorpelidis
  -- strict thread matches above, loose matches on Subject: below --
2024-01-12 20:34 Michael Litwak

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).