Skip to content

Commit

Permalink
import-tars: support symlinks
Browse files Browse the repository at this point in the history
Without this patch, symbolic links are turned into empty files.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jun 18, 2009
1 parent bc2bbc4 commit 6fb37f8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions contrib/fast-import/import-tars.perl
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,16 @@
$mtime = oct $mtime;
next if $typeflag == 5; # directory

print FI "blob\n", "mark :$next_mark\n", "data $size\n";
while ($size > 0 && read(I, $_, 512) == 512) {
print FI substr($_, 0, $size);
$size -= 512;
print FI "blob\n", "mark :$next_mark\n";
if ($typeflag == 2) { # symbolic link
print FI "data ", length($linkname), "\n", $linkname;
$mode = 0120000;
} else {
print FI "data $size\n";
while ($size > 0 && read(I, $_, 512) == 512) {
print FI substr($_, 0, $size);
$size -= 512;
}
}
print FI "\n";

Expand Down Expand Up @@ -118,7 +124,8 @@
{
my ($mark, $mode) = @{$files{$path}};
$path =~ s,^([^/]+)/,, if $have_top_dir;
printf FI "M %o :%i %s\n", $mode & 0111 ? 0755 : 0644, $mark, $path;
$mode = $mode & 0111 ? 0755 : 0644 unless $mode == 0120000;
printf FI "M %o :%i %s\n", $mode, $mark, $path;
}
print FI "\n";

Expand Down

0 comments on commit 6fb37f8

Please sign in to comment.