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

Re: [PATCHv3] submodule--helper: normalize funny urls

From
Stefan Beller <sbeller@google.com>
Date
Oct 18, 2016, 23:25 UTC
Message-ID
<CAGZ79kZHLVpxbJ_C-dM2LDA64-_TJNyY+52fTWkOvLvvAq2XDg@mail.gmail.com>
In-Reply-To
<xmqqshrtnynj.fsf@gitster.mtv.corp.google.com>
On Tue, Oct 18, 2016 at 2:19 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Stefan Beller <sbeller@google.com> writes:
>>
>>> The remote URL for the submodule can be specified relative
>>> ...
>>> v3:
>>>  * fixed the coding style.
>>
>> Ah, thanks.  I had a squash queued on top but will replace with this
>> one.
>
> Heh, I guess I shouldn't have responded before seeing what this
> breaks.  Applied on top of sb/submodule-ignore-trailing-slash, these
> seem to break.
Ugh. (I should have tested more than just t0060).
The underlying issue is two fold:
* in t3600 we'd need
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index d046d98..545d32f 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -616,7 +616,7 @@ test_expect_success 'setup subsubmodule' '
        git submodule update &&
        (cd submod &&
                git update-index --add --cacheinfo 160000 $(git
rev-parse HEAD) subsubmod &&
-               git config -f .gitmodules submodule.sub.url ../. &&
+               git config -f .gitmodules submodule.sub.url ./. &&
                git config -f .gitmodules submodule.sub.path subsubmod &&
                git submodule init &&
                git add .gitmodules &&

because the sub-submodule URL is actually the same as the submodule
(because we'd test lazily)

This looks ok from a bug fixers perspective.

However in t7403, we have a construct like:

    git clone . super

which then results in

    git -C super remote -v
...../git/t/trash directory.t7403-submodule-sync/. (fetch)

And the commit message of this patch claimed we'd never use
the /. syntax ourselves. (We could argue the stupid users in the test
suite are doing it wrong, because in practice nobody would use clone
to create a nested repository? Not sure I agree.)

However instead of fixing the levels of nesting, the fix is as easy as:
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 0726799..525d32b 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -15,7 +15,9 @@ test_expect_success setup '
        git add file &&
        test_tick &&
        git commit -m upstream &&
-       git clone . super &&
+       # avoid cloning a repository with a url ending in /.
+       git clone . root &&
+       git clone root super &&
        git clone super submodule &&
        (
                cd submodule &&

Same goes for t740{6,7} as well as t7506.

I think this change to the test suite is not warranted, because
we want to have the current behavior as-is as it seems like a nice
hack:

* Maybe we'd want to think about checking for the URL in git clone
  normalize the URL before configuring remote.origin.URL

* an often observed work flow for submodule tests seems:

    mkdir sub1 &&
    git -C sub1 init  &&
    ...

    git clone . super &&
    git -C super submodule add ../sub1
    ... # the ../sub1 looks intuitively correct
    # because from the current directory which is
    # super the relative path is ../sub1
    #
    # However in reality this ought to be a relative URL,
    # and as super sits in the same directory as sub1
    # ./sub1 would be "correct" according to the documentation
    # However as the super remote URL ends with /.
    # we had a bug that we needed to add one layer of unnesting
    # and that is how ../sub1 worked.


Not sure about this patch any more.

Stefan
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 12 in “[PATCHv3] submodule--helper: normalize funny urls”
  1. Stefan BellerOct 18, 2016
  2. Junio C HamanoOct 18, 2016
  3. Junio C HamanoOct 18, 2016
  4. Stefan BellerOct 18, 2016
  5. Junio C HamanoOct 19, 2016
  6. Stefan BellerOct 19, 2016
  7. Junio C HamanoOct 19, 2016
  8. Stefan BellerOct 20, 2016
  9. Junio C HamanoOct 20, 2016
  10. Stefan BellerOct 20, 2016
  11. Junio C HamanoOct 20, 2016
  12. Stefan BellerOct 21, 2016

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.