From: Lars Hjemli <hjemli@gmail.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules
Date: Sun, 18 Jan 2009 17:37:39 +0100 [thread overview]
Message-ID: <8c5c35580901180837i6e835d98ob8875ce1b8ad3011@mail.gmail.com> (raw)
In-Reply-To: <49735530.4090901@lsrfire.ath.cx>
On Sun, Jan 18, 2009 at 17:13, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
> Lars Hjemli schrieb:
>> The traversal of submodules is only triggered if the current submodule
>> HEAD commit object is accessible. To this end, read_tree_recursive()
>> will try to insert the submodule odb as an alternate odb but the lack
>> of such an odb is not treated as an error since it is then assumed that
>> the user is not interested in the submodule content. However, if the
>> submodule odb is found it is treated as an error if the HEAD commit
>> object is missing.
>
> Callers of read_tree_recursive() specify a tree to traverse.
> Unconditionally using the HEAD of submodules feels a bit restrictive,
> but I don't use submodules, so I have no idea what I'm actually talking
> about here. :)
For bare repositories (where the submodule repo is added to
objects/info/alternates), following the tree of the linked commit is
the only option. And for non-bare repositories with the submodule
checked out, I think we should honor the users choice of checked out
HEAD in the submodule (especially since we don't have any other way to
specify which submodule commit to follow).
>
>> int read_tree_recursive(struct tree *tree,
>> const char *base, int baselen,
>> int stage, const char **match,
>> @@ -132,6 +188,30 @@ int read_tree_recursive(struct tree *tree,
>> return -1;
>> continue;
>> }
>> + if (S_ISGITLINK(entry.mode) && get_traverse_gitlinks()) {
>> + int retval;
>> + char *newbase;
>> + struct tree *subtree;
>> + unsigned int pathlen = tree_entry_len(entry.path, entry.sha1);
>> +
>> + newbase = xmalloc(baselen + 1 + pathlen);
>> + memcpy(newbase, base, baselen);
>> + memcpy(newbase + baselen, entry.path, pathlen);
>> + newbase[baselen + pathlen] = 0;
>> + if (!traverse_gitlink(newbase, entry.sha1, &subtree)) {
>> + free(newbase);
>> + continue;
>> + }
>> + newbase[baselen + pathlen] = '/';
>> + retval = read_tree_recursive(subtree,
>> + newbase,
>> + baselen + pathlen + 1,
>> + stage, match, fn, context);
>> + free(newbase);
>> + if (retval)
>> + return -1;
>> + continue;
>> + }
>> }
>> return 0;
>> }
>
> You don't need to call get_traverse_gitlinks() in the if statement above
> if you make all read_tree_recursive() callback functions return 0 for
> gitlinks that they don't want to follow and READ_TREE_RECURSIVE for
> those they do. It's cleaner without the static variable and its
> accessors and more flexible, too: the callbacks might decide to traverse
> only certain submodules.
I like the idea, but it will require thorough review of all
read_tree_recursive() consumers. So now we've got three different
approaches:
* me: global setting
* dscho: parameter to read_tree_recursive()
* you: accept the return value from the callback function
Junio, what would you prefer?
--
larsh
next prev parent reply other threads:[~2009-01-18 16:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-18 10:53 [PATCH 0/3] Implement 'git archive --submodules' Lars Hjemli
2009-01-18 10:53 ` [PATCH 1/3] sha1_file: add function to insert alternate object db Lars Hjemli
2009-01-18 10:53 ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Lars Hjemli
2009-01-18 10:53 ` [PATCH 3/3] git-archive: add support for --submodules Lars Hjemli
2009-01-18 15:51 ` Johannes Schindelin
2009-01-18 15:48 ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Johannes Schindelin
2009-01-18 17:45 ` Lars Hjemli
2009-01-18 18:33 ` Johannes Schindelin
2009-01-18 19:45 ` Lars Hjemli
2009-01-18 21:02 ` Johannes Schindelin
2009-01-18 21:31 ` Lars Hjemli
2009-01-18 21:55 ` Johannes Schindelin
2009-01-18 22:46 ` Lars Hjemli
2009-01-19 1:24 ` Johannes Schindelin
2009-01-19 2:01 ` [PATCH/RFC v1 1/1] bug fix, diff whitespace ignore options Keith Cascio
2009-01-19 3:53 ` Johannes Schindelin
2009-01-19 18:03 ` [PATCH/RFC v2 " Keith Cascio
2009-01-19 18:36 ` Johannes Schindelin
2009-01-20 7:04 ` Junio C Hamano
2009-01-19 3:02 ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Junio C Hamano
2009-01-18 16:13 ` René Scharfe
2009-01-18 16:37 ` Lars Hjemli [this message]
2009-01-18 19:00 ` Junio C Hamano
2009-01-18 19:50 ` Lars Hjemli
2009-01-18 15:32 ` [PATCH 1/3] sha1_file: add function to insert alternate object db Johannes Schindelin
2009-01-18 15:55 ` [PATCH] " Lars Hjemli
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=8c5c35580901180837i6e835d98ob8875ce1b8ad3011@mail.gmail.com \
--to=hjemli@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/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).