Skip to content

Commit

Permalink
remote-bzr: add utf-8 support for pushing
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Apr 7, 2013
1 parent 5445b24 commit 6ff8d4e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions contrib/remote-helpers/test-bzr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6ff8d4e

Please sign in to comment.