git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 27, 2013, 05:30 UTC
Message-ID
<7vy5ffxkfb.fsf@alter.siamese.dyndns.org>
In-Reply-To
<5104B0B5.1030501@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 6 quoted lines
> This will still fail under Python 2.x if repo.path is a byte string that
> contains non-ASCII characters.  And it will fail under Python 3.1 and
> later if repo.path contains characters using the surrogateescape
> encoding option [1],...
> Here you don't really need byte-for-byte correctness; it would be enough
> to get *some* byte string that is unique for a given input ...
Yeek.

As we do not care about the actual value at all, how about doing something like this instead?

 git-remote-testgit.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-remote-testgit.py b/git-remote-testgit.py
index 5f3ebd2..705750d 100644
--- a/git-remote-testgit.py
+++ b/git-remote-testgit.py
@@ -40,7 +40,7 @@ def get_repo(alias, url):
     repo.get_head()
 
     hasher = _digest()
-    hasher.update(repo.path)
+    hasher.update(".".join([str(ord(c)) for c in repo.path]))
     repo.hash = hasher.hexdigest()
 
     repo.get_base_path = lambda base: os.path.join(
Previous: Michael HaggertyNext: John Keeping
Message 20 of 38 in “Python 3 support for git_remote_helpers”
  1. 0/8 Python 3 support for git_remote_helpersJohn Keeping, Jan 20, 2013
  2. 1/8 git_remote_helpers: Allow building with Python 3John Keeping, Jan 20, 2013
  3. Sverre RabbelierJan 23, 2013
  4. 2/8 git_remote_helpers: fix input when running under Python 3John Keeping, Jan 20, 2013
  5. Sverre RabbelierJan 23, 2013
  6. John KeepingJan 23, 2013
  7. Sverre RabbelierJan 23, 2013
  8. Junio C HamanoJan 23, 2013
  9. Brandon CaseyJan 25, 2013
  10. Erik Faye-LundFeb 5, 2013
  11. 3/8 git_remote_helpers: Force rebuild if python version changesJohn Keeping, Jan 20, 2013
  12. Sverre RabbelierJan 23, 2013
  13. 4/8 git_remote_helpers: Use 2to3 if building with Python 3John Keeping, Jan 20, 2013
  14. 5/8 svn-fe: allow svnrdump_sim.py to run with Python 3John Keeping, Jan 20, 2013
  15. 6/8 git-remote-testpy: hash bytes explicitlyJohn Keeping, Jan 20, 2013
  16. John KeepingJan 26, 2013
  17. Junio C HamanoJan 26, 2013
  18. git-remote-testpy: fix patch hashing on Python 3John Keeping, Jan 26, 2013
  19. Michael HaggertyJan 27, 2013
  20. Junio C HamanoJan 27, 2013
  21. John KeepingJan 27, 2013
  22. Sverre RabbelierJan 27, 2013
  23. Michael HaggertyJan 27, 2013
  24. John KeepingJan 27, 2013
  25. git-remote-testpy: fix patch hashing on Python 3John Keeping, Jan 27, 2013
  26. Junio C HamanoJan 27, 2013
  27. John KeepingJan 27, 2013
  28. Junio C HamanoJan 27, 2013
  29. John KeepingJan 27, 2013
  30. Junio C HamanoJan 27, 2013
  31. Junio C HamanoJan 27, 2013
  32. John KeepingJan 27, 2013
  33. Junio C HamanoJan 27, 2013
  34. Michael HaggertyJan 28, 2013
  35. fixup! git-remote-testpy: fix path hashing on Python 3John Keeping, Jan 28, 2013
  36. Junio C HamanoJan 28, 2013
  37. 7/8 git-remote-testpy: don't do unbuffered text I/OJohn Keeping, Jan 20, 2013
  38. 8/8 git-remote-testpy: call print as a functionJohn Keeping, Jan 20, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.