{"thread":{"id":"12291","subject":"[PATCH] Use user.name and user.email in import-tars.perl","startedAt":"2008-02-24T12:57:18Z","lastAt":"2008-09-08T20:40:20Z","messageCount":6,"participants":["Mike Hommey","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"69784","messageId":"1203857838-29505-1-git-send-email-mh@glandium.org","threadId":"12291","inReplyTo":null,"subject":"[PATCH] Use user.name and user.email in import-tars.perl","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2008-02-24T12:57:18Z","receivedAt":"2008-02-24T12:57:18Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"Mimic what is done in git-import.sh and git-import.perl\n\nSigned-off-by: Mike Hommey <mh@glandium.org>\n---\n\n And that made me wonder if it wouldn't be worth, actually, to have\n git config user.name and git config user.email return the \"magic\" values\n gotten from guessing in ident.c when no value is in the config. That would\n allow scripts, which have no other simple means to get the user name and\n email, to have the same feature as builtins.\n\n contrib/fast-import/import-tars.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 23aeb25..39c091c 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -14,8 +14,10 @@ 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+chomp(my $committer_name = `git config user.name`);\n+chomp(my $committer_email = `git config user.email`);\n+die 'You need to set user name and email'\n+  unless $committer_name && $committer_email;\n \n open(FI, '|-', 'git', 'fast-import', '--quiet')\n \tor die \"Unable to start git fast-import: $!\\n\";\n-- \n1.5.4.1.48.g0d77\n"},{"id":"69806","messageId":"7v3arixm8h.fsf@gitster.siamese.dyndns.org","threadId":"12291","inReplyTo":"1203857838-29505-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Use user.name and user.email in import-tars.perl","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-24T18:06:38Z","receivedAt":"2008-02-24T18:06:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> Mimic what is done in git-import.sh and git-import.perl\n>\n> Signed-off-by: Mike Hommey <mh@glandium.org>\n> ---\n>\n>  And that made me wonder if it wouldn't be worth, actually, to have\n>  git config user.name and git config user.email return the \"magic\" values\n>  gotten from guessing in ident.c when no value is in the config. That would\n>  allow scripts, which have no other simple means to get the user name and\n>  email, to have the same feature as builtins.\n\nOr perhaps use \"git var GIT_COMMITTER_IDENT\"?\n"},{"id":"89961","messageId":"1220777531-28934-1-git-send-email-mh@glandium.org","threadId":"12291","inReplyTo":"7v3arixm8h.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Use GIT_COMMITTER_IDENT instead of hardcoded values in import-tars.perl","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2008-09-07T08:52:11Z","receivedAt":"2008-09-07T08:52:11Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"Signed-off-by: Mike Hommey <mh@glandium.org>\n---\n\nhttp://marc.info/?l=git&m=120385776127178&w=2:\n> >  And that made me wonder if it wouldn't be worth, actually, to have\n> > git config user.name and git config user.email return the \"magic\" values\n> > gotten from guessing in ident.c when no value is in the config. That would\n> > allow scripts, which have no other simple means to get the user name and\n> > email, to have the same feature as builtins.\n>\n> Or perhaps use \"git var GIT_COMMITTER_IDENT\"?\n\nThe only problem I see with this approach is that lots of uses of\nGIT_COMMITTER_IDENT require regex'ing the output to remove the date\n(see git-am, old git-commit and git-tag...)\n\nMaybe adding another variable not containing the date would be a\ngood idea?\n\n contrib/fast-import/import-tars.perl |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 23aeb25..814fb73 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -14,8 +14,9 @@ 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+chomp(my $committer_ident = `git var GIT_COMMITTER_IDENT`);\n+die 'You need to set user name and email'\n+\tunless ($committer_ident =~ s/(.+ <[^>]+>).*/\\1/);\n \n open(FI, '|-', 'git', 'fast-import', '--quiet')\n \tor die \"Unable to start git fast-import: $!\\n\";\n@@ -100,7 +101,7 @@ foreach my $tar_file (@ARGV)\n \n \tprint FI <<EOF;\n commit $branch_ref\n-committer $committer_name <$committer_email> $commit_time +0000\n+committer $committer_ident $commit_time +0000\n data <<END_OF_COMMIT_MESSAGE\n Imported from $tar_file.\n END_OF_COMMIT_MESSAGE\n@@ -119,7 +120,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 $committer_ident $commit_time +0000\n data <<END_OF_TAG_MESSAGE\n Package $tar_name\n END_OF_TAG_MESSAGE\n-- \n1.6.0.2.g2ebc0\n"},{"id":"89982","messageId":"7vy723nare.fsf@gitster.siamese.dyndns.org","threadId":"12291","inReplyTo":"1220777531-28934-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Use GIT_COMMITTER_IDENT instead of hardcoded values in import-tars.perl","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-07T17:09:25Z","receivedAt":"2008-09-07T17:09:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> Signed-off-by: Mike Hommey <mh@glandium.org>\n> ---\n>\n> http://marc.info/?l=git&m=120385776127178&w=2:\n>> >  And that made me wonder if it wouldn't be worth, actually, to have\n>> > git config user.name and git config user.email return the \"magic\" values\n>> > gotten from guessing in ident.c when no value is in the config. That would\n>> > allow scripts, which have no other simple means to get the user name and\n>> > email, to have the same feature as builtins.\n>>\n>> Or perhaps use \"git var GIT_COMMITTER_IDENT\"?\n>\n> The only problem I see with this approach is that lots of uses of\n> GIT_COMMITTER_IDENT require regex'ing the output to remove the date\n> (see git-am, old git-commit and git-tag...)\n>\n> Maybe adding another variable not containing the date would be a\n> good idea?\n\nLooking at the two patches side-by-side makes me think your original from\nfrom February actually is much better.\n\nWhy don't we apply your original, reproduced here for a quick round of\ncomment?\n\n-- >8 --\nFrom: Mike Hommey <mh@glandium.org>\nSubject: [PATCH] Use user.name and user.email in import-tars.perl\nDate: Sun, 24 Feb 2008 13:57:18 +0100\n\nMimic what is done in git-import.sh and git-import.perl\n\nSigned-off-by: Mike Hommey <mh@glandium.org>\n---\n contrib/fast-import/import-tars.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 23aeb25..39c091c 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -14,8 +14,10 @@ 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+chomp(my $committer_name = `git config user.name`);\n+chomp(my $committer_email = `git config user.email`);\n+die 'You need to set user name and email'\n+  unless $committer_name && $committer_email;\n \n open(FI, '|-', 'git', 'fast-import', '--quiet')\n \tor die \"Unable to start git fast-import: $!\\n\";\n"},{"id":"90086","messageId":"alpine.DEB.1.00.0809081649040.13830@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"12291","inReplyTo":"1220777531-28934-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Use GIT_COMMITTER_IDENT instead of hardcoded values in import-tars.perl","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-09-08T14:51:45Z","receivedAt":"2008-09-08T14:51:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 7 Sep 2008, Mike Hommey wrote:\n\n> -my $committer_name = 'T Ar Creator';\n> -my $committer_email = 'tar@example.com';\n> +chomp(my $committer_ident = `git var GIT_COMMITTER_IDENT`);\n> +die 'You need to set user name and email'\n> +\tunless ($committer_ident =~ s/(.+ <[^>]+>).*/\\1/);\n\nI have at least one script that will be broken by this change in behavior.\n\nTo me, the issue is just like git-cvsimport, which sets the committer not \nto the actual committer, so that two people can end up with identical \ncommit names, even if they cvsimported independently.  I'd like the same \nbehavior for import-tars.  I actually use it that way.\n\nCiao,\nDscho\n"},{"id":"90129","messageId":"7vzlmie5hn.fsf@gitster.siamese.dyndns.org","threadId":"12291","inReplyTo":"alpine.DEB.1.00.0809081649040.13830@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH] Use GIT_COMMITTER_IDENT instead of hardcoded values in import-tars.perl","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-08T20:40:20Z","receivedAt":"2008-09-08T20:40:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Sun, 7 Sep 2008, Mike Hommey wrote:\n>\n>> -my $committer_name = 'T Ar Creator';\n>> -my $committer_email = 'tar@example.com';\n>> +chomp(my $committer_ident = `git var GIT_COMMITTER_IDENT`);\n>> +die 'You need to set user name and email'\n>> +\tunless ($committer_ident =~ s/(.+ <[^>]+>).*/\\1/);\n>\n> I have at least one script that will be broken by this change in behavior.\n>\n> To me, the issue is just like git-cvsimport, which sets the committer not \n> to the actual committer, so that two people can end up with identical \n> commit names, even if they cvsimported independently.  I'd like the same \n> behavior for import-tars.  I actually use it that way.\n\nI sense there are conflicting goals here.\n\ncvsimport has partial information about the author (only short account\nname and nothing else), and by replicating them without taking them\nliterally you can achieve reproducibility.  On the other extreme is to use\nthe authorname mapping file to sacrifice reproducibility with other people\nthat do not have the identical author mapping file to obtain more readable\nresulting history with real names.  You can do both.\n\nWith the hardcoded 'T Ar Creator', you do not have any choice but strict\nreproducibility without readable names.  With Mike's original patch to\nmake it in line with git-import.{sh,perl}, you cannot still have both,\nbecause setting GIT_COMMITTER_NAME does not affect what user.name\nconfiguration says.  But with \"git var GIT_COMMITTER_IDENT\", you could.\n\nThis makes me wonder if it might be a better design to:\n\n * Make fast-import feeders to preserve as much information from the\n   source material but not from the environment.  This is half-similar in\n   spirit to what cvsimport does---it does not know the timezone so it\n   always uses GMT, and it uses the short account name because it is the\n   only thing available, but it does not use hardcoded \"cvs\", and the\n   environment can affect it further by setting up an author mapping\n   file.  Here I am saying a fast-import feeder shouldn't (and does not\n   have to) take the environment into account, if it does not have good\n   data in the source material.\n\n   In the context of importing tarballs, zipfiles and an existing directory\n   which is a tarball extract, there is not much authorship information in\n   the source material (each entry in a tarball may have the owner\n   information, but what if your tarball have more than one files, with\n   different owners?).\n\n * Invent a fast-import stream filter that allows you to munge authorship\n   and committer information selectively.  Splice that in to the pipeline\n   between the feeder and the fast-import, if you want the resulting\n   history more readable if desired (e.g. use author mapping file).\n\n   Or you can choose not to use such a filter, and get a reproducible\n   result.\n\nIf the \"filter\" turns out to be simple enough, it might even make sense to\nmake it part of the fast-import itself, but that is an implementation\ndetail.\n"}]}