Skip to content

Commit

Permalink
Merge branch 'ks/svn-pathnameencoding-4' of git://git.bogomips.org/gi…
Browse files Browse the repository at this point in the history
…t-svn

* 'ks/svn-pathnameencoding-4' of git://git.bogomips.org/git-svn:
  git-svn: apply "svn.pathnameencoding" before URL encoding
  git-svn: enable "svn.pathnameencoding" on dcommit
  git-svn: hoist out utf8 prep from t9129 to lib-git-svn
  • Loading branch information
Junio C Hamano committed Feb 22, 2016
2 parents 8716bdc + 1b42f45 commit d4bd678
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 14 deletions.
4 changes: 3 additions & 1 deletion perl/Git/SVN/Editor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sub new {
"$self->{svn_path}/" : '';
$self->{config} = $opts->{config};
$self->{mergeinfo} = $opts->{mergeinfo};
$self->{pathnameencoding} = Git::config('svn.pathnameencoding');
return $self;
}

Expand Down Expand Up @@ -143,11 +144,12 @@ sub repo_path {

sub url_path {
my ($self, $path) = @_;
$path = $self->repo_path($path);
if ($self->{url} =~ m#^https?://#) {
# characters are taken from subversion/libsvn_subr/path.c
$path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#sprintf("%%%02X",ord($1))#eg;
}
$self->{url} . '/' . $self->repo_path($path);
$self->{url} . '/' . $path;
}

sub rmdirs {
Expand Down
12 changes: 12 additions & 0 deletions t/lib-git-svn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,15 @@ start_svnserve () {
--listen-host 127.0.0.1 &
}

prepare_a_utf8_locale () {
a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
p
q
}')
if test -n "$a_utf8_locale"
then
test_set_prereq UTF8
else
say "# UTF-8 locale not available, some tests are skipped"
fi
}
40 changes: 38 additions & 2 deletions t/t9115-git-svn-dcommit-funky-renames.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,47 @@ test_expect_success 'make a commit to test rebase' '
'

test_expect_success 'git svn rebase works inside a fresh-cloned repository' '
cd test-rebase &&
(
cd test-rebase &&
git svn rebase &&
test -e test-rebase-main &&
test -e test-rebase
'
)'

# Without this, LC_ALL=C as set in test-lib.sh, and Cygwin converts
# non-ASCII characters in filenames unexpectedly, and causes errors.
# https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-specialchars
# > Some characters are disallowed in filenames on Windows filesystems. ...
# ...
# > ... All of the above characters, except for the backslash, are converted
# > to special UNICODE characters in the range 0xf000 to 0xf0ff (the
# > "Private use area") when creating or accessing files.
prepare_a_utf8_locale
test_expect_success UTF8 'svn.pathnameencoding=cp932 new file on dcommit' '
LC_ALL=$a_utf8_locale &&
export LC_ALL &&
neq=$(printf "\201\202") &&
git config svn.pathnameencoding cp932 &&
echo neq >"$neq" &&
git add "$neq" &&
git commit -m "neq" &&
git svn dcommit
'

# See the comment on the above test for setting of LC_ALL.
test_expect_success 'svn.pathnameencoding=cp932 rename on dcommit' '
LC_ALL=$a_utf8_locale &&
export LC_ALL &&
inf=$(printf "\201\207") &&
git config svn.pathnameencoding cp932 &&
echo inf >"$inf" &&
git add "$inf" &&
git commit -m "inf" &&
git svn dcommit &&
git mv "$inf" inf &&
git commit -m "inf rename" &&
git svn dcommit
'

stop_httpd

Expand Down
12 changes: 1 addition & 11 deletions t/t9129-git-svn-i18n-commitencoding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@ compare_git_head_with () {
test_cmp current "$1"
}

a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
p
q
}')

if test -n "$a_utf8_locale"
then
test_set_prereq UTF8
else
say "# UTF-8 locale not available, some tests are skipped"
fi
prepare_a_utf8_locale

compare_svn_head_with () {
# extract just the log message and strip out committer info.
Expand Down

0 comments on commit d4bd678

Please sign in to comment.