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

Re: [PATCH 2/5 v2] unpack_trees: group errors by type

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 15, 2010, 13:28 UTC
Message-ID
<vpq7hm0whkk.fsf@bauges.imag.fr>
In-Reply-To
<AANLkTin381eyaDabz3-z_8jB05N4CVKGmLOqVOprJMW2@mail.gmail.com>
Diane Gasselin <diane.gasselin@ensimag.imag.fr> writes:
> In display_error_msgs(), I cannot access o->msg because I would not
> know which error I am treating.
You do:
static void display_error_msgs(struct unpack_trees_options *o)
{
...
	for (i = 0; i < NB_UNPACK_TREES_ERROR; i++) {
		...
	}

You know "i", so you know which error it is. The difficulty is that the rejected paths are in an array, while the error messages are in a struct, but you can either:

* Turn the struct into an array, and say msgs[would_overwrite] instead
  of msgs.would_overwrite (which would also simplify the code
  elsewhere since you would be able to write "ERRORMSG(o, error)" and
  such things).
* Do
switch (i) {
case would_overwrite:
	msg = o->msg.would_overwrite;
	break;
case not_uptodate_file:
	msg = o->msg.not_uptodate_file;
	break;
case not_uptodate_dir:
	msg = o->msg.not_uptodate_dir;
	break;
case would_lose_untracked_overwritten:
	msg = o->msg.would_lose_untracked_overwritten;
	break;
case would_lose_untracked_removed:
	msg = o->msg.would_lose_untracked_removed;
	break;
case sparse_not_uptodate_file:
	msg = o->msg.sparse_not_uptodate_file;
	break;
}
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Diane GasselinNext: Diane Gasselin
Message 11 of 13 in “unpack_trees: nicer error messages”
  1. 0/5 unpack_trees: nicer error messagesDiane Gasselin, Jun 15, 2010
  2. 1/5 merge-recursive: porcelain messages for checkoutDiane Gasselin, Jun 15, 2010
  3. 2/5 unpack_trees: group errors by typeDiane Gasselin, Jun 15, 2010
  4. 3/5 unpack_trees_options: update porcelain messagesDiane Gasselin, Jun 15, 2010
  5. 4/5 tests: update porcelain expected messageDiane Gasselin, Jun 15, 2010
  6. 5/5 t7609: test merge and checkout error messagesDiane Gasselin, Jun 15, 2010
  7. Matthieu MoyJun 15, 2010
  8. Matthieu MoyJun 15, 2010
  9. Matthieu MoyJun 15, 2010
  10. Diane GasselinJun 15, 2010
  11. Matthieu MoyJun 15, 2010
  12. Diane GasselinJun 15, 2010
  13. Matthieu MoyJun 15, 2010

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.