remote-bzr: add utf-8 support for pushing
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 5, 2013 at 21:49 UTC
6ff8d4e7487c0f48e568b7fd95fa02515a426c1a
2 files changed
+37
contrib/remote-helpers/git-remote-bzr
+6
@@ -512,6 +512,11 @@ class CustomTree():
512
def get_symlink_target(self, file_id):
513
return self.updates[file_id]['data']
514
515
+def c_style_unescape(string):
516
+ if string[0] == string[-1] == '"':
517
+ return string.decode('string-escape')[1:-1]
518
+ return string
519
+
520
def parse_commit(parser):
521
global marks, blob_marks, bmarks, parsed_refs
522
global mode
@@ -551,6 +556,7 @@ def parse_commit(parser):
556
f = { 'deleted' : True }
557
else:
558
die('Unknown file command: %s' % line)
559
+ path = c_style_unescape(path).decode('utf-8')
560
files[path] = f
561
562
repo = parser.repo
contrib/remote-helpers/test-bzr.sh
+31
@@ -204,4 +204,35 @@ test_expect_success 'fetch utf-8 filenames' '
204
test_cmp expected actual
205
'
206
207
+test_expect_success 'push utf-8 filenames' '
208
+ mkdir -p tmp && cd tmp &&
209
+ test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
210
+
211
+ export LC_ALL=en_US.UTF-8
212
+
213
+ (
214
+ bzr init bzrrepo &&
215
+ cd bzrrepo &&
216
+
217
+ echo one >> content &&
218
+ bzr add content &&
219
+ bzr commit -m one
220
+ ) &&
221
+
222
+ (
223
+ git clone "bzr::$PWD/bzrrepo" gitrepo &&
224
+ cd gitrepo &&
225
+
226
+ echo test >> "áéíóú" &&
227
+ git add "áéíóú" &&
228
+ git commit -m utf-8 &&
229
+
230
+ git push
231
+ ) &&
232
+
233
+ (cd bzrrepo && bzr ls > ../actual) &&
234
+ echo -e "content\náéíóú" > expected &&
235
+ test_cmp expected actual
236
+'
237
+
238
test_done