Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2022-10-30 14:46:11 +0300
committerTaylor Blau <me@ttaylorr.com>2022-10-30 21:04:33 +0300
commit75c92a0540dd866b1ccf5454c4cc540d926a6139 (patch)
treea1397b259d9c284598b7fbd15df2da4b6c5ff641 /builtin
parent53c4be3fd82208bde63c6f38556089428c4e5be5 (diff)
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/am.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 39fea24833..5781e7a95e 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2187,14 +2187,11 @@ static int show_patch(struct am_state *state, enum show_patch_type sub_mode)
int len;
if (!is_null_oid(&state->orig_commit)) {
- const char *av[4] = { "show", NULL, "--", NULL };
- char *new_oid_str;
- int ret;
+ const char *av[] = {
+ "show", oid_to_hex(&state->orig_commit), "--", NULL
+ };
- av[1] = new_oid_str = xstrdup(oid_to_hex(&state->orig_commit));
- ret = run_command_v_opt(av, RUN_GIT_CMD);
- free(new_oid_str);
- return ret;
+ return run_command_v_opt(av, RUN_GIT_CMD);
}
switch (sub_mode) {