Skip to content

Commit 6fb37f8

Browse files
dschogitster
authored andcommitted
import-tars: support symlinks
Without this patch, symbolic links are turned into empty files. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc2bbc4 commit 6fb37f8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

contrib/fast-import/import-tars.perl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,16 @@
8282
$mtime = oct $mtime;
8383
next if $typeflag == 5; # directory
8484

85-
print FI "blob\n", "mark :$next_mark\n", "data $size\n";
86-
while ($size > 0 && read(I, $_, 512) == 512) {
87-
print FI substr($_, 0, $size);
88-
$size -= 512;
85+
print FI "blob\n", "mark :$next_mark\n";
86+
if ($typeflag == 2) { # symbolic link
87+
print FI "data ", length($linkname), "\n", $linkname;
88+
$mode = 0120000;
89+
} else {
90+
print FI "data $size\n";
91+
while ($size > 0 && read(I, $_, 512) == 512) {
92+
print FI substr($_, 0, $size);
93+
$size -= 512;
94+
}
8995
}
9096
print FI "\n";
9197

@@ -118,7 +124,8 @@
118124
{
119125
my ($mark, $mode) = @{$files{$path}};
120126
$path =~ s,^([^/]+)/,, if $have_top_dir;
121-
printf FI "M %o :%i %s\n", $mode & 0111 ? 0755 : 0644, $mark, $path;
127+
$mode = $mode & 0111 ? 0755 : 0644 unless $mode == 0120000;
128+
printf FI "M %o :%i %s\n", $mode, $mark, $path;
122129
}
123130
print FI "\n";
124131

0 commit comments

Comments
 (0)