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

[PATCH v2 6/7] remote-bzr: add utf-8 support for fetching

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 8, 2013, 17:27 UTC
Message-ID
<1365442036-25732-7-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1365442036-25732-1-git-send-email-felipe.contreras@gmail.com>
From: Christophe Simonis <christophe@kn.gl>
Initial patch by Timotheus Pokorra.
[fc: added tests]
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 15 +++++++++------
 contrib/remote-helpers/test-bzr.sh    | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index dc0b757..64b35c7 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -184,21 +184,24 @@ def get_filechanges(cur, prev):
 
     changes = cur.changes_from(prev)
 
+    def u(s):
+        return s.encode('utf-8')
+
     for path, fid, kind in changes.added:
-        modified[path] = fid
+        modified[u(path)] = fid
     for path, fid, kind in changes.removed:
-        removed[path] = None
+        removed[u(path)] = None
     for path, fid, kind, mod, _ in changes.modified:
-        modified[path] = fid
+        modified[u(path)] = fid
     for oldpath, newpath, fid, kind, mod, _ in changes.renamed:
-        removed[oldpath] = None
+        removed[u(oldpath)] = None
         if kind == 'directory':
             lst = cur.list_files(from_dir=newpath, recursive=True)
             for path, file_class, kind, fid, entry in lst:
                 if kind != 'directory':
-                    modified[newpath + '/' + path] = fid
+                    modified[u(newpath + '/' + path)] = fid
         else:
-            modified[newpath] = fid
+            modified[u(newpath)] = fid
 
     return modified, removed
 
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index 68105fc..9a510a8 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -165,4 +165,36 @@ test_expect_success 'different authors' '
   test_cmp expected actual
 '
 
+test_expect_success 'fetch utf-8 filenames' '
+  mkdir -p tmp && cd tmp &&
+  test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
+
+  export LC_ALL=en_US.UTF-8
+
+  (
+  bzr init bzrrepo &&
+  cd bzrrepo &&
+
+  echo test >> "áéíóú" &&
+  bzr add "áéíóú" &&
+  echo test >> "îø∫∆" &&
+  bzr add "îø∫∆" &&
+  bzr commit -m utf-8 &&
+  echo test >> "áéíóú" &&
+  bzr commit -m utf-8 &&
+  bzr rm "îø∫∆" &&
+  bzr mv "áéíóú" "åß∂" &&
+  bzr commit -m utf-8
+  ) &&
+
+  (
+  git clone "bzr::$PWD/bzrrepo" gitrepo &&
+  cd gitrepo &&
+  git ls-files > ../actual
+  ) &&
+
+  echo "\"\\303\\245\\303\\237\\342\\210\\202\"" > expected &&
+  test_cmp expected actual
+'
+
 test_done
-- 
1.8.2
Previous: Felipe ContrerasNext: Torsten Bögershausen
Message 7 of 12 in “remote-bzr: generic updates”
  1. 0/7 remote-bzr: generic updatesFelipe Contreras, Apr 8, 2013
  2. 1/7 remote-bzr: fix directory renamingFelipe Contreras, Apr 8, 2013
  3. 2/7 remote-bzr: remove files before modificationsFelipe Contreras, Apr 8, 2013
  4. 3/7 remote-bzr: set author if availableFelipe Contreras, Apr 8, 2013
  5. 4/7 remote-bzr: only update workingtree on local reposFelipe Contreras, Apr 8, 2013
  6. 5/7 remote-bzr: improve tag handlingFelipe Contreras, Apr 8, 2013
  7. 6/7 remote-bzr: add utf-8 support for fetchingFelipe Contreras, Apr 8, 2013
  8. Torsten BögershausenApr 8, 2013
  9. 7/7 remote-bzr: add utf-8 support for pushingFelipe Contreras, Apr 8, 2013
  10. Junio C HamanoApr 8, 2013
  11. Felipe ContrerasApr 8, 2013
  12. Junio C HamanoApr 8, 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.