git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Martin Waitz <tali@admingilde.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>, Junio C Hamano <junkio@cox.net>
Subject: Re: [PATCH 6/6] Teach core object handling functions about gitlinks
Date: Thu, 12 Apr 2007 01:54:50 +0200	[thread overview]
Message-ID: <20070411235447.GO21701@admingilde.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0704110753360.6730@woody.linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 9635 bytes --]

hoi :)

On Wed, Apr 11, 2007 at 08:16:10AM -0700, Linus Torvalds wrote:
> Branches in submodules actually in many ways are *more* important than 
> branches in supermodules - it's just that with the CVS mentality, you 
> would never actually see that, because CVS obviously doesn't really 
> support such a notion.

I fully agree with you about the importance of submodule branches.
In fact, I want to make them even more important and useable!

And by the way, I long forgot about CVS ;-)


> So I'd argue that branches in submodules give you:
> 
>  - you can develop the submodule *independently* of the supermodule, but 
>    still be able to easily merge back and forth.
> 
>    Quite often, the submodule would be developed entirely _outside_ of the 
>    supermodule, and the "branch" that gets the most development would thus
>    actually be the "vendor branch", entirely outside the supermodule. Call 
>    that the "main" branch or whatever, inside the supermodule it would 
>    often be something like the remote "remotes/origin/master" branch.
> 
>    So inside the supermodule, the HEAD would generally point to something 
>    that is *not* necessarily the "main development" branch, because the 
>    supermodule maintainer would quite logically and often have his own 
>    modifications to the original project on that branch. It migth be a 
>    detached branch, or just a local branch inside the submodule.

I fully agree.

>  - branches inside submodules are *also* very useful even inside the 
>    supermodule, ie they again allow topic work to be fetched into the
>    submodule *without* having to actually be part of the supermodule,
>    or as a way to track a certain experimental branch of the supermodule.
> 
>    I suspect that most supermodule usage is as an "integrator" branch, 
>    which means that the supermodule tends to follow the "main 
>    development", and the whole point of the supermodule is largely to have 
>    a collection of "stable things that work together". 
> 
>    In contrast, branches within submodules are useful for doing all the 
>    development that is *not* yet ready to be committed to the supermodule, 
>    exactly because it's not yet been tested in the full "make World" kind 
>    of situation.

I fully agree.
You are just so much better in describing things than I am...

> > Whenever you do a checkout in the supermodule you also have to update
> > the submodule and this update has to change the same thing which is read
> > above.
> 
> I suspect (but will not guarantee) that the right approach is that a 
> supermodule checkout usually just uses a "detached HEAD" setup. Within the 
> context of the supermodule, only the actual commit SHA1 matters, not what 
> branch it was developed on (side note: I haven't decided if we should 
> allow the SHA1 to be a signed tag object too - the current patches 
> obviously don't care since they never follow the SHA1 anyway, and it might 
> be a good idea).

If you use a detached HEAD then you can no longer switch back to it
once you used some other (independent) branch (for testing or whatever).
This is my main argument: If you just update some 'special'
refs/heads/from-supermodule (or whatever, maybe get it from
.gitmodules/config) you can still switch between branches, making them
more useful IMHO.

If we create some other way to easily get to the commit referenced by
the index of the supermodule then a detached HEAD is ok for me, too.
But why create two things (this not-yet-existing way to get the
supermodule index entry, plus submodules HEAD) for the same thing?
Why not simply create a new refs/heads/whatever?
This is easy and everybody knows how to work with it.

> So I strongly suspect (and that is what the patch series embodies) that as 
> far as the supermodule is concerned, it should *not* matter at all what 
> branch the subproject was on. The subproject can use branches for 
> development, and the supermodule really doesn't care what the local 
> branchname was when a commit was made - because branch-names are *local* 
> things, and a branch that is called "experimental" in one environment 
> might be called "master" in another.

Fully agree.

Please don't confuse my "I always want to use one dedicated branch" with
"I always want to use one special branch from the submodule project".
This refs/heads/whatever I am talking about is _purely_ for ease of
use of the submodule inside the supermodule.  It is in no way linked
to the branchnames that are used by the submodule project.
Well, besides that you can merge back and forth between them, of course.

> So once the commit hits the superproject, the branch identities just go 
> away (only as far as the superproject is concerned, of course - the 
> subproject still stays with whatever branches it has), and the only thing 
> that matters is the commit SHA1.

Fully agree.

> > Updating the branch which HEAD points to is dangerous.
> 
> I would strongly suggest that the *superproject* never really change the 
> status of the subproject HEAD, except it updates it for "pull/reset", and 
> then it just would use whatever the subproject decided to use.
> 
> The subproject HEAD policy would be entirely under the control of the 
> subproject. If the subproject wants to use a branch to track the 
> superproject, go wild: have a real branch that is called "my-integration" 
> and make HEAD a symref to that (and thus any work in the superproject will 
> update that branch - something that is visible when you pull directly from 
> that subproject!)

