From: Jens Lehmann <Jens.Lehmann@web.de>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [WIP PATCH 3/4] Teach checkout to recursively checkout submodules
Date: Fri, 09 Apr 2010 23:39:21 +0200 [thread overview]
Message-ID: <4BBF9E89.3010806@web.de> (raw)
In-Reply-To: <4BBF9D6F.2000006@web.de>
Change the default behavior of "git checkout" to check out submodules
too. This can be prevented by using the new "--ignore-submodules" option.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
Documentation/git-checkout.txt | 7 +++++++
builtin/checkout.c | 7 ++++++-
t/t2013-checkout-submodule.sh | 14 ++++++++++++--
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 4505eb6..63ac3bc 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -144,6 +144,13 @@ the conflicted merge in the specified paths.
This means that you can use `git checkout -p` to selectively discard
edits from your current working tree.
+--ignore-submodules::
+ Since version 1.8.0 the default behavior is to checkout populated
+ submodules recursively. When this option is used, the work trees of
+ submodules will not be updated, only the hash recorded in the
+ superproject will be changed (this was the default behavior until
+ 1.8.0).
+
<branch>::
Branch to checkout; if it refers to a branch (i.e., a name that,
when prepended with "refs/heads/", is a valid ref), then that
diff --git a/builtin/checkout.c b/builtin/checkout.c
index ee198ae..0008ec5 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -31,6 +31,7 @@ struct checkout_opts {
int force;
int writeout_stage;
int writeout_error;
+ int ignore_submodules;
const char *new_branch;
const char *new_orphan_branch;
@@ -248,7 +249,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
memset(&state, 0, sizeof(state));
state.force = 1;
state.refresh_cache = 1;
- state.ignore_submodules = 1;
+ state.ignore_submodules = opts->ignore_submodules;
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
if (match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, NULL)) {
@@ -314,6 +315,7 @@ static int reset_tree(struct tree *tree, struct checkout_opts *o, int worktree)
opts.verbose_update = !o->quiet;
opts.src_index = &the_index;
opts.dst_index = &the_index;
+ opts.ignore_submodules = o->ignore_submodules;
parse_tree(tree);
init_tree_desc(&tree_desc, tree->buffer, tree->size);
switch (unpack_trees(1, &tree_desc, &opts)) {
@@ -393,6 +395,7 @@ static int merge_working_tree(struct checkout_opts *opts,
topts.dir = xcalloc(1, sizeof(*topts.dir));
topts.dir->flags |= DIR_SHOW_IGNORED;
topts.dir->exclude_per_dir = ".gitignore";
+ topts.ignore_submodules = opts->ignore_submodules;
tree = parse_tree_indirect(old->commit ?
old->commit->object.sha1 :
(unsigned char *)EMPTY_TREE_SHA1_BIN);
@@ -649,6 +652,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
{ OPTION_BOOLEAN, 0, "guess", &dwim_new_local_branch, NULL,
"second guess 'git checkout no-such-branch'",
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+ OPT_BOOLEAN(0, "ignore-submodules", &opts.ignore_submodules,
+ "don't update submodule work trees"),
OPT_END(),
};
int has_dash_dash;
diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh
index fda3f0a..e5f2e6e 100755
--- a/t/t2013-checkout-submodule.sh
+++ b/t/t2013-checkout-submodule.sh
@@ -29,14 +29,24 @@ test_expect_success '"reset <submodule>" updates the index' '
git diff-files --quiet
'
-test_expect_success '"checkout <submodule>" updates the index only' '
+test_expect_success '"checkout --ignore-submodules <submodule>" updates the index only' '
git update-index --refresh &&
git diff-files --quiet &&
git diff-index --quiet --cached HEAD &&
- git checkout HEAD^ submodule &&
+ git checkout --ignore-submodules HEAD^ submodule &&
test_must_fail git diff-files --quiet &&
git checkout HEAD submodule &&
git diff-files --quiet
'
+test_expect_success '"checkout <submodule>" updates recursively' '
+ git update-index --refresh &&
+ git diff-files --quiet &&
+ git diff-index --quiet --cached HEAD &&
+ git checkout HEAD^ submodule &&
+ git diff-files --quiet &&
+ git checkout HEAD submodule &&
+ git diff-files --quiet
+'
+
test_done
--
1.7.1.rc0.248.g09203
next prev parent reply other threads:[~2010-04-09 21:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-09 21:34 [WIP PATCH 0/4] Recursively checkout submodules Jens Lehmann
2010-04-09 21:36 ` [WIP PATCH 1/4] Prepare checkout_entry() for recursive checkout of submodules Jens Lehmann
2010-04-09 21:59 ` Junio C Hamano
2010-04-09 23:11 ` Jens Lehmann
2010-04-10 17:01 ` Jens Lehmann
2010-04-10 18:44 ` Junio C Hamano
2010-04-10 20:57 ` Jens Lehmann
2010-04-09 21:37 ` [WIP PATCH 2/4] Add "ignore_submodules" member to "struct unpack_trees_options" Jens Lehmann
2010-04-09 21:39 ` Jens Lehmann [this message]
2010-04-09 21:40 ` [WIP PATCH 4/4] Teach checkout-index to recursively checkout submodules Jens Lehmann
2010-04-09 22:04 ` Junio C Hamano
2010-04-09 23:22 ` Jens Lehmann
2010-04-10 5:07 ` [WIP PATCH 0/4] Recursively " 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BBF9E89.3010806@web.de \
--to=jens.lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.