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

Re: [PATCH v3 2/2] submodule: drop the top-level requirement

From
Johannes Sixt <j6t@kdbg.org>
Date
Apr 19, 2013, 19:23 UTC
Message-ID
<517199AB.50109@kdbg.org>
In-Reply-To
<7vmwsu31vh.fsf@alter.siamese.dyndns.org>
Am 19.04.2013 18:45, schrieb Junio C Hamano:
Show 44 quoted lines
> John Keeping <john@keeping.me.uk> writes:
> 
>> On Thu, Apr 18, 2013 at 03:40:41PM -0700, Junio C Hamano wrote:
>>> John Keeping <john@keeping.me.uk> writes:
>>>
>>>> +relative_path ()
>>>> +{
>>>> +	local target curdir result
>>>> +	target=$1
>>>> +	curdir=${2-$wt_prefix}
>>>> +	curdir=${curdir%/}
>>>> +	result=
>>>> +
>>>> +	while test -n "$curdir"
>>>> +	do
>>>> +		case "$target" in
>>>> +		"$curdir/"*)
>>>> +			target=${target#$curdir/}
>>>> +			break
>>>> +			;;
>>>> +		esac
>>>
>>> Could $curdir have glob wildcard to throw this part of the logic
>>> off?  It is OK to have limitations like "you cannot have a glob
>>> characters in your path to submodule working tree" (at least until
>>> we start rewriting these in C or Perl or Python), but we need to be
>>> aware of them.
>>
>> I think the use of "#" instead of "##" saves us here because even with a
>> wildcard in $curdir the case statement matches literally, 
> 
> If you have curdir=a*b and target=adropb/c/d/e, the chopping itself
> 
> 	target=${target#$curdir/}
> 
> would happily chop "adropb/" from the target, but because the dq
> around "$curdir/"* in the case arm label enforces that target must
> literally match curdir followed by a slash, we do not even come to
> the chomping part.
> 
> I still have not convinced myself that it is impossible for somebody
> more clever than I to craft a pair of target and curdir that breaks
> it, though.  (target="a*b/c/d", curdir="a*b") is correctly chopped,
> so that is not it.
Why not just replace the six-liner by this one-liner:
		target=${target#"$curdir"/}
-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 33 of 39 in “submodule: drop the top-level requirement”
  1. 0/2 submodule: drop the top-level requirementJohn Keeping, Apr 7, 2013
  2. 1/2 rev-parse: add --filename-prefix optionJohn Keeping, Apr 7, 2013
  3. Jonathan NiederApr 7, 2013
  4. John KeepingApr 8, 2013
  5. Junio C HamanoApr 8, 2013
  6. John KeepingApr 8, 2013
  7. Junio C HamanoApr 8, 2013
  8. 2/2 submodule: drop the top-level requirementJohn Keeping, Apr 7, 2013
  9. Jens LehmannApr 7, 2013
  10. 0/2 submodule: drop the top-level requirementJohn Keeping, Apr 9, 2013
  11. 1/2 rev-parse: add --filename-prefix optionJohn Keeping, Apr 9, 2013
  12. Junio C HamanoApr 9, 2013
  13. John KeepingApr 9, 2013
  14. Junio C HamanoApr 9, 2013
  15. Ramkumar RamachandraApr 18, 2013
  16. John KeepingApr 18, 2013
  17. 2/2 submodule: drop the top-level requirementJohn Keeping, Apr 9, 2013
  18. Junio C HamanoApr 9, 2013
  19. John KeepingApr 9, 2013
  20. Ramkumar RamachandraApr 18, 2013
  21. John KeepingApr 18, 2013
  22. 0/2 submodule: drop the top-level requirementJohn Keeping, Apr 18, 2013
  23. 1/2 rev-parse: add --prefix optionJohn Keeping, Apr 18, 2013
  24. Ramkumar RamachandraApr 19, 2013
  25. John KeepingApr 19, 2013
  26. Ramkumar RamachandraApr 19, 2013
  27. John KeepingApr 19, 2013
  28. Ramkumar RamachandraApr 19, 2013
  29. 2/2 submodule: drop the top-level requirementJohn Keeping, Apr 18, 2013
  30. Junio C HamanoApr 18, 2013
  31. John KeepingApr 19, 2013
  32. Junio C HamanoApr 19, 2013
  33. Johannes SixtApr 19, 2013
  34. Junio C HamanoApr 19, 2013
  35. submodule: fix quoting in relative_path()John Keeping, Apr 24, 2013
  36. Junio C HamanoApr 24, 2013
  37. John KeepingApr 24, 2013
  38. Johannes SixtApr 24, 2013
  39. Eric SunshineApr 18, 2013

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.