| Summary: | eclass git-r3 fails while fetching git submodules with relative URLs | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Jan Huwald <jh> |
| Component: | Eclasses | Assignee: | Michał Górny <mgorny> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | jh |
| Priority: | Normal | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Attachments: |
Patch to canonize relative URLs of submodules to not contain ../ or ./
ebuild to demonstrate the flaw Patch to canonize relative URLs of submodules to not contain ../ or ./ - version 2 |
||
|
Description
Jan Huwald
2014-02-13 21:11:26 UTC
Created attachment 370350 [details, diff]
Patch to canonize relative URLs of submodules to not contain ../ or ./
This runs URLs obtained from relative submodule adresses through a newly defined canonize function the removes ./ and ../ in a way that the pointed location is constant.
For example:
/foo/bar/../baz -> /foo/baz
/foo/./bar -> foo/bar
The code is only briefly tested.
Created attachment 370352 [details]
ebuild to demonstrate the flaw
Please don't use sed, and use simple (and readable!) bash pattern substitution instead. Created attachment 370364 [details, diff]
Patch to canonize relative URLs of submodules to not contain ../ or ./ - version 2
On top of the previous patch:
- use bash patterns instead of sed
- declare subrepos as *local* var again
- increase stylistic conformance
extglob is not allowed either... especially that you're applying it to any further processes in the ebuild that may not be prepared to. Do you have a definite style guide to refer to? I do not see how to cleanly implement the substitution in bash without resorting to extglob. Something like [^/]+ (in PCRE lingo) is required. Of course I could restore the previous extglob state or - if the style guide guarantuees extglob disabled being the default state - just disable it after usage. (In reply to Jan Huwald from comment #6) > Do you have a definite style guide to refer to? No. Just make it as simple as possible, so that a 12-year old who haven't used Perl yet would look at it and know what's happening. You can use loops if that helps you. Also, just to be clear, how does git handle this itself? Does it canonicalize the URIs? + 01 Jun 2014; Michał Górny <mgorny@gentoo.org> git-r3.eclass, + +tests/git-r3:subrepos.sh: + Properly canonicalize relative submodule URIs, bug #501250. Sorry that it took this long. Please try now. There is small typo in the fix: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?r1=1.42&r2=1.43 828: git-r3_checkout ${url} .. Should use new ${subrepos[*]} Thanks for the report. + 20 Jun 2014; Michał Górny <mgorny@gentoo.org> git-r3.eclass: + Fix typo in submodule fetching, reported by Hans Vercammen. |