replace and remove run_command_v_opt()

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 <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
René Scharfe
2022-10-30 12:55:06 +01:00
committed by Taylor Blau
parent ef249b398e
commit ddbb47fde9
13 changed files with 92 additions and 75 deletions

View File

@ -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