From 53c4be3fd82208bde63c6f38556089428c4e5be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 30 Oct 2022 12:45:13 +0100 Subject: run-command: fix return value comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 483bbd4e4c (run-command: introduce child_process_init(), 2014-08-19) and 2d71608ec0 (run-command: factor out child_process_clear(), 2015-10-24) added help texts about child_process_init() and child_process_clear() without updating the immediately following documentation of return codes that only applied to the preexisting functions. 4c4066d95d (run-command: move doc to run-command.h, 2019-11-17) started to list the functions explicitly that this paragraph applies to, but still wrongly included child_process_init() and child_process_clear(). Remove their names from that list. Suggested-by: Ævar Arnfjörð Bjarmason Signed-off-by: René Scharfe Signed-off-by: Taylor Blau --- run-command.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 0e85e5846a..61073fc589 100644 --- a/run-command.h +++ b/run-command.h @@ -150,9 +150,8 @@ struct child_process { } /** - * The functions: child_process_init, start_command, finish_command, - * run_command, run_command_v_opt, run_command_v_opt_cd_env, child_process_clear - * do the following: + * The functions: start_command, finish_command, run_command, + * run_command_v_opt, run_command_v_opt_cd_env do the following: * * - If a system call failed, errno is set and -1 is returned. A diagnostic * is printed. -- cgit v1.2.3 From eb5b6b57d0e9fba0e50871ece4ea79e76cd61a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 30 Oct 2022 12:51:55 +0100 Subject: replace and remove run_command_v_opt_cd_env() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run_command_v_opt_cd_env() is only used in an example in a comment. Use the struct child_process member "env" and run_command() directly instead and then remove the unused convenience function. Signed-off-by: René Scharfe Signed-off-by: Taylor Blau --- run-command.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 61073fc589..39e5eae8ba 100644 --- a/run-command.h +++ b/run-command.h @@ -151,7 +151,7 @@ struct child_process { /** * The functions: start_command, finish_command, run_command, - * run_command_v_opt, run_command_v_opt_cd_env do the following: + * run_command_v_opt do the following: * * - If a system call failed, errno is set and -1 is returned. A diagnostic * is printed. @@ -249,7 +249,6 @@ int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class); * env (the environment) is to be formatted like environ: "VAR=VALUE". * To unset an environment variable use just "VAR". */ -int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env); int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, const char *const *env, const char *tr2_class); -- cgit v1.2.3 From d82dbbd849fadd9d61d9489a03b429b6d1413c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 30 Oct 2022 12:52:40 +0100 Subject: replace and remove run_command_v_opt_tr2() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The convenience function run_command_v_opt_tr2() is only used by a single caller. Use struct child_process and run_command() directly instead and remove the underused function. Signed-off-by: René Scharfe Signed-off-by: Taylor Blau --- run-command.h | 1 - 1 file changed, 1 deletion(-) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 39e5eae8ba..1bfa18575e 100644 --- a/run-command.h +++ b/run-command.h @@ -244,7 +244,6 @@ int run_auto_maintenance(int quiet); * corresponds to the member .env. */ int run_command_v_opt(const char **argv, int opt); -int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class); /* * env (the environment) is to be formatted like environ: "VAR=VALUE". * To unset an environment variable use just "VAR". -- cgit v1.2.3 From ef249b398e26dd76f473ce83a35219c520f6fdbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 30 Oct 2022 12:53:40 +0100 Subject: replace and remove run_command_v_opt_cd_env_tr2() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The convenience function run_command_v_opt_cd_env_tr2() has no external callers left. Inline it and remove it from the API. Signed-off-by: René Scharfe Signed-off-by: Taylor Blau --- run-command.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 1bfa18575e..63ed6e18ff 100644 --- a/run-command.h +++ b/run-command.h @@ -233,23 +233,15 @@ int run_auto_maintenance(int quiet); #define RUN_CLOSE_OBJECT_STORE (1<<7) /** - * Convenience functions that encapsulate a sequence of + * Convenience function that encapsulates a sequence of * start_command() followed by finish_command(). The argument argv * specifies the program and its arguments. The argument opt is zero * or more of the flags `RUN_COMMAND_NO_STDIN`, `RUN_GIT_CMD`, * `RUN_COMMAND_STDOUT_TO_STDERR`, or `RUN_SILENT_EXEC_FAILURE` * that correspond to the members .no_stdin, .git_cmd, * .stdout_to_stderr, .silent_exec_failure of `struct child_process`. - * The argument dir corresponds the member .dir. The argument env - * corresponds to the member .env. */ int run_command_v_opt(const char **argv, int opt); -/* - * env (the environment) is to be formatted like environ: "VAR=VALUE". - * To unset an environment variable use just "VAR". - */ -int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, - const char *const *env, const char *tr2_class); /** * Execute the given command, sending "in" to its stdin, and capturing its -- cgit v1.2.3 From ddbb47fde9b6d8cd9f3728847a378f634318cfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 30 Oct 2022 12:55:06 +0100 Subject: replace and remove run_command_v_opt() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the remaining calls of run_command_v_opt() with run_command() calls and explict struct child_process variables. This is more verbose, but not by much overall. The code becomes more flexible, e.g. it's easy to extend to conditionally add a new argument. Then remove the now unused function and its own flag names, simplifying the run-command API. Suggested-by: Jeff King Signed-off-by: René Scharfe Signed-off-by: Taylor Blau --- run-command.h | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 63ed6e18ff..41cc8470dc 100644 --- a/run-command.h +++ b/run-command.h @@ -150,8 +150,7 @@ struct child_process { } /** - * The functions: start_command, finish_command, run_command, - * run_command_v_opt do the following: + * The functions: start_command, finish_command, run_command do the following: * * - If a system call failed, errno is set and -1 is returned. A diagnostic * is printed. @@ -223,26 +222,6 @@ int run_command(struct child_process *); */ int run_auto_maintenance(int quiet); -#define RUN_COMMAND_NO_STDIN (1<<0) -#define RUN_GIT_CMD (1<<1) -#define RUN_COMMAND_STDOUT_TO_STDERR (1<<2) -#define RUN_SILENT_EXEC_FAILURE (1<<3) -#define RUN_USING_SHELL (1<<4) -#define RUN_CLEAN_ON_EXIT (1<<5) -#define RUN_WAIT_AFTER_CLEAN (1<<6) -#define RUN_CLOSE_OBJECT_STORE (1<<7) - -/** - * Convenience function that encapsulates a sequence of - * start_command() followed by finish_command(). The argument argv - * specifies the program and its arguments. The argument opt is zero - * or more of the flags `RUN_COMMAND_NO_STDIN`, `RUN_GIT_CMD`, - * `RUN_COMMAND_STDOUT_TO_STDERR`, or `RUN_SILENT_EXEC_FAILURE` - * that correspond to the members .no_stdin, .git_cmd, - * .stdout_to_stderr, .silent_exec_failure of `struct child_process`. - */ -int run_command_v_opt(const char **argv, int opt); - /** * Execute the given command, sending "in" to its stdin, and capturing its * stdout and stderr in the "out" and "err" strbufs. Any of the three may -- cgit v1.2.3