Skip to content

Commit 6ff8d4e

Browse files
felipecgitster
authored andcommitted
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>
1 parent 5445b24 commit 6ff8d4e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ class CustomTree():
512512
def get_symlink_target(self, file_id):
513513
return self.updates[file_id]['data']
514514

515+
def c_style_unescape(string):
516+
if string[0] == string[-1] == '"':
517+
return string.decode('string-escape')[1:-1]
518+
return string
519+
515520
def parse_commit(parser):
516521
global marks, blob_marks, bmarks, parsed_refs
517522
global mode
@@ -551,6 +556,7 @@ def parse_commit(parser):
551556
f = { 'deleted' : True }
552557
else:
553558
die('Unknown file command: %s' % line)
559+
path = c_style_unescape(path).decode('utf-8')
554560
files[path] = f
555561

556562
repo = parser.repo

contrib/remote-helpers/test-bzr.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,35 @@ test_expect_success 'fetch utf-8 filenames' '
204204
test_cmp expected actual
205205
'
206206

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+
207238
test_done

0 commit comments

Comments
 (0)