git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remote.c: Fix overtight refspec validation

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 21, 2008, 23:59 UTC
Message-ID
<7vy78bmxx1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LNX.1.00.0803211840480.19665@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
Show 9 quoted lines
>> +		/*
>> +		 * Do we want to validate LHS?
>> + ...
>> +		 * Hence we check non-empty LHS for fetch, and
>> +		 * colonless or glob LHS for push here.
>> +		 */
>
> Wouldn't this be clearer and not meaningfully harder in 
> parse_fetch_refspec and parse_push_refspec?

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.

>> +		if (fetch ? (*rs[i].src) : (!rhs || is_glob)) {
>
> This is an odd combination of locals and struct members.
>                                        : (!rs[i].dst || rs[i].pattern) {
Sorry, I do not understand what's wrong about it.
	!!rhs === (did we see a colon) === !!rs[].dst
        is_glob === (did they both end with "/*") === rs[].pattern

They are equivalent, and local variables are primarily what the logic works on and bases its decisions to store what in rs[] structures.

Ahh...  do you mean:
	(*rs[i].src) === (is lhs non empty?) === !!llen
I guess using "llen" there is more consistent and is moderately cleaner.
Perhaps squash this as a clean-up?
diff --git a/remote.c b/remote.c
index 4117bfc..86113b7 100644
--- a/remote.c
+++ b/remote.c
@@ -453,7 +453,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
 		 * "empty" for removal) in LHS, and we cannot check
 		 * for error until it actually gets used.
 		 */
-		if (fetch ? (*rs[i].src) : (!rhs || is_glob)) {
+		if (fetch ? llen : (!rhs || is_glob)) {
 			st = check_ref_format(rs[i].src);
 			if (st && st != CHECK_REF_FORMAT_ONELEVEL)
 				goto invalid;
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 11 of 20 in “Permit refspec source side to parse as a sha1”
  1. Permit refspec source side to parse as a sha1Daniel Barkalow, Mar 21, 2008
  2. Junio C HamanoMar 21, 2008
  3. Junio C HamanoMar 21, 2008
  4. Daniel BarkalowMar 21, 2008
  5. Junio C HamanoMar 21, 2008
  6. Daniel BarkalowMar 21, 2008
  7. Junio C HamanoMar 21, 2008
  8. Daniel BarkalowMar 21, 2008
  9. remote.c: Fix overtight refspec validationJunio C Hamano, Mar 21, 2008
  10. Daniel BarkalowMar 21, 2008
  11. Junio C HamanoMar 21, 2008
  12. Daniel BarkalowMar 22, 2008
  13. Junio C HamanoMar 22, 2008
  14. Daniel BarkalowMar 22, 2008
  15. Linus TorvaldsMar 26, 2008
  16. Junio C HamanoMar 26, 2008
  17. Junio C HamanoMar 26, 2008
  18. Daniel BarkalowMar 26, 2008
  19. Junio C HamanoMar 26, 2008
  20. Jeff KingMar 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.