Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit d1d0945

Browse files
rscharfegitster
authored andcommitted
run-command: use internal argv_array of struct child_process in run_hook_ve()
Use the existing argv_array member instead of providing our own. This way we don't have to initialize or clean it up explicitly. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4bbaa1e commit d1d0945

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

run-command.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -770,28 +770,21 @@ char *find_hook(const char *name)
770770
int run_hook_ve(const char *const *env, const char *name, va_list args)
771771
{
772772
struct child_process hook;
773-
struct argv_array argv = ARGV_ARRAY_INIT;
774773
const char *p;
775-
int ret;
776774

777775
p = find_hook(name);
778776
if (!p)
779777
return 0;
780778

781-
argv_array_push(&argv, p);
782-
783-
while ((p = va_arg(args, const char *)))
784-
argv_array_push(&argv, p);
785-
786779
memset(&hook, 0, sizeof(hook));
787-
hook.argv = argv.argv;
780+
argv_array_push(&hook.args, p);
781+
while ((p = va_arg(args, const char *)))
782+
argv_array_push(&hook.args, p);
788783
hook.env = env;
789784
hook.no_stdin = 1;
790785
hook.stdout_to_stderr = 1;
791786

792-
ret = run_command(&hook);
793-
argv_array_clear(&argv);
794-
return ret;
787+
return run_command(&hook);
795788
}
796789

797790
int run_hook_le(const char *const *env, const char *name, ...)

0 commit comments

Comments
 (0)