diff options
| author | Benoit Pierre <benoit.pierre@gmail.com> | 2014-03-18 11:00:53 +0100 | 
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2014-03-18 11:25:12 -0700 | 
| commit | 15048f8a9ace23df67161746ca76b4f46114deee (patch) | |
| tree | 5b7d00d2da24c8e31ede5d028b889bf06a63aaaf /run-command.c | |
| parent | 91c9c8692056c0553c6ea9239ccd46f7f3dbd877 (diff) | |
| download | git-15048f8a9ace23df67161746ca76b4f46114deee.tar.gz | |
commit: fix patch hunk editing with "commit -p -m"
Don't change git environment: move the GIT_EDITOR=":" override to the
hook command subprocess, like it's already done for GIT_INDEX_FILE.
Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.c')
| -rw-r--r-- | run-command.c | 44 | 
1 files changed, 32 insertions, 12 deletions
| diff --git a/run-command.c b/run-command.c index 3914d9c511..75abc478c6 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_ve(const char *const *env, const char *name, va_list args)  {  	struct child_process hook;  	struct argv_array argv = ARGV_ARRAY_INIT; -	const char *p, *env[2]; -	char index[PATH_MAX]; -	va_list args; +	const char *p;  	int ret;  	p = find_hook(name); @@ -775,23 +773,45 @@ int run_hook(const char *index_file, const char *name, ...)  	argv_array_push(&argv, p); -	va_start(args, name);  	while ((p = va_arg(args, const char *)))  		argv_array_push(&argv, p); -	va_end(args);  	memset(&hook, 0, sizeof(hook));  	hook.argv = argv.argv; +	hook.env = env;  	hook.no_stdin = 1;  	hook.stdout_to_stderr = 1; -	if (index_file) { -		snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); -		env[0] = index; -		env[1] = NULL; -		hook.env = env; -	}  	ret = run_command(&hook);  	argv_array_clear(&argv);  	return ret;  } + +int run_hook_le(const char *const *env, const char *name, ...) +{ +	va_list args; +	int ret; + +	va_start(args, name); +	ret = run_hook_ve(env, name, args); +	va_end(args); + +	return ret; +} + +int run_hook_with_custom_index(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; + +	va_start(args, name); +	ret = run_hook_ve(hook_env, name, args); +	va_end(args); + +	return ret; +} | 
