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

Re: [PATCH v8 1/4] usage: make error functions a stack

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 15, 2014, 22:47 UTC
Message-ID
<xmqq7g3etf1o.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1405459754-4220-2-git-send-email-jacob.e.keller@intel.com>
Jacob Keller <jacob.e.keller@intel.com> writes:
>  extern void set_error_routine(void (*routine)(const char *err, va_list params));
> +extern void pop_error_routine(void);

pop that undoes set smells somewhat weird. Perhaps we should rename set to push? That would allow us catch possible topics that add new calls to set_error_routine() as well by forcing the system not to link when they are merged without necessary fixes.

Show 17 quoted lines
> +/* push error routine onto the error function stack */
>  void set_error_routine(void (*routine)(const char *err, va_list params))
>  {
> -	error_routine = routine;
> +	struct error_func_list *efl = xmalloc(sizeof(*efl));
> +	efl->func = routine;
> +	efl->next = error_funcs;
> +	error_funcs = efl;
> +}
> +
> +/* pop a single error routine off of the error function stack, thus reverting
> + * to previous error. Should always be paired with a set_error_routine */
> +void pop_error_routine(void)
> +{
> +	assert(error_funcs != &default_error_func);
> +
> +	struct error_func_list *efl = error_funcs;

decl-after-stmt. Can be fixed easily by flipping the above two lines.

Show 16 quoted lines
> +	if (efl->next) {
> +		error_funcs = efl->next;
> +		free(efl);
> +	}
>  }
>  
>  void set_die_is_recursing_routine(int (*routine)(void))
> @@ -144,7 +167,7 @@ int error(const char *err, ...)
>  	va_list params;
>  
>  	va_start(params, err);
> -	error_routine(err, params);
> +	error_funcs->func(err, params);
>  	va_end(params);
>  	return -1;
>  }
Previous: Jacob KellerNext: Keller, Jacob E
Message 3 of 11 in “tag: configure default tag sort via .gitconfig”
  1. 0/4 tag: configure default tag sort via .gitconfigJacob Keller, Jul 15, 2014
  2. 1/4 usage: make error functions a stackJacob Keller, Jul 15, 2014
  3. Junio C HamanoJul 15, 2014
  4. Keller, Jacob EJul 15, 2014
  5. Keller, Jacob EJul 15, 2014
  6. Junio C HamanoJul 16, 2014
  7. Keller, Jacob EJul 16, 2014
  8. 2/4 tag: fix --sort tests to use cat<<-\EOF formatJacob Keller, Jul 15, 2014
  9. 3/4 tag: update parsing to be more precise regarding errorsJacob Keller, Jul 15, 2014
  10. 4/4 tag: support configuring --sort via .gitconfigJacob Keller, Jul 15, 2014
  11. Junio C HamanoJul 15, 2014

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.