Re: [PATCH v3 05/13] hooks: convert 'post-checkout' hook to hook library

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

 



Ævar Arnfjörð Bjarmason  <avarab@xxxxxxxxx> writes:

>  	if (!ret && opts->checkout) {
> -		const char *hook = find_hook("post-checkout");
> -		if (hook) {
> -			const char *env[] = { "GIT_DIR", "GIT_WORK_TREE", NULL };
> -			cp.git_cmd = 0;
> -			cp.no_stdin = 1;
> -			cp.stdout_to_stderr = 1;
> -			cp.dir = path;
> -			cp.env = env;
> -			cp.argv = NULL;
> -			cp.trace2_hook_name = "post-checkout";
> -			strvec_pushl(&cp.args, absolute_path(hook),
> -				     oid_to_hex(null_oid()),
> -				     oid_to_hex(&commit->object.oid),
> -				     "1", NULL);
> -			ret = run_command(&cp);
> -		}
> +		struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
> +
> +		strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL);
> +		strvec_pushl(&opt.args,
> +			     oid_to_hex(null_oid()),
> +			     oid_to_hex(&commit->object.oid),
> +			     "1",
> +			     NULL);
> +		opt.dir = path;
> +		opt.absolute_path = 1;
> +
> +		ret = run_hooks_oneshot("post-checkout", &opt);

I can see how passing opt from the caller gives more flexibility
like allowing to pass arbitrary environments.  The interface still
looks a bit unwieldy as I expect passing command line args would be
a much more common need than tweaking the environment, but let's
keep reading.






[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]

  Powered by Linux