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

Re: Improving merge failure message

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Sep 8, 2009, 08:24 UTC
Message-ID
<4AA614A2.2060908@viscovery.net>
In-Reply-To
<7vbplmhr0i.fsf@alter.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 14 quoted lines
> Nanako Shiraishi <nanako3@lavabit.com> writes:
> 
>> [2]% git merge feature
>> error: Entry 'cool' not uptodate. Cannot merge.
>> fatal: merging of trees 8ec1d96451ff05451720e4e8968812c46b35e5e4 and aad8d5cef3915ab78b3227abaaac99b62db9eb54 failed
>>
>> ... the messages look unnecessarily scary, with two
>> "error" and "fatal" comments, and long sha1 commit names.
> 
>> It would be nice if the message in the latter case can be toned down.
> 
> Yeah, it would be nice.  This actually was something that bothered me as
> well while trying to explain the recovery procedure for these two cases.
> Give me half an hour or so to cook up something...

I think that this is a symptom of a much more involved issue about error handling.

Currently, it is customary in the code to report an error at each location where an exceptional condition is detected:

	if (frotz())
		ret = error("frotz messed up");

If frotz() is a "low-level" routine, like a C library function, then this is the right thing to do. However, if frotz() is our own function ("high-level") which itself calls low-level functions with the same pattern, then this is obviously the wrong thing to do, because it results into two error messages.

We need a guideline how errors are reported. This guideline could be:

(1) Low-level functions do not print error messages, but set an error code and leave the reporting to the caller.

(2) High-level functions must print an error message (through error() or die()) when they detect a failure of a low-level function that was called directly.

(3) High-level functions must not print an error message when they detect a failure of another high-level function that was called directly.

There remains to classify our functions into high-level or low-level. But I think we won't have a lot of low-level functions.

BTW, I applied this guideline when I worked on {start,finish,run}_command recently, and IMHO it worked out quite nicely because exactly one error is reported after a failure.

-- Hannes
Previous: Nanako Shiraishi
Message 11 of 11 in “Improving merge failure message”
  1. Nanako ShiraishiSep 8, 2009
  2. Junio C HamanoSep 8, 2009
  3. Junio C HamanoSep 8, 2009
  4. Sverre RabbelierSep 8, 2009
  5. Junio C HamanoSep 8, 2009
  6. Jeff KingSep 8, 2009
  7. Mike RalphsonSep 8, 2009
  8. Junio C HamanoSep 8, 2009
  9. Alex RiesenSep 8, 2009
  10. Nanako ShiraishiSep 8, 2009
  11. Johannes SixtSep 8, 2009

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.