diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-05-21 01:26:54 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-05-21 01:26:54 +0300 |
commit | 804ec0301fddb68d5170939084d79e2c0c672028 (patch) | |
tree | 2a59846b4ac9122d38675d8610543900e77806d1 /git-p4.py | |
parent | 2e55151800531fea805bbe3a655d73627c1ea194 (diff) | |
parent | fbe5f6b80437adbcd58af1b3751b830910a2ddaa (diff) |
Merge branch 'tk/p4-utf8-bom'
"git p4" update.
* tk/p4-utf8-bom:
git-p4: preserve utf8 BOM when importing from p4 to git
Diffstat (limited to 'git-p4.py')
-rwxr-xr-x | git-p4.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -3046,6 +3046,16 @@ class P4Sync(Command, P4UserMap): print("\nIgnoring apple filetype file %s" % file['depotFile']) return + if type_base == "utf8": + # The type utf8 explicitly means utf8 *with BOM*. These are + # streamed just like regular text files, however, without + # the BOM in the stream. + # Therefore, to accurately import these files into git, we + # need to explicitly re-add the BOM before writing. + # 'contents' is a set of bytes in this case, so create the + # BOM prefix as a b'' literal. + contents = [b'\xef\xbb\xbf' + contents[0]] + contents[1:] + # Note that we do not try to de-mangle keywords on utf16 files, # even though in theory somebody may want that. regexp = p4_keywords_regexp_for_type(type_base, type_mods) |