Skip to content

Commit 5e09f1d

Browse files
committed
Merge branch 'js/import-tars-hardlinks' into maint
"import-tars" fast-import script (in contrib/) used to ignore a hardlink target and replaced it with an empty file, which has been corrected to record the same blob as the other file the hardlink is shared with. * js/import-tars-hardlinks: import-tars: support hard links
2 parents c343e49 + 04e0869 commit 5e09f1d

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

contrib/fast-import/import-tars.perl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,35 @@
9696
$mtime = oct $mtime;
9797
next if $typeflag == 5; # directory
9898

99-
print FI "blob\n", "mark :$next_mark\n";
100-
if ($typeflag == 2) { # symbolic link
101-
print FI "data ", length($linkname), "\n", $linkname;
102-
$mode = 0120000;
103-
} else {
104-
print FI "data $size\n";
105-
while ($size > 0 && read(I, $_, 512) == 512) {
106-
print FI substr($_, 0, $size);
107-
$size -= 512;
99+
if ($typeflag != 1) { # handle hard links later
100+
print FI "blob\n", "mark :$next_mark\n";
101+
if ($typeflag == 2) { # symbolic link
102+
print FI "data ", length($linkname), "\n",
103+
$linkname;
104+
$mode = 0120000;
105+
} else {
106+
print FI "data $size\n";
107+
while ($size > 0 && read(I, $_, 512) == 512) {
108+
print FI substr($_, 0, $size);
109+
$size -= 512;
110+
}
108111
}
112+
print FI "\n";
109113
}
110-
print FI "\n";
111114

112115
my $path;
113116
if ($prefix) {
114117
$path = "$prefix/$name";
115118
} else {
116119
$path = "$name";
117120
}
118-
$files{$path} = [$next_mark++, $mode];
121+
122+
if ($typeflag == 1) { # hard link
123+
$linkname = "$prefix/$linkname" if $prefix;
124+
$files{$path} = [ $files{$linkname}->[0], $mode ];
125+
} else {
126+
$files{$path} = [$next_mark++, $mode];
127+
}
119128

120129
$author_time = $mtime if $mtime > $author_time;
121130
$path =~ m,^([^/]+)/,;

0 commit comments

Comments
 (0)