Martin Waitz [off-list ref] writes:
What is stored in the supermodule? It stores a reference to a specific
point in the history of the submodule. As such I am convinced that
the right counterpart inside the submodule is a refs/heads/whatever,
and not the branch selector HEAD.
Because 'submodule' is a project on its own, it can make
progress while the parent project is still using the stable
commit. Think of this:
- Your application uses product of another project as a
library (e.g. you are doing video application and embedding
ffmpeg).
- Your 'master' commit records a commit in the library
subproject. Maybe library subproject declared stable 1.0 and
that is what you used to integrate.
- But being an independent project on its own, the library
project can make progress, outside the context of this
aggregated work (i.e. your application). Next time you do:
$ cd ffmpeg ; git fetch
there may not be any branch that points at the exact "stable 1.0"
commit.
When you do a "checkout -f --recurse-into-subprojects" from the
toplevel, I suspect that you would need to detach HEAD in the
subproject repository grafted in your application tree to move
it to the exact commit the toplevel project (i.e. your
application) wants, and match the working tree to that commit.
The toplevel simply should _not_ have to care what branch that
commit comes from.
hoi :)
On Wed, Apr 11, 2007 at 01:01:17PM -0700, Junio C Hamano wrote:
When you do a "checkout -f --recurse-into-subprojects" from the
toplevel, I suspect that you would need to detach HEAD in the
subproject repository grafted in your application tree to move
it to the exact commit the toplevel project (i.e. your
application) wants, and match the working tree to that commit.
The toplevel simply should _not_ have to care what branch that
commit comes from.
yes.
But why does everybody want to detach the submodule HEAD, instead
of creating one 'special' branch which holds the commit which is
used by the supermodule?
If you then want to switch to another submodule branch you loose
the reference that comes from the supermodule.
I want to create the extra branch exactly _because_ there is
independent work going on in the submodule (or the project it is
based on). As you can switch between detached HEAD and an
independent branch you can also switch between the 'supermodule branch'
and independent branches -- only that you can easily switch back
if you have an branch of your own.
BTW: I also think that your --recurse-into-subprojects should
be implied.
If you check out one index entry, you should be able to read it
back afterwards. That is a nice property everyone expects from
normal files and we should try to keep that for submodules.
When checkout_entry wants to touch a submodule we can simply rewrite
the 'supermodule branch' in the submodule. If HEAD happens to point
to it we also read-tree the submodule.
This is easy to understand and implement and I have some good experience
with this model.
--
Martin Waitz
On Thu, 12 Apr 2007, Martin Waitz wrote:
But why does everybody want to detach the submodule HEAD, instead
of creating one 'special' branch which holds the commit which is
used by the supermodule?
I don't think "everybody" wants it.
But the point is, *regardless* of whether you want a "detached HEAD" or
you want a "'special' branch", you should always use HEAD to look up the
commit, and using HEAD *allows* both (ie just make HEAD a symref to the
'special' branch if you want that behaviour).
And if you *do* use a special branch, HEAD *must* match that special
branch anyway, since when you commit in the supermodule, the only
behaviour that makes sense is to commit the currently checked out state!
I want to create the extra branch exactly _because_ there is
independent work going on in the submodule (or the project it is
based on).
And that is entirely appropriate.
But that still means that HEAD must point to that branch (when in the
submodule), since that branch must be the one that is checked out. If it
isn't the branch that is checked out, normal operations like "git diff"
etc wouldn't make sense from the supermodule.
And that is why *regardless* of whether you use a special branch or not,
HEAD is the right thing to look up.
Linus