git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: git@vger.kernel.org, Samuel Tardieu <sam@rfc1149.net>
Subject: Re: [PATCH] remote.c: Fix overtight refspec validation
Date: Sat, 22 Mar 2008 12:48:59 -0700	[thread overview]
Message-ID: <7viqzeilp0.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LNX.1.00.0803212021190.19665@iabervon.org> (Daniel Barkalow's message of "Fri, 21 Mar 2008 20:36:42 -0400 (EDT)")

Daniel Barkalow <barkalow@iabervon.org> writes:

> On Fri, 21 Mar 2008, Junio C Hamano wrote:
> ...
>> Do you mean you want the callers of this internal implementation to also
>> loop over the input set of refs?  I think that would be more complex code
>> but I do not see much gain by doing so.
>
> I think it's more breadth but less depth. It would make the internal 
> implementation not depend on fetch, and put the checks that only apply to 
> fetch out of the push code path and vice versa.
>
> Or just have a section
>
> 	if (fetch) {
> 		// checks for fetch LHS
> 		// checks for fetch RHS
> 	} else {
> 		// checks for push LHS
> 		// checks for push RHS
> 	}
>
> The body of the condition is only four lines, after all.

There are two commits on jc/refspec-fix branch merged to 'pu'.  The
earlier one is my version, and the one on top is based on the above
suggestion.  I do not know which one is clearer, more readable and
maintainable.

>> Ahh...  do you mean:
>> 
>> 	(*rs[i].src) === (is lhs non empty?) === !!llen
>> 
>> I guess using "llen" there is more consistent and is moderately cleaner.
>
> I'd go the other way, but having them all from the same set makes more 
> sense than one from one set and two from the other, regardless of which 
> way. If you go this way, you should probably also include the the rhs 
> checks, and the argument to check_ref_format().

It is very much sensible to look at either the local variables it used
during the parsing and the tentative result it produced while deciding
what to check and how, and it also is very sensible to validate what it
gives back to the user and/or what it knows is equal to what it gives back
to the user.  When they are equivalent, it is mostly a matter of taste
which to use for deciding and which to use for validating.  But it makes
more sense to prefer its local variables for logic to decide what to do
and how, and validate what we are actually going to give back.

If you mean to suggest to change parameter given to check_ref_format()
from rs[i].{src,dst} to something else based on the local variables we
used, that's backwards.

But we have already agreed that our brains are wired differently when it
comes to taste; I'd prefer not pursuing bikeshedding any further.

Unless your suggestion _isn't_ bikeshedding, that is.

What I did so far was to spend time to respond with code that fixes
existing breakages, while what you did so far was to kibitz instead of
showing code.  Showing code might make me realize that the way you may
want to go is more than bikeshedding and actual improvements to
readability and maintainability, but honestly speaking I am tired of
looking at this part of the code for now, so...

  reply	other threads:[~2008-03-22 19:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-21  0:54 [PATCH] Permit refspec source side to parse as a sha1 Daniel Barkalow
2008-03-21  4:10 ` Junio C Hamano
2008-03-21  4:50   ` Junio C Hamano
2008-03-21  5:09   ` Daniel Barkalow
2008-03-21  5:30     ` Junio C Hamano
2008-03-21  5:57       ` Daniel Barkalow
2008-03-21  6:26         ` Junio C Hamano
2008-03-21 16:08           ` Daniel Barkalow
2008-03-21 22:17             ` [PATCH] remote.c: Fix overtight refspec validation Junio C Hamano
2008-03-21 23:12               ` Daniel Barkalow
2008-03-21 23:59                 ` Junio C Hamano
2008-03-22  0:36                   ` Daniel Barkalow
2008-03-22 19:48                     ` Junio C Hamano [this message]
2008-03-22 20:45                       ` Daniel Barkalow
2008-03-26  1:45               ` Linus Torvalds
2008-03-26  3:31                 ` Junio C Hamano
2008-03-26  4:11                   ` Junio C Hamano
2008-03-26  5:42                     ` Daniel Barkalow
2008-03-26  5:46                       ` Junio C Hamano
2008-03-26  6:22                         ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7viqzeilp0.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=sam@rfc1149.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).