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

Re: [RFC] submodule: munge paths to submodule git directories

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 8, 2018, 00:14 UTC
Message-ID
<xmqq36vpk94c.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180807230637.247200-1-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> Introduce a function "strbuf_submodule_gitdir()" which callers can use
> to build a path to a submodule's gitdir.  This allows for a single
> location where we can munge the submodule name (by url encoding it)
> before using it as part of a path.

I am not sure about the name with "strbuf_" prefix; it is as bad as using hungarian notation for variable names.

There probably are some existing offenders, but it is merely an implementation detail (or a function signature) that the returned value is communicated using a strbuf (contrast it with things like strbuf_add() that is _about_ doing something to a strbuf), and in the longer term I prefer to see them lose "strbuf_" from their names and optionally use the same number of bytes to describe what they do more clearly. For this particular case, "submodule" and "gitdir" are sufficient to signal what the function is about, I think, so the "optionally use..." is not necessary---instead we get a name that is shorte to type and to remember.

> Using submodule names as is continues to be not such a good idea.  Maybe
> we could apply something like this to stop using them as is.  url
> encoding seems like the easiest approach, but I've also heard
> suggestions that would could use the SHA1 of the submodule name.
Being human readable is a good trait to keep when possible.  

When you have two submodules with vastly different names (e.g. "hello" and "bye"), and for some reason you need to go in to .gitmodules and manually fix their entries up, "hash of name" does not help you avoid mistakes (hashing "hello" and hashing "helo" would give a name as different as hashing "bye", so when you see [module "hel$something"] in .gitmodules, you would know that entry is not about the "bye" module, but "hello" module, even if you do not remember exactly if the module you want to manipulate was called "hello" or "helo"). The same discussion applies against UUID.

Previous: Jonathan NiederNext: Brandon Williams
Message 3 of 40 in “[RFC] submodule: munge paths to submodule git directories”
  1. Brandon WilliamsAug 7, 2018
  2. Jonathan NiederAug 7, 2018
  3. Junio C HamanoAug 8, 2018
  4. 0/2 munge submodule namesBrandon Williams, Aug 8, 2018
  5. 1/2 submodule: create helper to build paths to submodule gitdirsBrandon Williams, Aug 8, 2018
  6. Stefan BellerAug 8, 2018
  7. Brandon WilliamsAug 9, 2018
  8. Junio C HamanoAug 10, 2018
  9. Brandon WilliamsAug 10, 2018
  10. 2/2 submodule: munge paths to submodule git directoriesBrandon Williams, Aug 8, 2018
  11. Jeff KingAug 9, 2018
  12. Brandon WilliamsAug 14, 2018
  13. Jonathan NiederAug 14, 2018
  14. Stefan BellerAug 14, 2018
  15. Jonathan NiederAug 14, 2018
  16. Stefan BellerAug 14, 2018
  17. Jonathan NiederAug 16, 2018
  18. Stefan BellerAug 16, 2018
  19. Jonathan NiederAug 16, 2018
  20. Brandon WilliamsAug 16, 2018
  21. submodule: add config for where gitdirs are locatedBrandon Williams, Aug 16, 2018
  22. Junio C HamanoAug 20, 2018
  23. Junio C HamanoAug 16, 2018
  24. Jeff KingAug 14, 2018
  25. Stefan BellerAug 28, 2018
  26. Jeff KingAug 29, 2018
  27. Stefan BellerAug 29, 2018
  28. Jeff KingAug 29, 2018
  29. Stefan BellerAug 29, 2018
  30. Jonathan NiederAug 29, 2018
  31. Stefan BellerAug 29, 2018
  32. Jeff KingAug 29, 2018
  33. Jonathan NiederAug 29, 2018
  34. Stefan BellerAug 29, 2018
  35. Brandon WilliamsAug 29, 2018
  36. Jeff KingAug 29, 2018
  37. Aaron SchrabAug 16, 2018
  38. Jonathan NiederJan 15, 2019
  39. Jeff KingJan 17, 2019
  40. Stefan BellerJan 17, 2019

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.