git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] tree-walk: learn get_tree_enty_follow_symlinks

From
David Turner <dturner@twopensource.com>
Date
May 8, 2015, 20:02 UTC
Message-ID
<1431115351.9179.7.camel@ubuntu>
In-Reply-To
<xmqqd22alvk6.fsf@gitster.dls.corp.google.com>
On Fri, 2015-05-08 at 12:26 -0700, Junio C Hamano wrote:
Show 11 quoted lines
> > +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.

Show 7 quoted lines
> > +#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.
Show 12 quoted lines
> > +/**
> > + * 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).

Show 5 quoted lines
> 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.
Previous: Junio C HamanoNext: Eric Sunshine
Message 14 of 15 in “tree-walk: learn get_tree_enty_follow_symlinks”
  1. 1/3 tree-walk: learn get_tree_enty_follow_symlinksdturner@twopensource.com, May 8, 2015
  2. 2/3 sha1_name: get_sha1_with_context learns to follow symlinksdturner@twopensource.com, May 8, 2015
  3. Eric SunshineMay 8, 2015
  4. Junio C HamanoMay 8, 2015
  5. Junio C HamanoMay 8, 2015
  6. Jeff KingMay 8, 2015
  7. Junio C HamanoMay 8, 2015
  8. David TurnerMay 8, 2015
  9. Philip OakleyMay 8, 2015
  10. Junio C HamanoMay 8, 2015
  11. 3/3 cat-file: add --follow-symlinks to --batchdturner@twopensource.com, May 8, 2015
  12. Eric SunshineMay 8, 2015
  13. Junio C HamanoMay 8, 2015
  14. David TurnerMay 8, 2015
  15. Eric SunshineMay 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.