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

Re: [PATCH 1/2] sha1_name: don't trigger detailed diagnosis for file arguments

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 18, 2012, 18:01 UTC
Message-ID
<7vwr3433et.fsf@alter.siamese.dyndns.org>
In-Reply-To
<vpqipeopkpj.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 35 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>>
>>> My version reads as
>>>
>>>   try something;
>>>   if (it failed && I'm only here to report an error)
>>>           report_error();
>>>
>>> which I find easier to understand.
>>
>> I agree that _this_ part is easy to understand when written that
>> way.  But then shouldn't there be a blanket "The caller is here only
>> to report an error, but all the previous code didn't find any error,
>> so there is something wrong" check much later in the code before it
>> returns a success?  Or am I being too paranoid?
>
> Currently, there's no problem if get_sha1_with_context_1 returns without
> dying, because the caller does:
>
> 	if (!(arg[0] == ':' && !isalnum(arg[1])))
> 		/* try a detailed diagnostic ... */
> 		get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);
>
> 	/* ... or fall back the most general message. */
> 	die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
> 	    "Use '--' to separate paths from revisions", arg);
>
> If we failed to give a nice diagnosis, we give the generic error
> message.
>
> We could add this check within get_sha1_with_context_1 to simplify the
> task of the caller, but that would require adding it before each
> "return" statement, which I think is overkill.
OK.
Previous: Matthieu Moy
Message 16 of 16 in “"Detailed diagnosis" perhaps broken”
  1. Junio C HamanoJun 15, 2012
  2. Matthieu MoyJun 17, 2012
  3. 1/2 sha1_name: don't trigger detailed diagnosis for file argumentsMatthieu Moy, Jun 17, 2012
  4. 2/2 verify_filename: ask the caller to chose the kind of diagnosisMatthieu Moy, Jun 17, 2012
  5. Junio C HamanoJun 17, 2012
  6. Matthieu MoyJun 18, 2012
  7. Junio C HamanoJun 18, 2012
  8. 1/2 sha1_name: don't trigger detailed diagnosis for file argumentsMatthieu Moy, Jun 18, 2012
  9. 2/2 verify_filename: ask the caller to chose the kind of diagnosisMatthieu Moy, Jun 18, 2012
  10. Junio C HamanoJun 18, 2012
  11. Matthieu MoyJun 19, 2012
  12. Junio C HamanoJun 18, 2012
  13. Matthieu MoyJun 18, 2012
  14. Junio C HamanoJun 18, 2012
  15. Matthieu MoyJun 18, 2012
  16. Junio C HamanoJun 18, 2012

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.