From 1a8e247ba72afdf79ff28bbf94693ed379cca2e5 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Fri, 26 Apr 2019 17:53:00 -0700 Subject: [PATCH] filter-repo (python3): add a decode() function We need a function to transform byte strings into unicode strings for printing error messages and occasional other uses. Signed-off-by: Elijah Newren --- git-filter-repo | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git-filter-repo b/git-filter-repo index 8039fdd..5420acd 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -115,6 +115,10 @@ def date_to_string(dateobj): return('{} {}'.format(int(_timedelta_to_seconds(dateobj - epoch)), dateobj.tzinfo.tzname(0))) +def decode(bytestr): + 'Try to convert bytestr to utf-8 for outputting as an error message.' + return bytestr.decode('utf-8', 'backslashreplace') + class PathQuoting: _unescape = {'a': '\a', 'b': '\b',