* [PATCH] import-tars: separate author from committer
@ 2009-03-20 9:57 Giuseppe Bilotta
2009-03-20 14:43 ` Shawn O. Pearce
0 siblings, 1 reply; 2+ messages in thread
From: Giuseppe Bilotta @ 2009-03-20 9:57 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Shawn O. Pearce, Giuseppe Bilotta
The import-tars script is typically employed to (re)create the past
history of a project from stored tars. Although assigning authorship in
these cases can be a somewhat arbitrary process, it makes sense to set
the author to whoever created the tars in the first place (if it's
known), and (s)he can in general be different from the committer
(whoever is running the script).
Implement this by having separate author and committer data, making them
settable from the usual GIT_* environment variables.
---
Or should I have made the ENV access a separate patch?
contrib/fast-import/import-tars.perl | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index 23aeb25..6309d14 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -14,13 +14,18 @@ die "usage: import-tars *.tar.{gz,bz2,Z}\n" unless @ARGV;
my $branch_name = 'import-tars';
my $branch_ref = "refs/heads/$branch_name";
-my $committer_name = 'T Ar Creator';
-my $committer_email = 'tar@example.com';
+my $author_name = $ENV{'GIT_AUTHOR_NAME'} || 'T Ar Creator';
+my $author_email = $ENV{'GIT_AUTHOR_EMAIL'} || 'tar@example.com';
+my $committer_name = $ENV{'GIT_COMMITTER_NAME'} || `git config --get user.name`;
+my $committer_email = $ENV{'GIT_COMMITTER_EMAIL'} || `git config --get user.email`;
+
+chomp($committer_name, $committer_email);
open(FI, '|-', 'git', 'fast-import', '--quiet')
or die "Unable to start git fast-import: $!\n";
foreach my $tar_file (@ARGV)
{
+ my $commit_time = time;
$tar_file =~ m,([^/]+)$,;
my $tar_name = $1;
@@ -39,7 +44,7 @@ foreach my $tar_file (@ARGV)
die "Unrecognized compression format: $tar_file\n";
}
- my $commit_time = 0;
+ my $author_time = 0;
my $next_mark = 1;
my $have_top_dir = 1;
my ($top_dir, %files);
@@ -92,7 +97,7 @@ foreach my $tar_file (@ARGV)
}
$files{$path} = [$next_mark++, $mode];
- $commit_time = $mtime if $mtime > $commit_time;
+ $author_time = $mtime if $mtime > $author_time;
$path =~ m,^([^/]+)/,;
$top_dir = $1 unless $top_dir;
$have_top_dir = 0 if $top_dir ne $1;
@@ -100,6 +105,7 @@ foreach my $tar_file (@ARGV)
print FI <<EOF;
commit $branch_ref
+author $author_name <$author_email> $author_time +0000
committer $committer_name <$committer_email> $commit_time +0000
data <<END_OF_COMMIT_MESSAGE
Imported from $tar_file.
@@ -119,7 +125,7 @@ EOF
print FI <<EOF;
tag $tar_name
from $branch_ref
-tagger $committer_name <$committer_email> $commit_time +0000
+tagger $author_name <$author_email> $author_time +0000
data <<END_OF_TAG_MESSAGE
Package $tar_name
END_OF_TAG_MESSAGE
--
1.6.2.254.g84bde
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] import-tars: separate author from committer
2009-03-20 9:57 [PATCH] import-tars: separate author from committer Giuseppe Bilotta
@ 2009-03-20 14:43 ` Shawn O. Pearce
0 siblings, 0 replies; 2+ messages in thread
From: Shawn O. Pearce @ 2009-03-20 14:43 UTC (permalink / raw)
To: Giuseppe Bilotta; +Cc: git, Junio C Hamano
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:
> The import-tars script is typically employed to (re)create the past
> history of a project from stored tars. Although assigning authorship in
> these cases can be a somewhat arbitrary process, it makes sense to set
> the author to whoever created the tars in the first place (if it's
> known), and (s)he can in general be different from the committer
> (whoever is running the script).
>
> Implement this by having separate author and committer data, making them
> settable from the usual GIT_* environment variables.
> ---
>
> Or should I have made the ENV access a separate patch?
Looks fine to me.
Acked-by: Shawn O. Pearce <spearce@spearce.org>
--
Shawn.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-20 14:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-20 9:57 [PATCH] import-tars: separate author from committer Giuseppe Bilotta
2009-03-20 14:43 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).