All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Benoit Pierre <benoit.pierre@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/6] commit: fix patch hunk editing with "commit -p -m"
Date: Thu, 06 Mar 2014 13:25:14 -0800	[thread overview]
Message-ID: <xmqqr46fvx39.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1394117424-29780-3-git-send-email-benoit.pierre@gmail.com> (Benoit Pierre's message of "Thu, 6 Mar 2014 15:50:20 +0100")

Benoit Pierre <benoit.pierre@gmail.com> 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.

  reply	other threads:[~2014-03-06 21:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06 14:50 [PATCH 0/6] fix hunk editing with 'commit -p -m' Benoit Pierre
2014-03-06 14:50 ` [PATCH 1/6] test patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-06 22:07   ` Eric Sunshine
2014-03-06 23:11     ` Junio C Hamano
2014-03-06 14:50 ` [PATCH 2/6] commit: fix " Benoit Pierre
2014-03-06 21:25   ` Junio C Hamano [this message]
2014-03-06 21:47     ` Junio C Hamano
2014-03-06 14:50 ` [PATCH 3/6] merge: fix GIT_EDITOR override for commit hook Benoit Pierre
2014-03-06 14:50 ` [PATCH 4/6] merge hook tests: fix and update tests Benoit Pierre
2014-03-06 22:11   ` Eric Sunshine
2014-03-06 14:50 ` [PATCH 5/6] merge hook tests: fix missing '&&' in test Benoit Pierre
2014-03-06 21:27   ` Junio C Hamano
2014-03-06 14:50 ` [PATCH 6/6] merge hook tests: use 'test_must_fail' instead of '!' Benoit Pierre
2014-03-06 21:29   ` Junio C Hamano
2014-03-07  0:35     ` Junio C Hamano
2014-03-06 21:15 ` [PATCH 0/6] fix hunk editing with 'commit -p -m' Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqr46fvx39.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=benoit.pierre@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.