mirror of
https://github.com/git/git
synced 2024-09-13 05:14:36 +00:00
am: simplify building "show" argument list
Build the string array av during initialization, without any magic numbers or heap allocations. Not duplicating the result of oid_to_hex() is safe because run_command_v_opt() duplicates all arguments already. (It would even be safe if it didn't, but that's a different story.) Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
parent
53c4be3fd8
commit
75c92a0540
11
builtin/am.c
11
builtin/am.c
|
@ -2187,14 +2187,11 @@ static int show_patch(struct am_state *state, enum show_patch_type sub_mode)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!is_null_oid(&state->orig_commit)) {
|
if (!is_null_oid(&state->orig_commit)) {
|
||||||
const char *av[4] = { "show", NULL, "--", NULL };
|
const char *av[] = {
|
||||||
char *new_oid_str;
|
"show", oid_to_hex(&state->orig_commit), "--", NULL
|
||||||
int ret;
|
};
|
||||||
|
|
||||||
av[1] = new_oid_str = xstrdup(oid_to_hex(&state->orig_commit));
|
return run_command_v_opt(av, RUN_GIT_CMD);
|
||||||
ret = run_command_v_opt(av, RUN_GIT_CMD);
|
|
||||||
free(new_oid_str);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sub_mode) {
|
switch (sub_mode) {
|
||||||
|
|
Loading…
Reference in a new issue