Re: [PATCH 2/6] commit: fix patch hunk editing with "commit -p -m"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Benoit Pierre <benoit.pierre@xxxxxxxxx> writes:

> +int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...)
> +{
> +	const char *hook_env[3] =  { NULL };
> +	char index[PATH_MAX];
> +	va_list args;
> +	int ret;
> +
> +	snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
> +	hook_env[0] = index;
> +
> +	/*
> +	 * Let the hook know that no editor will be launched.
> +	 */
> +	if (!editor_is_used)
> +		hook_env[1] = "GIT_EDITOR=:";
> +
> +	va_start(args, name);
> +	ret = run_hook_v(hook_env, name, args);

> diff --git a/run-command.c b/run-command.c
> index 3914d9c..4e9be12 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -760,13 +760,11 @@ char *find_hook(const char *name)
>  	return path;
>  }
>  
> -int run_hook(const char *index_file, const char *name, ...)
> +int run_hook_v(const char *const *env, const char *name, va_list args)
>  {

I think you named it as "foo_v()" for "this takes va_list" in a way
similar to the "v" in "execv()", but this also takes environment, so
perhaps we want to say "ve" instead?

Other than that, I like it---I admit that I am biased that I
essentially did the same earlier but with a _le variant ;-)

> +int run_hook(const char *const *env, const char *name, ...)
> +{

I'd rather not to see this changed in the same commit, so that any
other topic in-flight that adds a new call to run_hook() that expects
to pass the index file as its first parameter will not be broken.

Name it run_hook_le() (name modelled after execle()), and call it in
your change where you add new calls to this function, and add a thin
wrapper run_hook() that preserves the traditional "We can pass only
the index-file" for new callers we do not even know about on the
topics in flight.

Later we can eradicate callers of run_hook() that treats the index-file
specially, which was a grave mistake in a public API.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]