diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-09-08 21:35:54 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-08 21:35:54 -0700 |
commit | 5e09f1dd30dea9647ee58556b90caefdd8533869 (patch) | |
tree | 1f9b05d6249c6cbb88a34a04b8f45a4839937fa3 | |
parent | Merge branch 'ms/document-pack-window-memory-is-per-thread' into maint (diff) | |
parent | import-tars: support hard links (diff) | |
download | tgif-5e09f1dd30dea9647ee58556b90caefdd8533869.tar.xz |
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
-rwxr-xr-x | contrib/fast-import/import-tars.perl | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 95438e1ed4..d60b4315ed 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -96,18 +96,21 @@ foreach my $tar_file (@ARGV) $mtime = oct $mtime; next if $typeflag == 5; # directory - 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; + if ($typeflag != 1) { # handle hard links later + 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"; } - print FI "\n"; my $path; if ($prefix) { @@ -115,7 +118,13 @@ foreach my $tar_file (@ARGV) } else { $path = "$name"; } - $files{$path} = [$next_mark++, $mode]; + + if ($typeflag == 1) { # hard link + $linkname = "$prefix/$linkname" if $prefix; + $files{$path} = [ $files{$linkname}->[0], $mode ]; + } else { + $files{$path} = [$next_mark++, $mode]; + } $author_time = $mtime if $mtime > $author_time; $path =~ m,^([^/]+)/,; |