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

Re: [PATCH] git-submodule add: Record branch name in .gitmodules

From
NNahor <nahor.j+gmane@gmail.com>
Date
Oct 23, 2012, 19:16 UTC
Message-ID
<5086ED06.5020406@gmail.com>
In-Reply-To
<61a31f6bc61d4df322a097e32ba472390c583a81.1350923683.git.wking@tremily.us>
On 2012-10-22 09:34, W. Trevor King wrote:
Show 16 quoted lines
> From: "W. Trevor King" <wking@tremily.us>
>
> This removes a configuration step if you're trying to setup Ævar's
>
>    $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull'
>
> workflow from
>
>    commit f030c96d8643fa0a1a9b2bd9c2f36a77721fb61f
>    Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>    Date:   Fri May 21 16:10:10 2010 +0000
>
>      git-submodule foreach: Add $toplevel variable
>
> If you're not using that workflow, I see no harm in recording the
> branch used to determine the original submodule commit.

IMHO, the problem is that this works only for a very specific workflow. Normal git usage can very easily break this feature.

For instance, the module may later be updated to a commit in branch B instead of branch A. Unless you remember to also update .gitmodule, you have then inconsistent information.

A similar issue arises if branch A is deleted from the module later (for instance because it has been merged in the master branch and is not useful anymore). Then .gitmodule points to a non-existant branch. Same thing if a branch is renamed.

Last issue, the branch that exists in your local repository may not exist in someone else's repository, either because the branch is purely local, or because it has a different name on the remote repo.

I think a better place to store that kind of information is using git-notes. That way, if the branch is renamed or deleted, you can easily update the old notes to use the new name instead.

	Nahor
Previous: W. Trevor KingNext: W. Trevor King
Message 2 of 12 in “git-submodule add: Record branch name in .gitmodules”
  1. git-submodule add: Record branch name in .gitmodulesW. Trevor King, Oct 22, 2012
  2. NahorOct 23, 2012
  3. W. Trevor KingOct 23, 2012
  4. NahorOct 23, 2012
  5. Jens LehmannOct 23, 2012
  6. W. Trevor KingOct 23, 2012
  7. NahorOct 23, 2012
  8. Jens LehmannOct 24, 2012
  9. W. Trevor KingOct 22, 2012
  10. Phil HordOct 24, 2012
  11. W. Trevor KingOct 25, 2012
  12. Jeff KingOct 26, 2012

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.