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

Re: cat-file ambiguity prints "dangling"

From
EWEric Wong <e@80x24.org>
Date
Jan 18, 2019, 10:45 UTC
Message-ID
<20190118104519.fqpzirux5qulkcwa@dcvr>
In-Reply-To
<a7307f431e2231dd420a0190a22aa38094cd593f.camel@novalis.org>
David Turner <novalis@novalis.org> wrote:
Show 6 quoted lines
> It appears that get_oid_with_context calls into get_short_oid for that
> case, and get_short_oid returns SHORT_NAME_AMBIGUOUS, which is -2.  We
> treat that as DANGLING_SYMLINK, which also seems to have the value -2. 
> So, it's an ambiguity in ambiguity resolution.
> 
> Fix attached.  

Thanks for the quick response. Unfortunately, the patch makes the situation worse for me...

Show 20 quoted lines
> diff --git a/builtin/cat-file.c b/builtin/cat-file.c
> index 2ca56fd086..f2344b199f 100644
> --- a/builtin/cat-file.c
> +++ b/builtin/cat-file.c
> @@ -380,7 +380,7 @@ static void batch_one_object(const char *obj_name,
>  {
>  	struct object_context ctx;
>  	int flags = opt->follow_symlinks ? GET_OID_FOLLOW_SYMLINKS : 0;
> -	enum follow_symlinks_result result;
> +	enum get_oid_result result;
>  
>  	result = get_oid_with_context(obj_name, flags, &data->oid, &ctx);
>  	if (result != FOUND) {
> @@ -388,6 +388,9 @@ static void batch_one_object(const char *obj_name,
>  		case MISSING_OBJECT:
>  			printf("%s missing\n", obj_name);
>  			break;
> +		case SHORT_NAME_AMBIGUOUS:
> +			/* We've already printed the ambiguous message */
> +			break;

Because the message about ambiguity only goes to stderr. Something needs to go to stdout, or else the reader process would hang forever.

I've already updated my code[1] to work around "dangling", but maybe printing "ambiguous" similar to the "missing" message would be appropriate? Something like:

		case SHORT_NAME_AMBIGUOUS:
			printf("%s ambiguous\n", obj_name);
			break;
(Along with a manpage update)
[1] new stuff for public-inbox on the way :>
Previous: David TurnerNext: David Turner
Message 3 of 8 in “cat-file ambiguity prints "dangling"”
  1. Eric WongJan 18, 2019
  2. David TurnerJan 18, 2019
  3. Eric WongJan 18, 2019
  4. David TurnerJan 18, 2019
  5. t1512: test ambiguous cat-file --batch and --batch-outputEric Wong, Jan 18, 2019
  6. David TurnerJan 18, 2019
  7. SZEDER GáborJan 23, 2019
  8. t1512: test ambiguous cat-file --batch and --batch-outputEric Wong, Jan 30, 2019

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.