{"thread":{"id":"24305","subject":"[PATCH 4/5] git-cvsserver: break the loop after successful hit","startedAt":"2010-07-06T17:38:09Z","lastAt":"2010-07-07T05:28:41Z","messageCount":2,"participants":["Áshin László","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"144929","messageId":"AANLkTik0pMkYDHZD9jgzn3OaGUdyeiFwAv7o3OTUmEvO@mail.gmail.com","threadId":"24305","inReplyTo":"-1324832183078898154@unknownmsgid","subject":"[PATCH 4/5] git-cvsserver: break the loop after successful hit","fromName":"Áshin László","fromEmail":"ashinlaszlo@gmail.com","sentAt":"2010-07-06T17:38:09Z","receivedAt":"2010-07-06T17:38:09Z","isPatch":true,"sender":{"key":"ashinlaszlo@gmail.com","avatar":null},"body":"No need to check for more lines of the authentication database after found a\nmatching one.\n---\n git-cvsserver.perl |    9 ++++-----\n 1 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex e842d77..cd461ac 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -248,11 +248,10 @@ if ($state->{method} eq 'pserver') {\n        my $auth_ok;\n        open my $passwd, \"<\", $authdb or die $!;\n        while (<$passwd>) {\n-            if (m{^\\Q$user\\E:(.*)}) {\n-                if (crypt($user, $password) eq $1) {\n-                    $auth_ok = 1;\n-                }\n-            };\n+            if (m{^\\Q$user\\E:(.*)} && crypt($user, $password) eq $1) {\n+                $auth_ok = 1;\n+                last;\n+            }\n        }\n        close $passwd;\n\n--\n1.7.0.4\n"},{"id":"145002","messageId":"7vwrt7zwqe.fsf@alter.siamese.dyndns.org","threadId":"24305","inReplyTo":"AANLkTik0pMkYDHZD9jgzn3OaGUdyeiFwAv7o3OTUmEvO@mail.gmail.com","subject":"Re: [PATCH 4/5] git-cvsserver: break the loop after successful hit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-07T05:28:41Z","receivedAt":"2010-07-07T05:28:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Áshin László <ashinlaszlo@gmail.com> writes:\n\n> No need to check for more lines of the authentication database after found a\n> matching one.\n\ns/found/finding/;\n\nBut I see a bigger issue here.  Is it plausible that you might want to\nallow two entries for one user, with two different passwords, in an authdb\nfile?  The current code allows it, but if we want to disallow it, we could\ninstead add your \"last\", like this, if you do not break the structure of\nthe conditional statements in the original code.\n\n\twhile (<$passwd>) {\n\t\tif (m{^\\Q$user\\E:(.*)}) {\n\t\t\tif (crypt($user, $password) eq $1) {\n\t\t\t\t$auth_ok = 1;\n\t\t\t}\n\t\t\tlast;\n\t\t}\n\t}\n\nOr have the \"last\" inside the inner \"if\" statement to keep that logic.\n\nEither way I think the original nested \"if\" is much easier to read than\nyour version.\n"}]}