Junio C Hamano <gitster@xxxxxxxxx> writes: >> while (strbuf_getline_lf(&line, fh) != EOF) { >> + lineno++; >> + if (!credential_from_url_gently(&entry, line.buf, 1)) { >> + if (entry.username && entry.password && >> + credential_match(c, &entry)) { >> + found_credential = 1; >> + if (match_cb) { >> + match_cb(&entry); >> + break; >> + } >> } >> } >> + else >> + warning(_("ignoring invalid credential in %s:%d"), >> + fn, lineno); >> + if (!found_credential && other_cb) >> other_cb(&line); >> } > > The above is harder to follow than necessary. > > while (... != EOF) { > lineno++; > if (credential is not well formed) { After reading your [2/2], I think this part deserves a bit of explanation. By "is not well formed", what I mean is not just credential_from_url_gently() returns non-zero, but also user/pass are specified. And your step [2/2] may make the condition for a line to be "well formed" even stricter by requiring at least one of host or path, and that would also belong to this test. > warning(_("ignoring...")); > } else if (the entry matches) { And the "entry matches" test here would only be "what does credential_match() say?" > found_credential = 1; > if (match_cb) { > match_cb(&entry); > break; /* stop at the first match */ > } > continue; > } > > if (other_cb) > other_cb(&line); > } > > may make the intention a bit clearer, with the loud "continue" inside. > > (1) we give warning for malformed one; and > (2) we do not let other_cb touch a matching entry.