Re: [PATCH] git-submodule add: Record branch name in .gitmodules
- From
- Nahor <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