So you now have this nice "my-integration" branch lying next to other
independent (not-supermodule-related) branches.
If you want to _switch_ to one of these unrelated branches you obviously
have to change HEAD, and suddenly your unrelated branches are
considered to be part of the supermodule (ok, not yet part of its
index of course, but now all supermodule operations would work on
this unrelated branch).

I want to preserve these unrelated branches and see them as a strong
feature.  Branches in submodules should be independent from the
supermodule _because_ the supermodule has no notion of which branch
is used.

> But quite often, I suspect that a subproject would just use a detached 
> HEAD. The subproject may have branches of its own, of course, but you can 
> think of HEAD as not being connected to any of it's "own" branches, but 
> simply being the "superproject branch". That's a fairly accurate picture 
> of reality, and using "detached HEAD" sounds like a very natural thing to 
> do in that situation.

Only that you loose your nice detached HEAD view once you start using
those nice branches inside your submodule.

> So I really think you can do both, and I think using HEAD inside the 
> superproject gives you exactly that flexibility - you can decide on a 
> per-subproject basis whether HEAD should track a real local branch in a 
> subproject, or whether it should be detached.
> 
> (Side note: if you do *not* use detatched HEAD, I suspect the .gitmodules 
> file could also contain the branchname to be used for the subproject 
> tracking, but I think that's a detail, and quite debatable)
> 
> > So my advice is:
> > Always read and write one dedicated branch (hardcoded "master" or
> > configurable) when the supermodule wants to access a submodule.
> 
> So the main reasons I don't think that is a good idea are:
> 
>  - it's less flexible: see above on why you might want to use a dedicated 
>    branch *or* just detached HEAD, and why you might want to choose your 
>    own name for the dedicated branch.

In terms of flexibility it is important what you can do with the
submodule.  Being able to use branches just like in a normal
repository ("switch the branch to go to an other, unrelated branch")
is a plus for me.

A detached HEAD does not give the same level of flexibility as a real
head.

>  - it's also going to be quite confusing when the superproject sees 
>    something *else* than what is actually checked out.

Well, the user explicitly expressed his intent to switch to another
branch!  In a normal repository you are not confused about the working
directory not being in sync with "master", and we always prominently state
which branch you are on.  Of course this has to be clear for submodules,
too.  So if you do git-status in the supermodule it should print some
"submodule is on different branch"-dirty marker.

At least I had some situations where I wanted to use something like
this: use some experimental brach which should not be directly touched
by the supermodule.  Instead provide a method ("git merge
from-supermodule") to sync your working branch with new stuff from
the supermodule.

>    This is an equally strong argument for just using HEAD - when we
>    actually implement a
> 
> 	 git diff --subproject
> 
>    flag that recurses into the subproject, if you don't use HEAD inside 
>    the subproject, that suddenly becomes a *very* confusing thing.

This is right.  Suddenly we have one more player in the field which
you can diff against.

Before submodules:
tree <-> index <-> working file

submodules always using HEAD:
tree <-> index <-> submodule HEAD <-> submodule working dir

submodules using some dedicated branch:
tree <-> index <-> subm. "from-supermodule" <-> subm. HEAD <-> subm. wd

I haven't thought about which diff really makes sense in which
situation.


-- 
Martin Waitz

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2007-04-11 23:54 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10  4:12 [PATCH 0/6] Initial subproject support (RFC?) Linus Torvalds
     [not found] ` <Pi ne.LNX.4.64.0704092115020.6730@woody.linux-foundation.org>
2007-04-10  4:13 ` [PATCH 1/6] diff-lib: use ce_mode_from_stat() rather than messing with modes manually Linus Torvalds
2007-04-10  4:13 ` [PATCH 2/6] Avoid overflowing name buffer in deep directory structures Linus Torvalds
2007-04-10  4:14 ` [PATCH 3/6] Add 'resolve_gitlink_ref()' helper function Linus Torvalds
2007-04-10  9:38   ` Alex Riesen
2007-04-10 14:58     ` Linus Torvalds
2007-04-10 15:35       ` Alex Riesen
2007-04-10 15:52         ` Linus Torvalds
2007-04-10 15:57           ` Alex Riesen
2007-04-10 16:16             ` Linus Torvalds
2007-04-10 15:54       ` Josef Weidendorfer
2007-04-10  4:14 ` [PATCH 4/6] Add "S_IFDIRLNK" file mode infrastructure for git links Linus Torvalds
2007-04-10  4:15 ` [PATCH 5/6] Teach "fsck" not to follow subproject links Linus Torvalds
2007-04-11 22:41   ` Sam Vilain
2007-04-11 22:48     ` Linus Torvalds
2007-04-11 22:59       ` Sam Vilain
2007-04-11 23:16         ` Linus Torvalds
2007-04-11 23:05           ` David Lang
2007-04-11 23:53             ` Linus Torvalds
2007-04-11 23:30               ` David Lang
2007-04-12  2:14                 ` Linus Torvalds
2007-04-12  2:30                   ` Junio C Hamano
2007-04-12 17:18                   ` David Lang
2007-04-12 18:32                   ` Dana How
2007-04-12 19:17                     ` Linus Torvalds
2007-04-13  9:00                       ` Rogan Dawes
2007-04-13 15:23                         ` Linus Torvalds
2007-04-15  6:50                       ` Dana How
2007-04-12  0:00               ` Dana How
2007-04-12  0:03               ` Sam Vilain
2007-04-12  0:34           ` Junio C Hamano
2007-04-12  1:52             ` Linus Torvalds
2007-04-12  2:00               ` Junio C Hamano
2007-04-12  2:06                 ` Junio C Hamano
2007-04-12  2:28                   ` Linus Torvalds
2007-04-11 23:30         ` Dana How
2007-04-10  4:20 ` [PATCH 6/6] Teach core object handling functions about gitlinks Linus Torvalds
2007-04-10  8:40   ` Frank Lichtenheld
2007-04-10 11:31     ` Alex Riesen
2007-04-10 14:55     ` Linus Torvalds
2007-04-10 16:28   ` Josef Weidendorfer
2007-04-10 16:50     ` Alex Riesen
2007-04-10 17:23       ` Josef Weidendorfer
2007-04-10 18:45     ` Linus Torvalds
2007-04-10 19:04       ` Andy Parkins
2007-04-10 19:20         ` Linus Torvalds
2007-04-10 20:19           ` Junio C Hamano
2007-04-10 20:33             ` Linus Torvalds
2007-04-12  0:12               ` Sam Vilain
2007-04-12  0:35                 ` Martin Waitz
2007-04-12  2:01                 ` Linus Torvalds
2007-04-12  3:56                   ` Sam Vilain
2007-04-10 19:41         ` David Lang
2007-04-10 20:06         ` Junio C Hamano
2007-04-10 19:29       ` Josef Weidendorfer
2007-04-10 19:45         ` Linus Torvalds
2007-04-11 23:47           ` Sam Vilain
2007-04-12  0:13             ` Linus Torvalds
2007-04-12  0:42       ` Torgil Svensson
2007-04-12  0:56         ` Martin Waitz
2007-04-12 21:23           ` Torgil Svensson
2007-04-11 23:36     ` Sam Vilain
2007-04-11  8:06   ` Martin Waitz
2007-04-11  8:29     ` Alex Riesen
2007-04-11  8:36       ` Martin Waitz
2007-04-11  8:49         ` Alex Riesen
2007-04-11  9:20           ` Martin Waitz
2007-04-11  9:15         ` Junio C Hamano
2007-04-11 10:03           ` Martin Waitz
2007-04-11 20:01             ` Junio C Hamano
2007-04-11 22:19               ` Martin Waitz
2007-04-11 22:36                 ` Linus Torvalds
2007-04-11  9:47     ` Andy Parkins
2007-04-11 11:31       ` Martin Waitz
2007-04-11 15:16     ` Linus Torvalds
2007-04-11 22:49       ` Sam Vilain
2007-04-11 23:54       ` Martin Waitz [this message]
2007-04-12  1:57         ` Brian Gernhardt
2007-04-12 15:12         ` Josef Weidendorfer
2007-04-10  4:46 ` [PATCH 0/6] Initial subproject support (RFC?) Linus Torvalds
2007-04-10 13:04   ` Alex Riesen
2007-04-10 15:13     ` Linus Torvalds
2007-04-10 15:48       ` Alex Riesen
2007-04-10 16:07         ` Linus Torvalds
2007-04-10 16:43           ` Alex Riesen
2007-04-10 19:32           ` Junio C Hamano
2007-04-10 20:11             ` Linus Torvalds
2007-04-10 20:52               ` Junio C Hamano
2007-04-10 21:02                 ` Sam Ravnborg
2007-04-10 21:27                   ` Junio C Hamano
2007-04-10 21:03                 ` Nicolas Pitre
2007-04-15 23:21                   ` J. Bruce Fields
2007-04-11  8:08                 ` David Kågedal
2007-04-11  9:32                   ` Junio C Hamano
2007-04-15 23:25                     ` J. Bruce Fields
2007-04-11  8:32     ` Martin Waitz
2007-04-11  8:42       ` Alex Riesen
2007-04-11  8:57         ` Martin Waitz
2007-04-10 13:39   ` [PATCH] allow git-update-index work on subprojects Alex Riesen
2007-04-10 23:19     ` [PATCH] Allow " Alex Riesen
2007-04-11  2:55       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070411235447.GO21701@admingilde.org \
    --to=tali@admingilde.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).