Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v2 6/8] git-remote-testpy: hash bytes explicitly

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:55:48

John Keeping [off-list ref] writes:
On Thu, Jan 17, 2013 at 02:24:37PM -0800, Junio C Hamano wrote:
quoted
John Keeping [off-list ref] writes:
quoted
You're right - I think we need to add ", errors='replace'" to the call
to encode.
Of if it is used just as a opaque token, you can .encode('hex') or
something to punt on the whole issue, no?
Even better.  Are you happy to squash that in (assuming nothing else
comes up) or shall I resend?
If you go the .encode('hex') route, the log message needs to explain
why the hashed values are now different from the old implementation
and justify why it is safe to do so.  I do not think I want to do
that myself ;-).

Thanks.

quoted
quoted
quoted
quoted
 git-remote-testpy.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/git-remote-testpy.py b/git-remote-testpy.py
index d94a66a..f8dc196 100644
--- a/git-remote-testpy.py
+++ b/git-remote-testpy.py
@@ -31,9 +31,9 @@ from git_remote_helpers.git.exporter import GitExporter
 from git_remote_helpers.git.importer import GitImporter
 from git_remote_helpers.git.non_local import NonLocalGit
 
-if sys.hexversion < 0x01050200:
-    # os.makedirs() is the limiter
-    sys.stderr.write("git-remote-testgit: requires Python 1.5.2 or later.\n")
+if sys.hexversion < 0x02000000:
+    # string.encode() is the limiter
+    sys.stderr.write("git-remote-testgit: requires Python 2.0 or later.\n")
     sys.exit(1)
 
 def get_repo(alias, url):
@@ -45,7 +45,7 @@ def get_repo(alias, url):
     repo.get_head()
 
     hasher = _digest()
-    hasher.update(repo.path)
+    hasher.update(repo.path.encode('utf-8'))
     repo.hash = hasher.hexdigest()
 
     repo.get_base_path = lambda base: os.path.join(
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help