{"thread":{"id":"22697","subject":"[PATCH] import-tars: properly import git-archive tarballs","startedAt":"2010-02-17T19:20:52Z","lastAt":"2010-02-19T08:12:29Z","messageCount":6,"participants":["Gabriel","Peter Krefting"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"134884","messageId":"1266434452-14532-1-git-send-email-g2p.code@gmail.com","threadId":"22697","inReplyTo":null,"subject":"[PATCH] import-tars: properly import git-archive tarballs","fromName":"Gabriel","fromEmail":"g2p.code@gmail.com","sentAt":"2010-02-17T19:20:52Z","receivedAt":"2010-02-17T19:20:52Z","isPatch":true,"sender":{"key":"g2p.code@gmail.com","avatar":null},"body":"git-archive adds a special entry to the archives it creates,\npax_global_header, containing the SHA1 of the exported commit.\n\nimport-tars.perl extracted it as a file, the top directory of\nthe archive became a subdirectory, and files moved with every\nimported tarball.\n\nNow import-tars correctly ignores the comment.\n\nSigned-off-by: Gabriel <g2p.code@gmail.com>\n---\n contrib/fast-import/import-tars.perl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 95438e1..a5170a1 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -108,6 +108,7 @@ foreach my $tar_file (@ARGV)\n \t\t\t}\n \t\t}\n \t\tprint FI \"\\n\";\n+\t\tnext if $typeflag eq 'g' && $name eq 'pax_global_header';\n \n \t\tmy $path;\n \t\tif ($prefix) {\n-- \n1.7.0.rc2.31.g618d1\n"},{"id":"134937","messageId":"alpine.DEB.2.00.1002181037340.11095@ds9.cixit.se","threadId":"22697","inReplyTo":"1266434452-14532-1-git-send-email-g2p.code@gmail.com","subject":"Re: [PATCH] import-tars: properly import git-archive tarballs","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-02-18T09:40:13Z","receivedAt":"2010-02-18T09:40:13Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Gabriel:\n\n> git-archive adds a special entry to the archives it creates, \n> pax_global_header, containing the SHA1 of the exported commit.\n\nInteresting use-case.\n\n> Now import-tars correctly ignores the comment.\n\nIn the case where you actually would care, perhaps it should be added as a \ncomment to the default commit message? Something like \"Imported from \n$tar_file, created from commit $commit.\".\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"134966","messageId":"20100218140002.14f79853@gmail.com","threadId":"22697","inReplyTo":"1266434452-14532-1-git-send-email-g2p.code@gmail.com","subject":"Re: [PATCH] import-tars: properly import git-archive tarballs","fromName":"Gabriel","fromEmail":"g2p.code@gmail.com","sentAt":"2010-02-18T13:00:02Z","receivedAt":"2010-02-18T13:00:02Z","isPatch":true,"sender":{"key":"g2p.code@gmail.com","avatar":null},"body":"> Gabriel:\n> > git-archive adds a special entry to the archives it creates, \n> > pax_global_header, containing the SHA1 of the exported commit.\n> \n> Interesting use-case.\n\nMy use case really was a simple “import a range of tarballs for\nbisecting”. That they were from git was a surprise, but I don't have\naccess to that repo, which for all I know is full of junk and not meant\nfor publication, so I'm not trying to get the original history.\n\nI just want importing to work on tarballs found in the wild.\n\n> > Now import-tars correctly ignores the comment.\n> \n> In the case where you actually would care, perhaps it should be added\n> as a comment to the default commit message? Something like \"Imported\n> from $tar_file, created from commit $commit.\".\n\nSomeone with stronger perl-fu to parse the hash comment could print on\nstderr (keep me CC-ed if you do that):\n  This tarball was generated by git, from commit id $SHA1.\n\nIt will serve as a hint when the person doing the import has access to\nthe original history. I don't think there's a point in keeping a sha1\nwhen there's no access; keeping it in the history would confuse people,\nor require sticking a longer explanation to each of these commits.\n"},{"id":"134967","messageId":"20100218132709.8CEBA2FC07@perkele","threadId":"22697","inReplyTo":"20100218140002.14f79853@gmail.com","subject":"[PATCH] import-tars: Make it possible to include the original commit ID","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-02-18T13:24:21Z","receivedAt":"2010-02-18T13:24:21Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Add an option --readpax which makes import-tars read the commit ID\nstored by git-archive, adding it to the default commit message.\n\nSigned-off-by: Peter Krefting <peter@softwolves.pp.se>\n---\n> Someone with stronger perl-fu to parse the hash comment could print on\n> stderr (keep me CC-ed if you do that):\n>   This tarball was generated by git, from commit id $SHA1.\n\nActually, having this information could be useful, for instance to create\na \"history-skipping\" repository, and use bisect in that. When one finds\nwhich released version causes the problem, one can bisect in the\noriginal repository, using the commit ID indicated.\n\nThis applies on top of your patch.\n\n contrib/fast-import/import-tars.perl |   25 +++++++++++++++++++++++--\n 1 files changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex a5170a1..3451309 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -14,14 +14,20 @@\n ##\n ##  echo 'This is the commit message' > myfile.tar.bz2.msg\n ##  perl import-tars.perl --metainfo=msg myfile.tar.bz2\n+##\n+## Use --readpax to read the pax_global_header generated by git archive.\n+## The commit ID stored in the header will be appended to the default\n+## generated commit message for the imported tarball. If the parameter\n+## is not given, the pax_global_header is ignored.\n \n use strict;\n use Getopt::Long;\n \n my $metaext = '';\n+my $readpax;\n \n-die \"usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,lzma,xz,Z}\\n\"\n-\tunless GetOptions('metainfo=s' => \\$metaext) && @ARGV;\n+die \"usage: import-tars [--metainfo=extension] [--readpax] *.tar.{gz,bz2,lzma,xz,Z}\\n\"\n+\tunless GetOptions('metainfo=s' => \\$metaext, 'readpax' => \\$readpax) && @ARGV;\n \n my $branch_name = 'import-tars';\n my $branch_ref = \"refs/heads/$branch_name\";\n@@ -61,6 +67,7 @@ foreach my $tar_file (@ARGV)\n \tmy $author_time = 0;\n \tmy $next_mark = 1;\n \tmy $have_top_dir = 1;\n+\tmy $orig_commitid = '';\n \tmy ($top_dir, %files);\n \n \twhile (read(I, $_, 512) == 512) {\n@@ -95,6 +102,16 @@ foreach my $tar_file (@ARGV)\n \t\t$size = oct $size;\n \t\t$mtime = oct $mtime;\n \t\tnext if $typeflag == 5; # directory\n+\t\tif (defined $readpax && $typeflag eq 'g' && $name eq 'pax_global_header')\n+\t\t{\n+\t\t\twhile ($size > 0 && read(I, $_, 512) == 512) {\n+\t\t\t\tif (/52 comment=([0-9a-f]{40})/)\n+\t\t\t\t{\n+\t\t\t\t\t$orig_commitid = $1;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tnext;\n+\t\t}\n \n \t\tprint FI \"blob\\n\", \"mark :$next_mark\\n\";\n \t\tif ($typeflag == 2) { # symbolic link\n@@ -154,6 +171,10 @@ foreach my $tar_file (@ARGV)\n \t\t\tclose MSG;\n \t\t}\n \t}\n+\telsif ($orig_commitid ne '')\n+\t{\n+\t\t$commit_msg .= \"\\n\\nThis tarball was generated by git, from commit id\\n$orig_commitid.\";\n+\t}\n \n \tprint FI <<EOF;\n commit $branch_ref\n-- \n1.7.0\n"},{"id":"134973","messageId":"1266505333-20286-1-git-send-email-g2p.code@gmail.com","threadId":"22697","inReplyTo":"20100218132709.8CEBA2FC07@perkele","subject":"[PATCH] import-tars: Make it possible to include the original commit ID","fromName":"Gabriel","fromEmail":"g2p.code@gmail.com","sentAt":"2010-02-18T15:02:12Z","receivedAt":"2010-02-18T15:02:12Z","isPatch":true,"sender":{"key":"g2p.code@gmail.com","avatar":null},"body":"From: Peter Krefting <peter@softwolves.pp.se>\n\nAdd an option --readpax which makes import-tars read the commit ID\nstored by git-archive, adding it to the default commit message.\n\nSigned-off-by: Peter Krefting <peter@softwolves.pp.se>\nSigned-off-by: Gabriel <g2p.code@gmail.com>\n---\n\nThat's a sensible patch, thanks.\n\nA small correction; when both --readpax and --metainfo=msg are passed,\nincorporate both message and original sha1. I amended your commit.\n\n\n contrib/fast-import/import-tars.perl |   27 ++++++++++++++++++++++++---\n 1 files changed, 24 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex a5170a1..f41480e 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -14,14 +14,20 @@\n ##\n ##  echo 'This is the commit message' > myfile.tar.bz2.msg\n ##  perl import-tars.perl --metainfo=msg myfile.tar.bz2\n+##\n+## Use --readpax to read the pax_global_header generated by git archive.\n+## The commit ID stored in the header will be appended to the default\n+## generated commit message for the imported tarball. If the parameter\n+## is not given, the pax_global_header is ignored.\n \n use strict;\n use Getopt::Long;\n \n my $metaext = '';\n+my $readpax;\n \n-die \"usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,lzma,xz,Z}\\n\"\n-\tunless GetOptions('metainfo=s' => \\$metaext) && @ARGV;\n+die \"usage: import-tars [--metainfo=extension] [--readpax] *.tar.{gz,bz2,lzma,xz,Z}\\n\"\n+\tunless GetOptions('metainfo=s' => \\$metaext, 'readpax' => \\$readpax) && @ARGV;\n \n my $branch_name = 'import-tars';\n my $branch_ref = \"refs/heads/$branch_name\";\n@@ -61,6 +67,7 @@ foreach my $tar_file (@ARGV)\n \tmy $author_time = 0;\n \tmy $next_mark = 1;\n \tmy $have_top_dir = 1;\n+\tmy $orig_commitid = '';\n \tmy ($top_dir, %files);\n \n \twhile (read(I, $_, 512) == 512) {\n@@ -95,6 +102,16 @@ foreach my $tar_file (@ARGV)\n \t\t$size = oct $size;\n \t\t$mtime = oct $mtime;\n \t\tnext if $typeflag == 5; # directory\n+\t\tif (defined $readpax && $typeflag eq 'g' && $name eq 'pax_global_header')\n+\t\t{\n+\t\t\twhile ($size > 0 && read(I, $_, 512) == 512) {\n+\t\t\t\tif (/52 comment=([0-9a-f]{40})/)\n+\t\t\t\t{\n+\t\t\t\t\t$orig_commitid = $1;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tnext;\n+\t\t}\n \n \t\tprint FI \"blob\\n\", \"mark :$next_mark\\n\";\n \t\tif ($typeflag == 2) { # symbolic link\n@@ -124,7 +141,7 @@ foreach my $tar_file (@ARGV)\n \t\t$have_top_dir = 0 if $top_dir ne $1;\n \t}\n \n-\tmy $commit_msg = \"Imported from $tar_file.\";\n+\tmy $commit_msg = \"Imported from $tar_file.\\n\";\n \tmy $this_committer_name = $committer_name;\n \tmy $this_committer_email = $committer_email;\n \tmy $this_author_name = $author_name;\n@@ -154,6 +171,10 @@ foreach my $tar_file (@ARGV)\n \t\t\tclose MSG;\n \t\t}\n \t}\n+\tif ($orig_commitid ne '')\n+\t{\n+\t\t$commit_msg .= \"\\nThis tarball was generated by git, from commit id\\n$orig_commitid.\";\n+\t}\n \n \tprint FI <<EOF;\n commit $branch_ref\n-- \n1.7.0.rc2.31.g618d1\n"},{"id":"135060","messageId":"alpine.DEB.2.00.1002190911140.5644@ds9.cixit.se","threadId":"22697","inReplyTo":"1266505333-20286-1-git-send-email-g2p.code@gmail.com","subject":"Re: [PATCH] import-tars: Make it possible to include the original commit ID","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-02-19T08:12:29Z","receivedAt":"2010-02-19T08:12:29Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Gabriel:\n\n> A small correction; when both --readpax and --metainfo=msg are passed, \n> incorporate both message and original sha1. I amended your commit.\n\nMy initial thought was to let have the --metainfo message override the \nauto-generated message in its entirety, but I have no strong feelings either \nway, so i am OK with this change.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"}]}