git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Hjemli <hjemli@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC/PATCH 1/3] tree.c: add support for traversal of submodules
Date: Mon, 12 Jan 2009 10:04:29 +0100	[thread overview]
Message-ID: <8c5c35580901120104u418d8d73mad4ab7d71fe8c3f8@mail.gmail.com> (raw)
In-Reply-To: <7vr639kyf0.fsf@gitster.siamese.dyndns.org>

On Mon, Jan 12, 2009 at 04:15, Junio C Hamano <gitster@pobox.com> wrote:
> Lars Hjemli <hjemli@gmail.com> writes:
>
>> If the commit referenced by a gitlink is available in the (possibly
>> alternate) object database, read_tree_recursive() is now able to descend
>> into the tree of the linked commit if the flag 'traverse_gitlinks' is
>> turned on.
>>
>> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
>> ---
>>  tree.c |   20 +++++++++++++++++---
>>  tree.h |    1 +
>>  2 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/tree.c b/tree.c
>> index 03e782a..1468e10 100644
>> --- a/tree.c
>> +++ b/tree.c
>> @@ -7,6 +7,7 @@
>>  #include "tree-walk.h"
>>
>>  const char *tree_type = "tree";
>> +int traverse_gitlinks = 0;
>
> I think we tend to put these global settings that will affect everybody in
> environment.c.  You do not have to initialize variable to zero; BSS will
> take care of it.

Ok, I'll add a proper interface in environment.c for this setting.


> When the user explicitly asks you to traverse into submodules and the
> necessary commit is not available in a submodule, the code goes on without
> complaining.  I am not saying it is bad, but I wonder if we would want to
> distinguish these three cases:
>
>  (1) the submodule is initialized and the necessary commit is there.
>
>  (2) the submodule is initialized, but the necessary commit is missing.
>
>  (3) the submodule is not even initialized (aka "the user is not
>     interested in it"); there is only an empty directory.
>
> I think it is perfectly fine not to say anything for (3) but I am unsure
> about the second case.

Do we want to impose the porcelainish rules of git-submodule
(.gitmodules, .git/config) in read_tree_recursive()?

If so, I guess a new submodule.h might provide something like this
(disclaimer: coded in gmail):

	struct submodule {
		int interesting:1;
		char *name;
		char *url;
		char **objectdirs;
		char **paths;
	}

	typedef int (*submodule_cb)(struct submodule *submodule, void *data);

	int load_submodule_config();
	struct submodule *get_submodule_from_path(char *path);
	int add_submodule_objectdb(struct submodule *item);
	int for_each_submodule(submodule_cb cb, void *data);



Then, in read_tree_recursive(), we could check submodule->interesting
to decide if we should follow the gitlink. Also, for bare
repositories, we'd need to support something like
'submodule.<name>.objectdir' in the config file (and .gitmodules must
obviously be read from the objectdb).

If we don't want to impose these rules, the current patch should be
minimally sufficient (the user has to edit
.git/objects/info/alternates by hand and missing submodule commits are
treated as if the submodule is not interesting).

-- 
larsh

  reply	other threads:[~2009-01-12  9:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-11 23:45 [RFC/PATCH 0/3] Enable in-process submodule traversal Lars Hjemli
2009-01-11 23:45 ` [RFC/PATCH 1/3] tree.c: add support for traversal of submodules Lars Hjemli
2009-01-11 23:45   ` [RFC/PATCH 2/3] archive.c: enable " Lars Hjemli
2009-01-11 23:45     ` [RFC/PATCH 3/3] builtin-ls-tree: " Lars Hjemli
2009-01-12  3:15   ` [RFC/PATCH 1/3] tree.c: add support for " Junio C Hamano
2009-01-12  9:04     ` Lars Hjemli [this message]
2009-01-12 10:07       ` Junio C Hamano
2009-01-12 10:59         ` Lars Hjemli
2009-01-12  2:07 ` [RFC/PATCH 0/3] Enable in-process submodule traversal 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=8c5c35580901120104u418d8d73mad4ab7d71fe8c3f8@mail.gmail.com \
    --to=hjemli@gmail.com \
    --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 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).