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 v5 3/3] cat-file: add --follow-symlinks to --batch
Date: Tue, 12 May 2015 18:36:44 -0400 [thread overview]
Message-ID: <1431470204.16652.52.camel@ubuntu> (raw)
In-Reply-To: <xmqqd225fsw8.fsf@gitster.dls.corp.google.com>
On Tue, 2015-05-12 at 13:22 -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Ahh, that would also give us "missing", so in that sense you are
> > being consistent.
> >
> > But I do not think that consistency is useful. Showing just
> > "missing" instead is losing information and that is what bothers me.
> >
> > Showing "symlink 6 nosuch" to this "link points at a target that
> > would be in-tree but there is no such object in the tree" symbolic
> > link instead of "missing" would make it more useful, and I do not
> > offhand think of a downside, but maybe I am missing something.
> >
> > For a link that points outside, the code already gives
> >
> > $ ln -s ../outside outlink
> > $ git add outlink
> > $ echo "$(git write-tree):outlink" |
> > git cat-file --batch --follow-symlinks
> >
> > "symlink ../outside", so the script reading from the batch output
> > already has to be prepared to handle "symlink" and understand it as
> > saying "the link does not point an object that is inside the tree".
>
> Having said all that, I think we can make readers' life easier by
> classifying various reasons why --follow-symlinks cannot pretend
> as if the in-tree pointee were given as its input and signal it
> differently:
>
> * A link points outside the original tree (or the index, once we
> support "cat-file :RelNotes").
>
> I think your "symlink <size> LF <target> LF" already does this.
>
> * A link points (directly or indirectly) at itself.
>
> This would be your "loop <size> LF <target> LF", which I think is
> good.
>
> * A link does not step outside the original tree, but the pointee
> does not exist in the original tree.
>
> I think you currently say "<object name for HEAD:link> missing",
> but I do not think it is useful. That object does exist, but it
> merely cannot be dereferenced. Perhaps introducing a new one,
> e.g. "dangling <size> LF <target> LF" similar to symlink/loop,
> would help the reader better?
>
> Are there other cases? The only other case I think of is when the
> link resolves cleanly inside the tree, which you already handle.
>
> Thanks.
On Tue, 2015-05-12 at 13:22 -0700, Junio C Hamano wrote:
Junio C Hamano <gitster@pobox.com> writes:
>
> > Ahh, that would also give us "missing", so in that sense you are
> > being consistent.
> >
> > But I do not think that consistency is useful. Showing just
> > "missing" instead is losing information and that is what bothers me.
> >
> > Showing "symlink 6 nosuch" to this "link points at a target that
> > would be in-tree but there is no such object in the tree" symbolic
> > link instead of "missing" would make it more useful, and I do not
> > offhand think of a downside, but maybe I am missing something.
> >
> > For a link that points outside, the code already gives
> >
> > $ ln -s ../outside outlink
> > $ git add outlink
> > $ echo "$(git write-tree):outlink" |
> > git cat-file --batch --follow-symlinks
> >
> > "symlink ../outside", so the script reading from the batch output
> > already has to be prepared to handle "symlink" and understand it as
> > saying "the link does not point an object that is inside the tree".
>
> Having said all that, I think we can make readers' life easier by
> classifying various reasons why --follow-symlinks cannot pretend
> as if the in-tree pointee were given as its input and signal it
> differently:
>
> * A link points outside the original tree (or the index, once we
> support "cat-file :RelNotes").
>
> I think your "symlink <size> LF <target> LF" already does this.
>
> * A link points (directly or indirectly) at itself.
>
> This would be your "loop <size> LF <target> LF", which I think is
> good.
>
> * A link does not step outside the original tree, but the pointee
> does not exist in the original tree.
>
> I think you currently say "<object name for HEAD:link> missing",
> but I do not think it is useful. That object does exist, but it
> merely cannot be dereferenced. Perhaps introducing a new one,
> e.g. "dangling <size> LF <target> LF" similar to symlink/loop,
> would help the reader better?
>
> Are there other cases? The only other case I think of is when the
> link resolves cleanly inside the tree, which you already handle.
While updating the tests, I noticed another two cases:
1. HEAD:broken-link/file
I am inclined to describe this as "dangling" as well. (It is not useful
to tell users that "file" is the remaining bit to be resolved, because
due to chains of symlinks, users have no idea what file would be
relative to). I think the filesystem returns ENOENT in the equivalent
case.
2. HEAD:link-to-file/file
This should be "notdir", I think, in that it is a distinct way of
failing that the user might care to know. The filesystem returns ENOTDIR
in the equivalent case.
In addition, I would like to have the format for the dangling, loop, and
notdir cases match the missing case. In other words, "HEAD:link
missing", "HEAD:link dangling", etc. Users already need to parse the
missing case, so we might as well make the others match. It's true that
this parsing is impossible in the case of filenames containing newlines,
but git cat-file --batch cannot accept those filenames as input anyway
(presumably, a -0 flag would be needed, if anyone actually used such
filenames, and at that point we could make the -0 output unambiguously
parseable).
next prev parent reply other threads:[~2015-05-12 22:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-11 22:50 [PATCH v5 0/3] cat-file --follow-symlinks dturner
2015-05-11 22:50 ` [PATCH v5 1/3] tree-walk: learn get_tree_entry_follow_symlinks dturner
2015-05-12 17:29 ` Johannes Sixt
2015-05-11 22:50 ` [PATCH v5 2/3] sha1_name: get_sha1_with_context learns to follow symlinks dturner
2015-05-11 22:50 ` [PATCH v5 3/3] cat-file: add --follow-symlinks to --batch dturner
2015-05-12 17:34 ` Johannes Sixt
2015-05-12 18:07 ` Junio C Hamano
2015-05-12 18:36 ` David Turner
2015-05-12 18:43 ` Junio C Hamano
2015-05-12 18:55 ` David Turner
2015-05-12 20:00 ` Junio C Hamano
2015-05-12 20:22 ` Junio C Hamano
2015-05-12 22:36 ` David Turner [this message]
2015-05-12 23:02 ` Junio C Hamano
2015-05-12 23:06 ` Junio C Hamano
2015-05-12 20:07 ` Junio C Hamano
2015-05-12 21:37 ` David Turner
2015-05-12 21:42 ` Junio C Hamano
2015-05-12 21:53 ` David Turner
2015-05-14 20:06 ` 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=1431470204.16652.52.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).