[PATCH] Use GIT_COMMITTER_IDENT instead of hardcoded values in import-tars.perl
- From
Mike Hommey <mh@glandium.org>
- Date
- Sep 7, 2008, 08:52 UTC
- Message-ID
- <1220777531-28934-1-git-send-email-mh@glandium.org>
- In-Reply-To
- <7v3arixm8h.fsf@gitster.siamese.dyndns.org>
Signed-off-by: Mike Hommey <mh@glandium.org> ---
http://marc.info/?l=git&m=120385776127178&w=2:
Show 7 quoted lines
> > And that made me wonder if it wouldn't be worth, actually, to have > > git config user.name and git config user.email return the "magic" values > > gotten from guessing in ident.c when no value is in the config. That would > > allow scripts, which have no other simple means to get the user name and > > email, to have the same feature as builtins. > > Or perhaps use "git var GIT_COMMITTER_IDENT"?
The only problem I see with this approach is that lots of uses of GIT_COMMITTER_IDENT require regex'ing the output to remove the date (see git-am, old git-commit and git-tag...)
Maybe adding another variable not containing the date would be a good idea?
contrib/fast-import/import-tars.perl | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 23aeb25..814fb73 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -14,8 +14,9 @@ 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'; +chomp(my $committer_ident = `git var GIT_COMMITTER_IDENT`); +die 'You need to set user name and email' + unless ($committer_ident =~ s/(.+ <[^>]+>).*/\1/); open(FI, '|-', 'git', 'fast-import', '--quiet') or die "Unable to start git fast-import: $!\n"; @@ -100,7 +101,7 @@ foreach my $tar_file (@ARGV) print FI <<EOF; commit $branch_ref -committer $committer_name <$committer_email> $commit_time +0000 +committer $committer_ident $commit_time +0000 data <<END_OF_COMMIT_MESSAGE Imported from $tar_file. END_OF_COMMIT_MESSAGE @@ -119,7 +120,7 @@ EOF print FI <<EOF; tag $tar_name from $branch_ref -tagger $committer_name <$committer_email> $commit_time +0000 +tagger $committer_ident $commit_time +0000 data <<END_OF_TAG_MESSAGE Package $tar_name END_OF_TAG_MESSAGE
-- 1.6.0.2.g2ebc0