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

Re: [PATCH v3 2/3] sha1dc: optionally use sha1collisiondetection as a submodule

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 4, 2017, 22:50 UTC
Message-ID
<87fuebbyvl.fsf@gmail.com>
In-Reply-To
<xmqq4luskt9l.fsf@gitster.mtv.corp.google.com>
On Tue, Jul 04 2017, Junio C. Hamano jotted:
Show 23 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>>>> diff --git a/.gitmodules b/.gitmodules
>>>> new file mode 100644
>>>> index 0000000000..cbeebdab7a
>>>> --- /dev/null
>>>> +++ b/.gitmodules
>>>> @@ -0,0 +1,4 @@
>>>> +[submodule "sha1collisiondetection"]
>>>> +	path = sha1collisiondetection
>>>> +	url = https://github.com/cr-marcstevens/sha1collisiondetection.git
>>>> +	branch = master
>>>
>>> Do we need to say this "branch" bit?
>>
>> Yes, it's to make future updates easier, see b928922727 ("submodule add:
>> If --branch is given, record it in .gitmodules", 2012-12-19).
>
> Why?  It's not like we want to _follow_ the 'master' branch of that
> sha1collisiondetection repository.  We declare that a specific
> commit from the (sub)module is suited for our project, and do not
> really care to automatically update from whatever happens to be at
> the tip of 'master' there.

I'm honestly at a bit of a loss as to to what the confusion is here. So to try to unravel that let's start from square one, explaining some things you surely know already, but hopefully clearing this up.

> It's not like we want to _follow_ the 'master' branch of that
> sha1collisiondetection repository.

Git has no support at all for submodules that somehow follow an upstream branch in the SVN sense of remotes, so no, that's not what putting "branch" into the .gitmodules config means at all.

> We declare that a specific commit from the (sub)module is suited for
> our project, and do not really care to automatically update from
> whatever happens to be at the tip of 'master' there.

There is no automatic updating involved. The "master" branch here is just metadata. If and when we bump the sha1collisiondetection submodule that's going to be from the master branch, so by recording it we save ourselves one step (in theory) by issuing some "pull updates from the branch we always update from" command, rather than being at a loss as to where we should go from the currently detached ref to N potential upstream branches to update from.

Now, it seems git-submodule's tooling for doing this is still rather crappy, but I think that's the idea, maybe I'm just holding it wrong.

Before git ever got this "branch" key in .gitmodules I'd added it to my own aliases (and they're happily compatible with git-submodule). It still (for me) works better than what git-submodule does:

    $ git config alias.sm-mainbranch
    !git config --file ../.gitmodules submodule.$NAME.branch || git describe --all --always | sed 's!^heads/!!'
    $ git config alias.sm-pull-all
    !git submodule foreach 'git checkout $(NAME=$name git sm-mainbranch) && git pull'

So in a repo with submodules I can simply run "git sm-pull-all" and it'll update them all to the branch they're tracking, and at this point I can "git add" them and review the updates.

I think some invocation of "git submodule update ???" will do the same, but I can't from the docs see what that is right now.

In any case, if and when I/others figure that out the metadata will be there, saving us one step in updating this in the future.

>>
>>> Other than that looks good to me.
>>>
>>> Thanks.
Previous: Junio C HamanoNext: Stefan Beller
Message 32 of 50 in “Compile Error v2.13.2 on Solaris SPARC”
  1. Michael KebeJun 26, 2017
  2. 0/3 update sha1dc from PR #36Ævar Arnfjörð Bjarmason, Jun 27, 2017
  3. 1/3 sha1dc: update from my PR #36Ævar Arnfjörð Bjarmason, Jun 27, 2017
  4. Junio C HamanoJun 27, 2017
  5. Junio C HamanoJun 27, 2017
  6. Ævar Arnfjörð BjarmasonJun 27, 2017
  7. Junio C HamanoJun 27, 2017
  8. Liam R. HowlettJun 27, 2017
  9. Ævar Arnfjörð BjarmasonJun 27, 2017
  10. Junio C HamanoJun 27, 2017
  11. Junio C HamanoJun 27, 2017
  12. Ævar Arnfjörð BjarmasonJun 27, 2017
  13. Junio C HamanoJun 27, 2017
  14. Liam R. HowlettJun 27, 2017
  15. Junio C HamanoJun 27, 2017
  16. Ævar Arnfjörð BjarmasonJun 27, 2017
  17. Junio C HamanoJun 27, 2017
  18. Ævar Arnfjörð BjarmasonJun 27, 2017
  19. Junio C HamanoJun 27, 2017
  20. Junio C HamanoJun 27, 2017
  21. Ævar Arnfjörð BjarmasonJun 27, 2017
  22. 2/3 sha1dc: optionally use sha1collisiondetection as a submoduleÆvar Arnfjörð Bjarmason, Jun 27, 2017
  23. Stefan BellerJun 27, 2017
  24. Ævar Arnfjörð BjarmasonJun 27, 2017
  25. 3/3 sha1collisiondetection: automatically enable when submodule is populatedÆvar Arnfjörð Bjarmason, Jun 27, 2017
  26. Stefan BellerJun 27, 2017
  27. 0/3 Update sha1dc from upstreamÆvar Arnfjörð Bjarmason, Jul 1, 2017
  28. 2/3 sha1dc: optionally use sha1collisiondetection as a submoduleÆvar Arnfjörð Bjarmason, Jul 1, 2017
  29. Junio C HamanoJul 3, 2017
  30. Ævar Arnfjörð BjarmasonJul 3, 2017
  31. Junio C HamanoJul 4, 2017
  32. Ævar Arnfjörð BjarmasonJul 4, 2017
  33. Stefan BellerJul 5, 2017
  34. Junio C HamanoJul 5, 2017
  35. Stefan BellerJul 5, 2017
  36. Ævar Arnfjörð BjarmasonJul 5, 2017
  37. 1/3 sha1dc: update from upstreamÆvar Arnfjörð Bjarmason, Jul 1, 2017
  38. 3/3 sha1collisiondetection: automatically enable when submodule is populatedÆvar Arnfjörð Bjarmason, Jul 1, 2017
  39. Michael KebeJun 26, 2017
  40. Ævar Arnfjörð BjarmasonJun 26, 2017
  41. Michael KebeJun 26, 2017
  42. Ævar Arnfjörð BjarmasonJun 26, 2017
  43. Liam R. HowlettJun 26, 2017
  44. Michael KebeJun 27, 2017
  45. Michael KebeJun 27, 2017
  46. Liam R. HowlettJun 27, 2017
  47. Junio C HamanoJun 27, 2017
  48. Liam R. HowlettJun 27, 2017
  49. Ævar Arnfjörð BjarmasonJun 27, 2017
  50. Ævar Arnfjörð BjarmasonJun 27, 2017

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.