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

Re: [PATCHv2 4/4] git submodule: Fix handling of // and /.. in paths for added submodules

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Feb 26, 2009, 09:05 UTC
Message-ID
<49A65B4C.305@drmicha.warpmail.net>
In-Reply-To
<7v1vtm1a6b.fsf@gitster.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 25.02.2009 22:25:
Show 42 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> Michael J Gruber schrieb:
>>> Johannes Sixt venit, vidit, dixit 25.02.2009 15:06:
>>>> I think we have so far avoided \+ in sed expressions for portability reasons.
>>> Hmmpf. Is it that new, or gnu specific? I'm always afraid of portability
>>> issues with bash but wasn't aware of sed being an issue as well.
>>>
>>> In any case, would 's|\\*|/|g' be better (more portable) then?
>> You mean 's|//*|/|g'; yes, that is definitly portable.
>>
>>> Well, how is
>>>
>>> echo a/b/c/../../d | sed -e ':start;s|\([^/]*\)/\.\./||g;tstart'
>>> a/d
>>>
>>> I meant: how portable is...
>> I don't know... Let's see: My AIX 4.3.3 sed understands it if it is not
>> all on a single line, and that says a lot. Specifically, I tried this:
>>
>> echo a/b/c/../../d | sed -e ':start
>>              s|\([^/]*\)/\.\./||
>>              tstart
>> '
>>
>> and got the desired result:
>>
>> a/d
>>
>> Note that the 'g' flag is not necessary in this case.
>>
>> OTOH, this sed doesn't understand #comments :-/
> 
> Historically, sed was much worse than the shell when it came to the
> portability issues, especially before people started to use bash, which
> tipped the balance a bit by worsening the situation for the shell side.
> 
> The sed scripts in the more important parts of scripted Porcelains avoid
> multiple commands on a single line concatenated with ";" mostly by inertia
> on my side, but it was acquired exactly from this kind of portability
> mess.  IIRC, AIX's was the worst offender. It also got "/A/../B/ { ... }"
> wrong in earlier versions.

I'm a bit confused now. Are you saying that "git-submodule.sh" should avoid the multiple lines in sed (which work in AIX 4.3.3)? I don't know how to simplify a/b/c/../../ easily then. Of course one could loop around in shell rather than using sed's "goto", but that looks ugly.

I think that's my only question before doing a v3 which will be a good "cd citizen" in tests and test for more idiosyncracies.

Oh wait: Would it be worthwhile to have that shell version of normalize_path_copy() in git-sh-setup instead?

Michael
Previous: Junio C HamanoNext: Junio C Hamano
Message 17 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.