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

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2015, 03:57 UTC
Message-ID
<xmqqfv71ceoo.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1431481799-23560-4-git-send-email-dturner@twopensource.com>
dturner@twopensource.com writes:
Show 8 quoted lines
> 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.
Show 7 quoted lines
> +--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.
Show 9 quoted lines
> +	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) {
Show 15 quoted lines
> +		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.

Show 11 quoted lines
> +		}
> +		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;
Previous: dturner@twopensource.comNext: Junio C Hamano
Message 6 of 7 in “[PATCH v7 0/3]”
  1. 0/3 dturner@twopensource.com, May 13, 2015
  2. 1/3 tree-walk: learn get_tree_entry_follow_symlinksdturner@twopensource.com, May 13, 2015
  3. Jeff KingMay 13, 2015
  4. 2/3 sha1_name: get_sha1_with_context learns to follow symlinksdturner@twopensource.com, May 13, 2015
  5. 3/3 cat-file: add --follow-symlinks to --batchdturner@twopensource.com, May 13, 2015
  6. Junio C HamanoMay 13, 2015
  7. Junio C HamanoMay 13, 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.