From: Junio C Hamano <gitster@pobox.com>
To: dturner@twopensource.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 11:07:03 -0700 [thread overview]
Message-ID: <xmqqoalpzn3s.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1431384645-17276-4-git-send-email-dturner@twopensource.com> (dturner@twopensource.com's message of "Mon, 11 May 2015 18:50:45 -0400")
dturner@twopensource.com writes:
> +--follow-symlinks::
> + Follow symlinks inside the repository when requesting objects
> + with extended SHA-1 expressions of the form tree-ish:path-in-tree.
> + Instead of providing output about the link itself, provide output
> + about the linked-to object. This option requires --batch or
> + --batch-check. In the event of a symlink loop (or more than
> + 40 symlinks in a symlink resolution chain), the file will be
> + treated as missing. If a symlink points outside the tree-ish
> + (e.g. a link to /foo or a root-level link to ../foo), the
> + portion of the link which is outside the tree will be printed.
> + Follow-symlinks will be silently turned off if <object>
> + specifies an object in the index rather than one in the object
> + database.
> +
> + For example, consider the a git repository containing:
> + f: a file containing "hello\n"
> + link: a symlink to f
> + dir/link: a symlink to ../f
> + plink: a symlink to ../f
> + alink: a symlink to /etc/passwd
> +
> + echo HEAD:f |git cat-file --batch --follow-symlinks would print
> + ce013625030ba8dba906f756967f9e9ca394464a blob 6
> +
> + echo HEAD:link |git cat-file --batch --follow-symlinks would print
> + the same thing, as would HEAD:dir/link.
> + Without follow-symlinks, these would print data about the
> + symlink itself. In the case of HEAD:link, you would see
> + 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
> +
> + 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.
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.
* 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".
* 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.
I do not necessarily think the latter three need to be addressed in
this 3-patch series, but they should be listed as known bugs, I
would think. That would invite others to fix them and save time for
users to file unnecessary bug reports.
So (now I came back) the last part of the description may want to
become more like this:
...
portion of the link which is outside the tree will be printed.
This option (currently) cannot be used unless `--batch` or
`--batch-check` is used.
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.
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.
Thanks.
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index 9bdfced..3226f3e 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -82,31 +82,43 @@ OPTIONS
Follow-symlinks will be silently turned off if <object>
specifies an object in the index rather than one in the object
database.
-
- For example, consider the a git repository containing:
++
+For example, consider a git repository containing:
++
+--
f: a file containing "hello\n"
link: a symlink to f
dir/link: a symlink to ../f
plink: a symlink to ../f
alink: a symlink to /etc/passwd
-
- echo HEAD:f |git cat-file --batch --follow-symlinks would print
+--
++
+For a regular file `f`, `echo HEAD:f | git cat-file --batch` would print
++
+--
ce013625030ba8dba906f756967f9e9ca394464a blob 6
-
- echo HEAD:link |git cat-file --batch --follow-symlinks would print
- the same thing, as would HEAD:dir/link.
- Without follow-symlinks, these would print data about the
- symlink itself. In the case of HEAD:link, you would see
+--
++
+And `echo HEAD:link | git cat-file --batch --follow-symlinks` would print
+the same thing, as would `HEAD:dir/link`, as they both point at `HEAD:f`.
++
+Without `--follow-symlinks`, these would print data about the
+symlink itself. In the case of `HEAD:link`, you would see
++
+--
4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
-
- Both plink and alink point outside the tree, so they would
- respectively print:
+--
++
+Both `plink` and `alink` point outside the tree, so they would
+respectively print:
++
+--
symlink 4
../f
symlink 11
/etc/passwd
-
+--
OUTPUT
--
2.4.0-363-gef77c54
next prev parent reply other threads:[~2015-05-12 18:07 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 [this message]
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
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=xmqqoalpzn3s.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=dturner@twitter.com \
--cc=dturner@twopensource.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.