{"thread":{"id":"18432","subject":"[PATCH] import-tars: separate author from committer","startedAt":"2009-03-20T09:57:50Z","lastAt":"2009-03-20T14:43:52Z","messageCount":2,"participants":["Giuseppe Bilotta","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108685","messageId":"1237543070-4909-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"18432","inReplyTo":null,"subject":"[PATCH] import-tars: separate author from committer","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-03-20T09:57:50Z","receivedAt":"2009-03-20T09:57:50Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"The import-tars script is typically employed to (re)create the past\nhistory of a project from stored tars. Although assigning authorship in\nthese cases can be a somewhat arbitrary process, it makes sense to set\nthe author to whoever created the tars in the first place (if it's\nknown), and (s)he can in general be different from the committer\n(whoever is running the script).\n\nImplement this by having separate author and committer data, making them\nsettable from the usual GIT_* environment variables.\n---\n\nOr should I have made the ENV access a separate patch?\n\n contrib/fast-import/import-tars.perl |   16 +++++++++++-----\n 1 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 23aeb25..6309d14 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -14,13 +14,18 @@ die \"usage: import-tars *.tar.{gz,bz2,Z}\\n\" unless @ARGV;\n \n my $branch_name = 'import-tars';\n my $branch_ref = \"refs/heads/$branch_name\";\n-my $committer_name = 'T Ar Creator';\n-my $committer_email = 'tar@example.com';\n+my $author_name = $ENV{'GIT_AUTHOR_NAME'} || 'T Ar Creator';\n+my $author_email = $ENV{'GIT_AUTHOR_EMAIL'} || 'tar@example.com';\n+my $committer_name = $ENV{'GIT_COMMITTER_NAME'} || `git config --get user.name`;\n+my $committer_email = $ENV{'GIT_COMMITTER_EMAIL'} || `git config --get user.email`;\n+\n+chomp($committer_name, $committer_email);\n \n open(FI, '|-', 'git', 'fast-import', '--quiet')\n \tor die \"Unable to start git fast-import: $!\\n\";\n foreach my $tar_file (@ARGV)\n {\n+\tmy $commit_time = time;\n \t$tar_file =~ m,([^/]+)$,;\n \tmy $tar_name = $1;\n \n@@ -39,7 +44,7 @@ foreach my $tar_file (@ARGV)\n \t\tdie \"Unrecognized compression format: $tar_file\\n\";\n \t}\n \n-\tmy $commit_time = 0;\n+\tmy $author_time = 0;\n \tmy $next_mark = 1;\n \tmy $have_top_dir = 1;\n \tmy ($top_dir, %files);\n@@ -92,7 +97,7 @@ foreach my $tar_file (@ARGV)\n \t\t}\n \t\t$files{$path} = [$next_mark++, $mode];\n \n-\t\t$commit_time = $mtime if $mtime > $commit_time;\n+\t\t$author_time = $mtime if $mtime > $author_time;\n \t\t$path =~ m,^([^/]+)/,;\n \t\t$top_dir = $1 unless $top_dir;\n \t\t$have_top_dir = 0 if $top_dir ne $1;\n@@ -100,6 +105,7 @@ foreach my $tar_file (@ARGV)\n \n \tprint FI <<EOF;\n commit $branch_ref\n+author $author_name <$author_email> $author_time +0000\n committer $committer_name <$committer_email> $commit_time +0000\n data <<END_OF_COMMIT_MESSAGE\n Imported from $tar_file.\n@@ -119,7 +125,7 @@ EOF\n \tprint FI <<EOF;\n tag $tar_name\n from $branch_ref\n-tagger $committer_name <$committer_email> $commit_time +0000\n+tagger $author_name <$author_email> $author_time +0000\n data <<END_OF_TAG_MESSAGE\n Package $tar_name\n END_OF_TAG_MESSAGE\n-- \n1.6.2.254.g84bde\n"},{"id":"108721","messageId":"20090320144352.GZ23521@spearce.org","threadId":"18432","inReplyTo":"1237543070-4909-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCH] import-tars: separate author from committer","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-20T14:43:52Z","receivedAt":"2009-03-20T14:43:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:\n> The import-tars script is typically employed to (re)create the past\n> history of a project from stored tars. Although assigning authorship in\n> these cases can be a somewhat arbitrary process, it makes sense to set\n> the author to whoever created the tars in the first place (if it's\n> known), and (s)he can in general be different from the committer\n> (whoever is running the script).\n> \n> Implement this by having separate author and committer data, making them\n> settable from the usual GIT_* environment variables.\n> ---\n> \n> Or should I have made the ENV access a separate patch?\n\nLooks fine to me.\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n-- \nShawn.\n"}]}