git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eran Tromer <git2eran@tromer.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: skimo@liacs.nl, Sven Verdoolaege <skimo@kotnet.org>, git@vger.kernel.org
Subject: Re: [PATCH] unpack-trees.c: assume submodules are clean during check-out
Date: Sat, 04 Aug 2007 12:03:28 -0400	[thread overview]
Message-ID: <46B4A350.9060806@tromer.org> (raw)
In-Reply-To: <7v643vj316.fsf@assigned-by-dhcp.cox.net>

On 2007-08-04 01:13, Junio C Hamano wrote:
> Let me understand the problem first.  If your first checkout
> does not check out the submodule, switching between revisions
> that has different commit of the submodule there would not fail,
> but once you checkout the submodule, switching without updating
> the submodule would be Ok (because by design updating the
> submodule is optional) but then further switching out of that
> state will fail because submodule in the supermodule tree and
> checked-out submodule repository are now out of sync.  Is that
> the problem?
> 
[snip]

> Where does the "No you are not up-to-date, I wouldn't let you
> switch" come from?  Is that verify_uptodate() called from
> merged_entry() called from twoway_merge()?  I think the right
> approach to deal with this is to teach verify_uptodate() about
> the policy.  The function is about "make sure the filesystem
> entity that corresponds to this cache entry is up to date, lest
> we lose the local modifications".  As we explicitly allow
> submodule checkout to drift from the supermodule index entry,
> the check should say "Ok, for submodules, not matching is the
> norm" for now.  Later when we have the ability to mark "I care
> about this submodule to be always in sync with the superproject"
> (thereby implementing automatic recursive checkout and perhaps
> diff, among other things), we should check if the submodule in
> question is marked as such and perform the current test.
> 
> How about doing something like this instead?
> 
>  unpack-trees.c |    9 +++++++++

Works here: it silences the check and allows switching branches. Still,
leaving the working tree dirty can inadvertently affect subsequent
commits. Consider the most ordinary of sequences:

$ git checkout experimental-death-ray
$ git submodules update
(return a week later, woozy from the vacation.)
$ git checkout master
(hack hack hack)
$ git commit -a -m "fixed typos"
$ git push
(Oops. You've just accidentally committed the wrong submodule heads.)

So to safely make new commits you must remember to always run "git
submodule update", or forgo use of "git commit -a", whenever submodules
might be involved.

I guess you can hack around this by excluding submodules from "commit
-a" and (for scripts) "ls-files -m" too...

Another approach is for pull, checkout etc. to automatically update the
submodule' head ref, but no more. In this case the supermodule always
sees a consistent state with traditional semantics, but the *submodule*
ends up with a dirty working tree and a head referring to a
possibly-missing commit; "git submodule update" would need to clean that up.

  Eran

  parent reply	other threads:[~2007-08-04 16:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-17 18:28 [PATCH] unpack-trees.c: assume submodules are clean during check-out Sven Verdoolaege
2007-07-18  7:29 ` Junio C Hamano
2007-08-01 14:05   ` Sven Verdoolaege
2007-08-04  5:13     ` Junio C Hamano
2007-08-04 11:41       ` Lars Hjemli
2007-08-05  6:02         ` Junio C Hamano
2007-08-05 13:55         ` Sven Verdoolaege
2007-08-04 16:03       ` Eran Tromer [this message]
2007-08-05  6:12         ` Junio C Hamano
2007-08-05 14:46         ` Sven Verdoolaege
2007-08-06 18:42           ` Eran Tromer
2007-08-06 19:03             ` Sven Verdoolaege
2007-08-07  3:24               ` Eran Tromer
2007-08-07  8:51                 ` Sven Verdoolaege
2007-08-08  1:41                   ` Eran Tromer
2007-08-08 11:39                     ` Sven Verdoolaege

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=46B4A350.9060806@tromer.org \
    --to=git2eran@tromer.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=skimo@kotnet.org \
    --cc=skimo@liacs.nl \
    /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).