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

Re: [PATCH v5 3/3] cat-file: add --follow-symlinks to --batch

From
David Turner <dturner@twopensource.com>
Date
May 12, 2015, 18:36 UTC
Message-ID
<1431455779.16652.20.camel@ubuntu>
In-Reply-To
<xmqqoalpzn3s.fsf@gitster.dls.corp.google.com>
On Tue, 2015-05-12 at 11:07 -0700, Junio C Hamano wrote:
Show 22 quoted lines
> > +	Both plink and alink point outside the tree, so they would
> > +	respectively print:
> > +	symlink 4
> > +	../f
> > +
> > +	symlink 11
> > +	/etc/passwd
> > +
> > +
> > +
> 
> A few points I noticed:
> 
>  * It is not clear that this is (currently) only for --batch and
>    --batch-check until you read four lines into the description.
> 
>    Perhaps start the description like this instead?
> 
>    --follow-symlinks::
>            When answering `--batch` or `--batch-check` request,
>            follow symlinks inside the repository when requesting objects
>            with extended SHA-1 expressions of the form tree-ish:path-in-tree.
Will rearrange.
Show 7 quoted lines
>    Also I'd lose the "This option requires ..." sentence in the middle
>    (I'll come back to the reason why later).
> 
>  * Is it fundamental that this is only for --batch family, or is it
>    just lack of need by the current implementor and implementation?
>    "git cat-file --follow-symlinks blob :RelNotes" does not sound
>    a nonsense request to me.

The reason that --follow-symlinks doesn't work for non-batch requests is that it is impossible to distinguish out-of-tree symlinks from valid output in non-batch output. I will add text explaining this.

>  * I am not sure if HEAD:link that points at HEAD:link should be
>    reported as "missing".  It may be better to report the original
>    without any dereferencing just like a link that points at outside
>    the tree? i.e. "symlink 4 LF link".

Unfortunately, a symlink loop might include relative symlinks (e.g. ../a). If we return a relative symlink, the user will not be able to distinguish it from a non-loop, out-of-tree symlink. So I think we may not return symlink 4 LF ../a for these cases.

We could, I guess, have a separate output like loop <size> LF link <LF>", but, unless we always save and output the first link in the chain, we won't know what any link is relative to. Since reasonable people do not create symlink loops, and since there are other mechanisms for symlink loop debugging (e.g. plain cat-file), I think it is OK not to put special effort into handling loops.

Show 7 quoted lines
>  * I think "echo :RelNotes | git cat-file --batch --follow-symlinks"
>    that does not follow a symlink is a BUG.  Unless there is
>    something fundamental that in-index object should never support
>    this feature, that is.  But I do not think of a good reason
>    why---it feels that this is just the lack of implementation that
>    can be addressed by somebody else in the future who finds the
>    need for the support.

Yes, this should definitely be addressed in the future. I didn't see a straightforward way to generalize this code to also address the index, so a new version of this function would have to be written. That's why I didn't add that feature yet. The lack of it is definitely a bug, though.

Show 7 quoted lines
>         Also the option does not (currently) work correctly when an
> 	object in the index is specified (e.g. `:link` instead of
> 	`HEAD:link`) rather than one in the tree.
> 
> We need to also say something about the "missing" vs "loop" case, if
> we choose to leave that part broken.  I'd rather see it fixed, but
> that is not a very strong preference.
Will add an example.
> By the way, the text after your patch would not format well thru
> AsciiDoc.  See attached for a suggested mark-up fix that can be
> squashed.
I'll squash that in when I re-roll.  Thanks for the formatting.
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 20 in “cat-file --follow-symlinks”
  1. 0/3 cat-file --follow-symlinksdturner@twopensource.com, May 11, 2015
  2. 1/3 tree-walk: learn get_tree_entry_follow_symlinksdturner@twopensource.com, May 11, 2015
  3. Johannes SixtMay 12, 2015
  4. 2/3 sha1_name: get_sha1_with_context learns to follow symlinksdturner@twopensource.com, May 11, 2015
  5. 3/3 cat-file: add --follow-symlinks to --batchdturner@twopensource.com, May 11, 2015
  6. Johannes SixtMay 12, 2015
  7. Junio C HamanoMay 12, 2015
  8. David TurnerMay 12, 2015
  9. Junio C HamanoMay 12, 2015
  10. David TurnerMay 12, 2015
  11. Junio C HamanoMay 12, 2015
  12. Junio C HamanoMay 12, 2015
  13. David TurnerMay 12, 2015
  14. Junio C HamanoMay 12, 2015
  15. Junio C HamanoMay 12, 2015
  16. Junio C HamanoMay 12, 2015
  17. David TurnerMay 12, 2015
  18. Junio C HamanoMay 12, 2015
  19. David TurnerMay 12, 2015
  20. Junio C HamanoMay 14, 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.