From: David Turner <dturner@twopensource.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, David Turner <dturner@twitter.com>
Subject: Re: [PATCH 1/3] tree-walk: learn get_tree_enty_follow_symlinks
Date: Fri, 08 May 2015 16:02:31 -0400 [thread overview]
Message-ID: <1431115351.9179.7.camel@ubuntu> (raw)
In-Reply-To: <xmqqd22alvk6.fsf@gitster.dls.corp.google.com>
On Fri, 2015-05-08 at 12:26 -0700, Junio C Hamano wrote:
> > +static int find_tree_entry_nonrecursive(struct tree_desc *t, char *name, unsigned char *result, unsigned *mode) {
> > + int namelen = strlen(name);
> > +
> > + while (t->size) {
>
> Why do you need an almost duplicate of existing find_tree_entry()
> here? The argument "name" above is not const, so isn't that just
> the matter of the caller to temporarily replace '/' in name[] before
> calling find_tree_entry() if all you wanted to avoid was to prevent
> it from falling into get_tree_entry() codepath? Or are there more
> to this function?
Oh, right, actually, we already replaced the '/'! So I can just use the
existing one. That was silly.
> > +#define GET_TREE_ENTRY_FOLLOW_SYMLINKS_MAX_LINKS 40
>
> Is 40 just a randomly chosen number?
>
> I do not think 40 is particularly unreasonable, but so is 5 (which I
> think is also reasonable and is already used as MAXDEPTH in refs.c
> to follow symrefs), and am curious where that number came from.
http://lxr.linux.no/linux+v3.6.4/fs/namei.c#L783
I'll add a comment to that effect.
> > +/**
> > + * Find a tree entry by following symlinks in tree_sha (which is
> > + * assumed to be the root of the repository). In the event that a
> > + * symlink points outside the repository (e.g. a link to /foo or a
> > + * root-level link to ../foo), the portion of the link which is
> > + * outside the repository will be copied into result_path (which is
> > + * assumed to hold at least PATH_MAX bytes), and *mode will be set to
> > + * 0.
>
> As the API to this new function is not constrained by existing
> callers, you might want to consider using strbuf for result_path,
> which would make it easier for both the callers and this function.
The API is sort-of constrained, because the caller has a fixed-size
buffer to fill in (see the 2nd patch in this series).
> It is customary to name variables to control an ALLOC_GROW()-managed
> array 'foo' as foo_nr and foo_alloc. Deviating from the convention
> makes the patch harder to read by people who are familiar with it
> without any benefit, and those who are familiar with the existing
> code are the people you want your patch reviewed by.
Will fix.
> I am context-switching now; will review the remainder some other
> time.
Thanks for the review.
next prev parent reply other threads:[~2015-05-08 20:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 18:13 [PATCH 1/3] tree-walk: learn get_tree_enty_follow_symlinks dturner
2015-05-08 18:13 ` [PATCH 2/3] sha1_name: get_sha1_with_context learns to follow symlinks dturner
2015-05-08 19:45 ` Eric Sunshine
2015-05-08 20:17 ` Junio C Hamano
2015-05-08 20:25 ` Junio C Hamano
2015-05-08 20:39 ` Jeff King
2015-05-08 21:22 ` Junio C Hamano
2015-05-08 20:27 ` David Turner
2015-05-08 20:38 ` Philip Oakley
2015-05-08 21:31 ` Junio C Hamano
2015-05-08 18:13 ` [PATCH 3/3] cat-file: add --follow-symlinks to --batch dturner
2015-05-08 19:51 ` Eric Sunshine
2015-05-08 19:26 ` [PATCH 1/3] tree-walk: learn get_tree_enty_follow_symlinks Junio C Hamano
2015-05-08 20:02 ` David Turner [this message]
2015-05-08 19:43 ` Eric Sunshine
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=1431115351.9179.7.camel@ubuntu \
--to=dturner@twopensource.com \
--cc=dturner@twitter.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).