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

Re: [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 3, 2009, 15:48 UTC
Message-ID
<49AD5159.8060605@drmicha.warpmail.net>
In-Reply-To
<7v3aduehz2.fsf@gitster.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 03.03.2009 16:36:
Show 27 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> Michael J Gruber schrieb:
>>> +	# normalize path:
>>> +	# multiple //; leading ./; /./; /../; trailing /
>>> +	path=$(printf '%s/\n' "$path" |
>>> +		sed -e '
>>> +			s|//*|/|g
>>> +			s|^\(\./\)*||
>>> +			s|/\./|/|g
>>> +			:start
>>> +			s|\([^/]*\)/\.\./||g
>> Sorry to say: not yet. This turns "a/b/c/d/../../../d" into "a/b/c/d"
>> instead of "a/d". Drop the 'g'.
>>
>> Once this is fixed, I have to ask what should happen with path names like
>> "../a/b", "../../a/b"? Should there be a warning or error?
>>
>> Other than that, this expression works on AIX 4.3.3! Note in particular
>> that '\n' in the printf format string is essential!
>>
>>> +			tstart
>>> +			s|/*$||
>>> +		')
> 
> At some point you should wonder if all of this complication is worth it,
> or it makes sense to reject when you see // or /\.\./ in the input.

I surely do wonder now! This started off treating merely leading ./ as reported problematic by AT. Then the "do it really right" competition started, and I think J6t and I came out as clear winners. There were no other contenders.

Seriously, "git submodule init" does that normalization (by using ls-files), so I think it does make sense to have it for add as well. git submodule itself may have semi-porc/semi-plumb character, but if someone wants to add submodules programmatically there is no simple way around using "git submodule add", and paths may very well be constructed relatively.

Michael
Previous: Junio C HamanoNext: Johannes Schindelin
Message 31 of 35 in “Fwd: Git Submodule Misbehaviour With ./”
  1. Andrei ThorpFeb 24, 2009
  2. 0/2 Fix git submodule add for paths with ./Michael J Gruber, Feb 25, 2009
  3. 1/2 git submodule: Add test cases for git submodule addMichael J Gruber, Feb 25, 2009
  4. 2/2 git submodule: Fix adding of submodules at paths with ./Michael J Gruber, Feb 25, 2009
  5. Johannes SixtFeb 25, 2009
  6. Michael J GruberFeb 25, 2009
  7. Johannes SixtFeb 25, 2009
  8. 0/4 Fix git submodule add for funky pathsMichael J Gruber, Feb 25, 2009
  9. 1/4 git submodule: Add test cases for git submodule addMichael J Gruber, Feb 25, 2009
  10. 2/4 git submodule: Fix adding of submodules at paths with ./Michael J Gruber, Feb 25, 2009
  11. 3/4 git submodule: Add more tests for add with funky pathsMichael J Gruber, Feb 25, 2009
  12. 4/4 git submodule: Fix handling of // and /.. in paths for added submodulesMichael J Gruber, Feb 25, 2009
  13. Johannes SixtFeb 25, 2009
  14. Michael J GruberFeb 25, 2009
  15. Johannes SixtFeb 25, 2009
  16. Junio C HamanoFeb 25, 2009
  17. Michael J GruberFeb 26, 2009
  18. Junio C HamanoFeb 26, 2009
  19. 0/2 git submodule: normalize paths before addingMichael J Gruber, Mar 3, 2009
  20. 1/2 git submodule: Add test cases for git submodule addMichael J Gruber, Mar 3, 2009
  21. 2/2 git submodule: Fix adding of submodules at paths with ./, .. and //Michael J Gruber, Mar 3, 2009
  22. Johannes SixtMar 3, 2009
  23. Michael J GruberMar 3, 2009
  24. 0/2 git submodule: normalize paths before addingMichael J Gruber, Mar 3, 2009
  25. 1/2 git submodule: Add test cases for git submodule addMichael J Gruber, Mar 3, 2009
  26. 2/2 git submodule: Fix adding of submodules at paths with ./, .. and //Michael J Gruber, Mar 3, 2009
  27. Johannes SixtMar 3, 2009
  28. Michael J GruberMar 3, 2009
  29. Junio C HamanoMar 3, 2009
  30. Junio C HamanoMar 3, 2009
  31. Michael J GruberMar 3, 2009
  32. Johannes SchindelinMar 3, 2009
  33. Michael J GruberMar 3, 2009
  34. Junio C HamanoFeb 25, 2009
  35. Junio C HamanoFeb 25, 2009

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.