Merge branch 'maint'

* 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
This commit is contained in:
Junio C Hamano 2008-06-28 21:08:35 -07:00
commit 8e69d78be3
4 changed files with 10 additions and 15 deletions

View File

@ -513,7 +513,7 @@ have each person clone that repository with 'git clone':
cd project cd project
git-init git-init
git remote add origin server:/pub/project 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 git fetch
# Initialize git-svn locally (be sure to use the same URL and -T/-b/-t options as were used on server) # 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 git-svn init http://svn.foo.org/project

View File

@ -181,6 +181,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
write_or_die(1, contents, size); write_or_die(1, contents, size);
printf("\n"); printf("\n");
fflush(stdout); fflush(stdout);
free(contents);
} }
return 0; return 0;

View File

@ -30,7 +30,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
if (argc != 2) if (argc != 2)
usage(upload_archive_usage); usage(upload_archive_usage);
if (strlen(argv[1]) > sizeof(buf)) if (strlen(argv[1]) + 1 > sizeof(buf))
die("insanely long repository name"); die("insanely long repository name");
strcpy(buf, argv[1]); /* enter-repo smudges its argument */ strcpy(buf, argv[1]); /* enter-repo smudges its argument */

View File

@ -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 { sub find_existing_remote {
my ($url, $remotes) = @_; my ($url, $remotes) = @_;
return undef if $no_reuse_existing; return undef if $no_reuse_existing;
@ -2853,7 +2846,7 @@ sub _new {
unless (defined $ref_id && length $ref_id) { unless (defined $ref_id && length $ref_id) {
$_[2] = $ref_id = $Git::SVN::default_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"; my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
$_[3] = $path = '' unless (defined $path); $_[3] = $path = '' unless (defined $path);
mkpath(["$ENV{GIT_DIR}/svn"]); mkpath(["$ENV{GIT_DIR}/svn"]);
@ -3243,7 +3236,9 @@ sub close_file {
my ($tmp_fh, $tmp_filename) = File::Temp::tempfile(UNLINK => 1); my ($tmp_fh, $tmp_filename) = File::Temp::tempfile(UNLINK => 1);
my $result; my $result;
while ($result = sysread($fh, my $string, 1024)) { 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 $!; defined $result or croak $!;
close $tmp_fh or croak $!; close $tmp_fh or croak $!;
@ -3251,6 +3246,7 @@ sub close_file {
close $fh or croak $!; close $fh or croak $!;
$hash = $::_repository->hash_and_insert_object($tmp_filename); $hash = $::_repository->hash_and_insert_object($tmp_filename);
unlink($tmp_filename);
$hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n"; $hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n";
close $fb->{base} or croak $!; close $fb->{base} or croak $!;
} else { } else {
@ -4704,8 +4700,7 @@ sub minimize_connections {
# skip existing cases where we already connect to the root # skip existing cases where we already connect to the root
if (($ra->{url} eq $ra->{repos_root}) || if (($ra->{url} eq $ra->{repos_root}) ||
(Git::SVN::sanitize_remote_name($ra->{repos_root}) eq ($ra->{repos_root} eq $repo_id)) {
$repo_id)) {
$root_repos->{$ra->{url}} = $repo_id; $root_repos->{$ra->{url}} = $repo_id;
next; next;
} }
@ -4744,8 +4739,7 @@ sub minimize_connections {
foreach my $url (keys %$new_urls) { foreach my $url (keys %$new_urls) {
# see if we can re-use an existing [svn-remote "repo_id"] # see if we can re-use an existing [svn-remote "repo_id"]
# instead of creating a(n ugly) new section: # instead of creating a(n ugly) new section:
my $repo_id = $root_repos->{$url} || my $repo_id = $root_repos->{$url} || $url;
Git::SVN::sanitize_remote_name($url);
my $fetch = $new_urls->{$url}; my $fetch = $new_urls->{$url};
foreach my $path (keys %$fetch) { foreach my $path (keys %$fetch) {