git-cvsserver: read from git with -z to get non-ASCII pathnames.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 10, 2006 at 11:53 UTC
e02cd6388f0193706279268a7d9fa57be4cbc997
1 file changed
+35
-28
git-cvsserver.perl
+35
-28
@@ -2331,67 +2331,72 @@ sub update
2331
2332
if ( defined ( $lastpicked ) )
2333
{
2334
- my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!");
2334
+ my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!");
2335
+ local ($/) = "\0";
2336
while ( <FILELIST> )
2337
{
2337
- unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)\s+(.*)$/o )
2338
+ chomp;
2339
+ unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)$/o )
2340
{
2341
die("Couldn't process git-diff-tree line : $_");
2342
}
2343
+ my ($mode, $hash, $change) = ($1, $2, $3);
2344
+ my $name = <FILELIST>;
2345
+ chomp($name);
2346
2342
- # $log->debug("File mode=$1, hash=$2, change=$3, name=$4");
2347
+ # $log->debug("File mode=$mode, hash=$hash, change=$change, name=$name");
2348
2349
my $git_perms = "";
2345
- $git_perms .= "r" if ( $1 & 4 );
2346
- $git_perms .= "w" if ( $1 & 2 );
2347
- $git_perms .= "x" if ( $1 & 1 );
2350
+ $git_perms .= "r" if ( $mode & 4 );
2351
+ $git_perms .= "w" if ( $mode & 2 );
2352
+ $git_perms .= "x" if ( $mode & 1 );
2353
$git_perms = "rw" if ( $git_perms eq "" );
2354
2350
- if ( $3 eq "D" )
2355
+ if ( $change eq "D" )
2356
{
2352
- #$log->debug("DELETE $4");
2353
- $head->{$4} = {
2354
- name => $4,
2355
- revision => $head->{$4}{revision} + 1,
2357
+ #$log->debug("DELETE $name");
2358
+ $head->{$name} = {
2359
+ name => $name,
2360
+ revision => $head->{$name}{revision} + 1,
2361
filehash => "deleted",
2362
commithash => $commit->{hash},
2363
modified => $commit->{date},
2364
author => $commit->{author},
2365
mode => $git_perms,
2366
};
2362
- $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2367
+ $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2368
}
2364
- elsif ( $3 eq "M" )
2369
+ elsif ( $change eq "M" )
2370
{
2366
- #$log->debug("MODIFIED $4");
2367
- $head->{$4} = {
2368
- name => $4,
2369
- revision => $head->{$4}{revision} + 1,
2370
- filehash => $2,
2371
+ #$log->debug("MODIFIED $name");
2372
+ $head->{$name} = {
2373
+ name => $name,
2374
+ revision => $head->{$name}{revision} + 1,
2375
+ filehash => $hash,
2376
commithash => $commit->{hash},
2377
modified => $commit->{date},
2378
author => $commit->{author},
2379
mode => $git_perms,
2380
};
2376
- $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2381
+ $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2382
}
2378
- elsif ( $3 eq "A" )
2383
+ elsif ( $change eq "A" )
2384
{
2380
- #$log->debug("ADDED $4");
2381
- $head->{$4} = {
2382
- name => $4,
2385
+ #$log->debug("ADDED $name");
2386
+ $head->{$name} = {
2387
+ name => $name,
2388
revision => 1,
2384
- filehash => $2,
2389
+ filehash => $hash,
2390
commithash => $commit->{hash},
2391
modified => $commit->{date},
2392
author => $commit->{author},
2393
mode => $git_perms,
2394
};
2390
- $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2395
+ $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2396
}
2397
else
2398
{
2394
- $log->warn("UNKNOWN FILE CHANGE mode=$1, hash=$2, change=$3, name=$4");
2399
+ $log->warn("UNKNOWN FILE CHANGE mode=$mode, hash=$hash, change=$change, name=$name");
2400
die;
2401
}
2402
}
@@ -2400,10 +2405,12 @@ sub update
2405
# this is used to detect files removed from the repo
2406
my $seen_files = {};
2407
2403
- my $filepipe = open(FILELIST, '-|', 'git-ls-tree', '-r', $commit->{hash}) or die("Cannot call git-ls-tree : $!");
2408
+ my $filepipe = open(FILELIST, '-|', 'git-ls-tree', '-z', '-r', $commit->{hash}) or die("Cannot call git-ls-tree : $!");
2409
+ local $/ = "\0";
2410
while ( <FILELIST> )
2411
{
2406
- unless ( /^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\s+(.*)$/o )
2412
+ chomp;
2413
+ unless ( /^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o )
2414
{
2415
die("Couldn't process git-ls-tree line : $_");
2416
}