Skip to content

Commit

Permalink
Merge git://git.bogomips.org/git-svn
Browse files Browse the repository at this point in the history
* git://git.bogomips.org/git-svn:
  git svn: fix dcommit to work with touched files
  git svn: add an option to recode pathnames
  • Loading branch information
Junio C Hamano committed Aug 2, 2010
2 parents 9f9aa76 + 181264a commit e7bdd1b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ svn.brokenSymlinkWorkaround::
revision fetched. If unset, 'git svn' assumes this option to
be "true".

svn.pathnameencoding::
This instructs git svn to recode pathnames to a given encoding.
It can be used by windows users and by those who work in non-utf8
locales to avoid corrupted file names with non-ASCII characters.
Valid encodings are the ones supported by Perl's Encode module.

Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and useSvmProps
options all affect the metadata generated and used by 'git svn'; they
*must* be set in the configuration file before any history is imported
Expand Down
10 changes: 10 additions & 0 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ sub cmd_set_tree {

sub cmd_dcommit {
my $head = shift;
command_noisy(qw/update-index --refresh/);
git_cmd_try { command_oneline(qw/diff-index --quiet HEAD/) }
'Cannot dcommit with a dirty index. Commit your changes first, '
. "or stash them with `git stash'.\n";
Expand Down Expand Up @@ -4050,6 +4051,7 @@ sub new {
$self->{absent_dir} = {};
$self->{absent_file} = {};
$self->{gii} = $git_svn->tmp_index_do(sub { Git::IndexInfo->new });
$self->{pathnameencoding} = Git::config('svn.pathnameencoding');
$self;
}

Expand Down Expand Up @@ -4133,6 +4135,10 @@ sub open_directory {

sub git_path {
my ($self, $path) = @_;
if (my $enc = $self->{pathnameencoding}) {
require Encode;
Encode::from_to($path, 'UTF-8', $enc);
}
if ($self->{path_strip}) {
$path =~ s!$self->{path_strip}!! or
die "Failed to strip path '$path' ($self->{path_strip})\n";
Expand Down Expand Up @@ -4521,6 +4527,10 @@ sub split_path {

sub repo_path {
my ($self, $path) = @_;
if (my $enc = $self->{pathnameencoding}) {
require Encode;
Encode::from_to($path, $enc, 'UTF-8');
}
$self->{path_prefix}.(defined $path ? $path : '');
}

Expand Down
11 changes: 11 additions & 0 deletions t/t9100-git-svn-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ test_expect_success 'able to dcommit to a subdirectory' "
test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\"
"

test_expect_success 'dcommit should not fail with a touched file' '
test_commit "commit-new-file-foo2" foo2 &&
test-chmtime =-60 foo &&
git svn dcommit
'

test_expect_success 'rebase should not fail with a touched file' '
test-chmtime =-60 foo &&
git svn rebase
'

test_expect_success 'able to set-tree to a subdirectory' "
echo cba > d &&
git update-index d &&
Expand Down

0 comments on commit e7bdd1b

Please sign in to comment.