From: Junio C Hamano Date: Tue, 06 Dec 2011 21:50:58 GMT Subject: Re: [PATCHv2 12/13] credentials: add "store" helper Message-ID: <7vzkf5e5dp.fsf@alter.siamese.dyndns.org> In-Reply-To: <20111206062305.GL29233@sigill.intra.peff.net> Jeff King writes: > +static void store_credential(const char *fn, struct credential *c) > +{ > + struct strbuf buf = STRBUF_INIT; > + > + /* > + * Sanity check that what we are storing is actually sensible. > + * In particular, we can't make a URL without a protocol field. > + * Without either a host or pathname (depending on the scheme), > + * we have no primary key. And without a username and password, > + * we are not actually storing a credential. > + */ > + if (!c->protocol || !(c->host || c->path) || > + !c->username || !c->password) > + return; Very nicely explained. I wish all our patches had comments like this to explain tricky bit that looks as if the choice was arbitrarily made but in fact the logic was carefully constructed. Thanks.