git-p4: avoid decoding more data from perforce
authorAndrew Oakley <andrew@adoakley.name>
Mon, 12 Apr 2021 08:52:50 +0000 (09:52 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Apr 2021 18:32:53 +0000 (11:32 -0700)
commite28c86f002d66e88f12042659b667f5cc9d67b93
treeeeb4185c1141bdb11c3312ebe2a81068faad5334
parent89b43f80a514aee58b662ad606e6352e03eaeee4
git-p4: avoid decoding more data from perforce

Perforce does not validate or store the encoding of user submitted data
by default (although this can be enabled).  In large repositories it is
therefore very likely that some data will not be valid UTF-8.

Historically (with python2) git-p4 did not attempt to decode the data
from the perforce server - it just passed bytes from perforce to git,
preserving whatever was stored in perforce.  This seems like a sensible
approach - it avoids any loss of data, and there is no way to determine
the intended encoding for any invalid data from perforce.

This change updates git-p4 to avoid decoding changelist descriptions,
user and time information.  The time data is almost certainly valid
unicode, but as they are processed with the user information it is more
convenient for them to be handled as bytes.

Signed-off-by: Andrew Oakley <andrew@adoakley.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py
t/t9835-git-p4-message-encoding.sh [new file with mode: 0755]