]> granicus.if.org Git - git/commitdiff
remote-bzr: add utf-8 support for pushing
authorFelipe Contreras <felipe.contreras@gmail.com>
Sat, 6 Apr 2013 03:49:23 +0000 (21:49 -0600)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Apr 2013 07:39:28 +0000 (00:39 -0700)
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/test-bzr.sh

index 0bd0759d7ffb9014c1bd12ee4bca69f53e4f8c2b..fad4a48cdc4567cb732ddaed616d6e2365bab620 100755 (executable)
@@ -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
index 6eacf09a9bf5df5c04400bb59d558ab781be3fc2..4d71f711a6d032acfe4c1dc92d1c308ee56b1b80 100755 (executable)
@@ -204,4 +204,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