From: Pete Wyckoff <pw@padd.com>
To: Chris Li <christ.li@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Eberhard Beilharz <eb1@sil.org>,
Jordan Zimmerman <jzimmerman@netflix.com>,
Mike Crowe <mac@mcrowe.com>
Subject: Re: [PATCH] git-p4: don't convert utf16 files.
Date: Sun, 21 Aug 2011 11:21:56 -0400 [thread overview]
Message-ID: <20110821152156.GA30299@arf.padd.com> (raw)
In-Reply-To: <CANeU7QmGJTr4V-tWzuPnP2P=9eQbGDgQxv2phAVbGXjU5tqYPQ@mail.gmail.com>
christ.li@gmail.com wrote on Fri, 19 Aug 2011 15:50 -0700:
> Some repository has some utf16 files git-p4 don't know
> how to convert. For those files, git-p4 just write the utf8
> files. That is wrong, because git get different file than
> perforce does, causing some windows resource file fail
> to compile.
>
> Using the "p4 print -o tmpfile depotfile" can avoid this
> convertion (and possible failure) all together.
This isn't contrib/fast-import/git-p4. Searching around, I
discovered a 2009 fork of git-p4 that is fairly active. CC-ing
some of the names I found on github.
Here's one such repo:
http://github.com/ermshiperete/git-p4
Git's git-p4 doesn't try to do anything special with utf-16. It
does \r\n mangling, but not $Keyword$ removal, then just streams
it to disk however p4 sends it. That's close to what you're
trying to do here.
-- Pete
> Signed-off-by: Chris Li <git@chrisli.org>
>
> ---
> git-p4 | 11 +++++------
> 1 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/git-p4 b/git-p4
> index 672b0c2..0c6a5cc 100755
> --- a/git-p4
> +++ b/git-p4
> @@ -755,12 +755,11 @@ class P4FileReader:
> break
>
> if header['type'].startswith('utf16'):
> - try:
> - text = textBuffer.getvalue().encode('utf_16')
> - except UnicodeDecodeError:
> - # File checked in to Perforce has an error. Try
> without encoding
> - print "Corrupt UTF-16 file in Perforce: %s" %
> header['depotFile']
> - text = textBuffer.getvalue()
> + # Don't even try to convert utf16. Ask p4 to write
> the file directly.
> + tmpFile = tempfile.NamedTemporaryFile()
> + P4Helper().p4_system("print -o %s %s"%(tmpFile.name,
> header['depotFile']))
> + text = open(tmpFile.name).read()
> + tmpFile.close()
> else:
> text = textBuffer.getvalue()
> textBuffer.close()
> --
> 1.7.6
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2011-08-21 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-19 22:50 [PATCH] git-p4: don't convert utf16 files Chris Li
2011-08-21 15:21 ` Pete Wyckoff [this message]
2011-08-21 19:09 ` Chris Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110821152156.GA30299@arf.padd.com \
--to=pw@padd.com \
--cc=christ.li@gmail.com \
--cc=eb1@sil.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jzimmerman@netflix.com \
--cc=mac@mcrowe.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox