All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: dturner@twopensource.com
Cc: git@vger.kernel.org, David Turner <dturner@twitter.com>
Subject: Re: [PATCH v7 3/3] cat-file: add --follow-symlinks to --batch
Date: Tue, 12 May 2015 20:57:27 -0700	[thread overview]
Message-ID: <xmqqfv71ceoo.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1431481799-23560-4-git-send-email-dturner@twopensource.com> (dturner@twopensource.com's message of "Tue, 12 May 2015 21:49:59 -0400")

dturner@twopensource.com writes:

> From: David Turner <dturner@twitter.com>
>
> This wires the in-repo-symlink following code through to the cat-file
> builtin.  In the event of an out-of-repo link, cat-file will print
> the link in a new format.
>
> Signed-off-by: David Turner <dturner@twitter.com>
> ---

Thanks.

> +--follow-symlinks::
> +	With --batch or --batch-check, follow symlinks inside the
> +	repository when requesting objects with extended SHA-1
> +...
> +	printed.
> +[normal]
> +	This option does not (currently) work correctly when an

Nice; didn't realize that "[normal]" trick would work, but why not.

> +	object in the index is specified (e.g. `:link` instead of
> +	`HEAD:link`) rather than one in the tree.
> +[normal]
> +	This option cannot be used unless `--batch` or `--batch-check`
> +	is used, because it would be impossible to distinguish between
> +	the output for an out-of-repo symlink, and the contents of a
> +	blob.
> +
> +For example, consider a git repository containing:

... but I am not sure about this paragraph.  Does it align and look
to be at the same level as the first paragraph that begins with
"With `--batch` or `--batch-check`" (asking because I do not have an
access to a good environment to check the resulting HTML easily
right now)?

> +	result = get_sha1_with_context(obj_name, flags, data->sha1, &ctx);
> +	if (result != FOUND) {
> +		switch(result) {

	switch (result) {

> +		case MISSING_OBJECT:
> +			printf("%s missing\n", obj_name);
> +			break;
> +		case DANGLING_SYMLINK:
> +			printf("dangling %"PRIuMAX"\n%s\n", strlen(obj_name),
> +			       obj_name);
> +			break;
> +		case SYMLINK_LOOP:
> +			printf("loop %"PRIuMAX"\n%s\n", strlen(obj_name),
> +			       obj_name);
> +			break;
> +		case NOT_DIR:
> +			printf("notdir %"PRIuMAX"\n%s\n", strlen(obj_name),
> +			       obj_name);
> +			break;

Don't all these lengths need to be cast to uintmax_t, like the
"symlink" one below?

By the way, I noticed that my compiler is so stupid that it does not
realize this "switch (result)" is inside "if (result != FOUND)" and
missing "case FOUND:" is perfectly fine.  The remainder of the code
I have been compiling with -Wswitch, but this one makes me to drop
it.

> +		}
> +		fflush(stdout);
> +		return 0;
> +	}
> +
> +	if (ctx.mode == 0) {
> +		printf("symlink %"PRIuMAX"\n%s\n",
> +		       (uintmax_t)ctx.symlink_path.len,
> +		       ctx.symlink_path.buf);
>  		fflush(stdout);
>  		return 0;

  reply	other threads:[~2015-05-13  3:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13  1:49 [PATCH v7 0/3] dturner
2015-05-13  1:49 ` [PATCH v7 1/3] tree-walk: learn get_tree_entry_follow_symlinks dturner
2015-05-13 15:39   ` Jeff King
2015-05-13  1:49 ` [PATCH v7 2/3] sha1_name: get_sha1_with_context learns to follow symlinks dturner
2015-05-13  1:49 ` [PATCH v7 3/3] cat-file: add --follow-symlinks to --batch dturner
2015-05-13  3:57   ` Junio C Hamano [this message]
2015-05-13  5:51 ` [PATCH v7 0/3] 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=xmqqfv71ceoo.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.