From: Jens Lehmann <Jens.Lehmann@web.de>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Heiko Voigt <hvoigt@hvoigt.net>,
"W. Trevor King" <wking@tremily.us>
Subject: Re: [WIP/PATCH 9/9] submodule: teach unpack_trees() to update submodules
Date: Fri, 07 Feb 2014 22:32:28 +0100 [thread overview]
Message-ID: <52F550EC.20202@web.de> (raw)
In-Reply-To: <CACsJy8CiAPnatithenDKBBKVGFHQZsu4mJLEjuWFD2GXqO56Lw@mail.gmail.com>
Am 04.02.2014 01:11, schrieb Duy Nguyen:
> On Tue, Feb 4, 2014 at 2:54 AM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> Implement the functionality needed to enable work tree manipulating
>> commands so that an changed submodule does not only affect the index but
>> it also updates the work tree of any initialized submodule according to
>> the SHA-1 recorded in the superproject.
>>
>> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
>> ---
>> entry.c | 15 ++++++++--
>> submodule.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> submodule.h | 3 ++
>> unpack-trees.c | 69 ++++++++++++++++++++++++++++++++++++----------
>> unpack-trees.h | 1 +
>> 5 files changed, 157 insertions(+), 17 deletions(-)
>>
>> diff --git a/entry.c b/entry.c
>> index d1bf6ec..61a2767 100644
>> --- a/entry.c
>> +++ b/entry.c
>> @@ -265,7 +265,7 @@ int checkout_entry(struct cache_entry *ce,
>>
>> if (!check_path(path, len, &st, state->base_dir_len)) {
>> unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
>> - if (!changed)
>> + if (!changed && (!S_ISDIR(st.st_mode) || !S_ISGITLINK(ce->ce_mode)))
>> return 0;
>
> Should we report something when ce is a gitlink, but path is not a
> directory, instead of siliently exit?
Good point.
>> diff --git a/submodule.c b/submodule.c
>> index 3907034..83e7595 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -520,6 +520,42 @@ int depopulate_submodule(const char *path)
>> return 0;
>> }
>>
>> +int update_submodule(const char *path, const unsigned char sha1[20], int force)
>> +{
>> + struct strbuf buf = STRBUF_INIT;
>> + struct child_process cp;
>> + const char *hex_sha1 = sha1_to_hex(sha1);
>> + const char *argv[] = {
>> + "checkout",
>> + force ? "-fq" : "-q",
>
> respect "state->quiet" in checkout_entry() as well?
See below.
>> + hex_sha1,
>> + NULL,
>> + };
>> + const char *git_dir;
>> +
>> + strbuf_addf(&buf, "%s/.git", path);
>> + git_dir = read_gitfile(buf.buf);
>> + if (!git_dir)
>> + git_dir = buf.buf;
>> + if (!is_directory(git_dir)) {
>> + strbuf_release(&buf);
>> + /* The submodule is not populated, so we can't check it out */
>> + return 0;
>> + }
>> + strbuf_release(&buf);
>> +
>> + memset(&cp, 0, sizeof(cp));
>> + cp.argv = argv;
>> + cp.env = local_repo_env;
>> + cp.git_cmd = 1;
>> + cp.no_stdin = 1;
>> + cp.dir = path; /* GIT_WORK_TREE doesn't work for git checkout */
>
> And if we do respect --quiet and it's not specified, paths printed by
> this process is relative to "dir", not to user cwd. Could be
> confusing.
That's the reason I'm currently always passing -q to checkout. While
checkout would have to learn a "--prefix=" option to be able to print
the path relative to the superproject, some (most?) users don't want
to see this detailed information from inside the submodule. After all
git status and diff currently also only show a condensed view of the
submodule state and don't print any detailed information about files
inside the submodule. We might want to add means to enable that later,
and then we'd have to conditionally provide --quiet (and --prefix)
here.
>> + if (run_command(&cp))
>> + return error("Could not checkout submodule %s", path);
>> +
>> + return 0;
>> +}
>> +
prev parent reply other threads:[~2014-02-07 21:32 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 22:36 What's cooking in git.git (Jan 2014, #01; Mon, 6) Junio C Hamano
2014-01-06 23:16 ` Francesco Pretto
2014-01-06 23:32 ` Junio C Hamano
2014-01-06 23:45 ` Francesco Pretto
2014-01-07 17:49 ` Jens Lehmann
[not found] ` <xmqqvbxvekwv.fsf@gitster.dls.corp.google.com>
2014-02-03 19:47 ` [WIP/PATCH 0/9] v2 submodule recursive checkout] Jens Lehmann
2014-02-03 19:48 ` [WIP/PATCH 1/9] submodule: prepare for recursive checkout of submodules Jens Lehmann
2014-02-03 22:23 ` Junio C Hamano
2014-02-07 21:06 ` Jens Lehmann
2014-02-04 0:01 ` Jonathan Nieder
2014-02-07 21:01 ` Jens Lehmann
2014-02-03 19:49 ` [WIP/PATCH 2/9] Teach reset the --[no-]recurse-submodules option Jens Lehmann
2014-02-03 22:40 ` Junio C Hamano
2014-02-07 21:09 ` Jens Lehmann
2014-02-03 19:50 ` [WIP/PATCH 3/9] Teach checkout " Jens Lehmann
2014-02-03 22:56 ` Junio C Hamano
2014-02-07 21:12 ` Jens Lehmann
2014-02-03 19:50 ` [WIP/PATCH 4/9] Teach merge " Jens Lehmann
2014-02-03 23:01 ` Junio C Hamano
2014-02-07 21:23 ` Jens Lehmann
2014-02-07 22:00 ` Junio C Hamano
2014-02-07 22:08 ` W. Trevor King
2014-02-03 19:51 ` [WIP/PATCH 5/9] Teach bisect--helper " Jens Lehmann
2014-02-03 19:51 ` [WIP/PATCH 6/9] Teach bisect " Jens Lehmann
2014-02-03 20:04 ` W. Trevor King
2014-02-03 20:22 ` Jens Lehmann
2014-02-03 19:52 ` [WIP/PATCH 7/9] submodule: teach unpack_trees() to remove submodule contents Jens Lehmann
2014-02-03 20:10 ` W. Trevor King
2014-02-07 21:24 ` Jens Lehmann
2014-02-03 19:53 ` [WIP/PATCH 8/9] submodule: teach unpack_trees() to repopulate submodules Jens Lehmann
2014-02-03 19:54 ` [WIP/PATCH 9/9] submodule: teach unpack_trees() to update submodules Jens Lehmann
2014-02-03 20:19 ` W. Trevor King
2014-02-07 21:25 ` Jens Lehmann
2014-02-04 0:11 ` Duy Nguyen
2014-02-07 21:32 ` Jens Lehmann [this message]
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=52F550EC.20202@web.de \
--to=jens.lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hvoigt@hvoigt.net \
--cc=jrnieder@gmail.com \
--cc=pclouds@gmail.com \
--cc=wking@tremily.us \
/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 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 NNTP newsgroup(s).