Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  git-svn: don't sanitize remote names in config
  git-svn: avoid filling up the disk with temp files.
  git cat-file: Fix memory leak in batch mode
  fix git config example syntax
  avoid off-by-one error in run_upload_archive
  • Loading branch information
Junio C Hamano committed Jun 29, 2008
2 parents 861d1af + 7829f20 commit 8e69d78
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ have each person clone that repository with 'git clone':
cd project
git-init
git remote add origin server:/pub/project
git config --add remote.origin.fetch=+refs/remotes/*:refs/remotes/*
git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
git fetch
# Initialize git-svn locally (be sure to use the same URL and -T/-b/-t options as were used on server)
git-svn init http://svn.foo.org/project
Expand Down
1 change: 1 addition & 0 deletions builtin-cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
write_or_die(1, contents, size);
printf("\n");
fflush(stdout);
free(contents);
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion builtin-upload-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
if (argc != 2)
usage(upload_archive_usage);

if (strlen(argv[1]) > sizeof(buf))
if (strlen(argv[1]) + 1 > sizeof(buf))
die("insanely long repository name");

strcpy(buf, argv[1]); /* enter-repo smudges its argument */
Expand Down
20 changes: 7 additions & 13 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1462,13 +1462,6 @@ sub verify_remotes_sanity {
}
}

# we allow more chars than remotes2config.sh...
sub sanitize_remote_name {
my ($name) = @_;
$name =~ tr{A-Za-z0-9:,/+-}{.}c;
$name;
}

sub find_existing_remote {
my ($url, $remotes) = @_;
return undef if $no_reuse_existing;
Expand Down Expand Up @@ -2853,7 +2846,7 @@ sub _new {
unless (defined $ref_id && length $ref_id) {
$_[2] = $ref_id = $Git::SVN::default_ref_id;
}
$_[1] = $repo_id = sanitize_remote_name($repo_id);
$_[1] = $repo_id;
my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
$_[3] = $path = '' unless (defined $path);
mkpath(["$ENV{GIT_DIR}/svn"]);
Expand Down Expand Up @@ -3243,14 +3236,17 @@ sub close_file {
my ($tmp_fh, $tmp_filename) = File::Temp::tempfile(UNLINK => 1);
my $result;
while ($result = sysread($fh, my $string, 1024)) {
syswrite($tmp_fh, $string, $result);
my $wrote = syswrite($tmp_fh, $string, $result);
defined($wrote) && $wrote == $result
or croak("write $tmp_filename: $!\n");
}
defined $result or croak $!;
close $tmp_fh or croak $!;

close $fh or croak $!;

$hash = $::_repository->hash_and_insert_object($tmp_filename);
unlink($tmp_filename);
$hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n";
close $fb->{base} or croak $!;
} else {
Expand Down Expand Up @@ -4704,8 +4700,7 @@ sub minimize_connections {

# skip existing cases where we already connect to the root
if (($ra->{url} eq $ra->{repos_root}) ||
(Git::SVN::sanitize_remote_name($ra->{repos_root}) eq
$repo_id)) {
($ra->{repos_root} eq $repo_id)) {
$root_repos->{$ra->{url}} = $repo_id;
next;
}
Expand Down Expand Up @@ -4744,8 +4739,7 @@ sub minimize_connections {
foreach my $url (keys %$new_urls) {
# see if we can re-use an existing [svn-remote "repo_id"]
# instead of creating a(n ugly) new section:
my $repo_id = $root_repos->{$url} ||
Git::SVN::sanitize_remote_name($url);
my $repo_id = $root_repos->{$url} || $url;

my $fetch = $new_urls->{$url};
foreach my $path (keys %$fetch) {
Expand Down

0 comments on commit 8e69d78

Please sign in to comment.