Code

git-cvsimport: fix handling of user name when it is not set in CVSROOT
authorGordon Hopper <g.hopper@computer.org>
Thu, 8 Nov 2007 20:15:20 +0000 (13:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Nov 2007 09:23:40 +0000 (01:23 -0800)
The cvs programs do not default to "anonymous" as the user name, but use the
currently logged in user.  This patch more closely matches the cvs behavior.

Signed-off-by: Gordon Hopper <g.hopper@computer.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-cvsimport.perl

index e4bc2b54f68930df217751975e32b4224f8d765c..efa6a0c41ad5a253047789e8ac2a30bf57f8646d 100755 (executable)
@@ -223,7 +223,8 @@ sub conn {
                        }
                }
 
-               $user="anonymous" unless defined $user;
+               # if username is not explicit in CVSROOT, then use current user, as cvs would
+               $user=(getlogin() || $ENV{'LOGNAME'} || $ENV{'USER'} || "anonymous") unless $user;
                my $rr2 = "-";
                unless ($port) {
                        $rr2 = ":pserver:$user\@$serv:$repo";