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

[PATCH 7/7] remote-bzr: add utf-8 support for pushing

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 6, 2013, 03:49 UTC
Message-ID
<1365220163-13581-8-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1365220163-13581-1-git-send-email-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr |  6 ++++++
 contrib/remote-helpers/test-bzr.sh    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 0bd0759..fad4a48 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -512,6 +512,11 @@ class CustomTree():
     def get_symlink_target(self, file_id):
         return self.updates[file_id]['data']
 
+def c_style_unescape(string):
+    if string[0] == string[-1] == '"':
+        return string.decode('string-escape')[1:-1]
+    return string
+
 def parse_commit(parser):
     global marks, blob_marks, bmarks, parsed_refs
     global mode
@@ -551,6 +556,7 @@ def parse_commit(parser):
             f = { 'deleted' : True }
         else:
             die('Unknown file command: %s' % line)
+        path = c_style_unescape(path).decode('utf-8')
         files[path] = f
 
     repo = parser.repo
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index e468079..f4c7768 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -190,4 +190,35 @@ test_expect_success 'fetch utf-8 filenames' '
   test_cmp expected actual
 '
 
+test_expect_success 'push 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 one >> content &&
+  bzr add content &&
+  bzr commit -m one
+  ) &&
+
+  (
+  git clone "bzr::$PWD/bzrrepo" gitrepo &&
+  cd gitrepo &&
+
+  echo test >> "áéíóú" &&
+  git add "áéíóú" &&
+  git commit -m utf-8 &&
+
+  git push
+  ) &&
+
+  (cd bzrrepo && bzr ls > ../actual) &&
+  echo -e "content\náéíóú" > expected &&
+  test_cmp expected actual
+'
+
 test_done
-- 
1.8.2
Previous: Felipe ContrerasNext: Felipe Contreras
Message 8 of 9 in “remote-bzr: generic updates”
  1. 0/7 remote-bzr: generic updatesFelipe Contreras, Apr 6, 2013
  2. 1/7 remote-bzr: fix directory renamingFelipe Contreras, Apr 6, 2013
  3. 2/7 remote-bzr: remove files before modificationsFelipe Contreras, Apr 6, 2013
  4. 3/7 remote-bzr: set author if availableFelipe Contreras, Apr 6, 2013
  5. 4/7 remote-bzr: only update workingtree on local reposFelipe Contreras, Apr 6, 2013
  6. 5/7 remote-bzr: avoid unreferred tagsFelipe Contreras, Apr 6, 2013
  7. 6/7 remote-bzr: add utf-8 support for fetchingFelipe Contreras, Apr 6, 2013
  8. 7/7 remote-bzr: add utf-8 support for pushingFelipe Contreras, Apr 6, 2013
  9. Felipe ContrerasApr 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.