9ea1378d04
Various leak fixes. * ab/various-leak-fixes: built-ins: use free() not UNLEAK() if trivial, rm dead code revert: fix parse_options_concat() leak cherry-pick: free "struct replay_opts" members rebase: don't leak on "--abort" connected.c: free the "struct packed_git" sequencer.c: fix "opts->strategy" leak in read_strategy_opts() ls-files: fix a --with-tree memory leak revision API: call graph_clear() in release_revisions() unpack-file: fix ancient leak in create_temp_file() built-ins & libs & helpers: add/move destructors, fix leaks dir.c: free "ident" and "exclude_per_dir" in "struct untracked_cache" read-cache.c: clear and free "sparse_checkout_patterns" commit: discard partial cache before (re-)reading it {reset,merge}: call discard_index() before returning tests: mark tests as passing with SANITIZE=leak
33 lines
841 B
C
33 lines
841 B
C
#include "git-compat-util.h"
|
|
#include "run-command.h"
|
|
#include "strbuf.h"
|
|
|
|
int cmd_main(int argc, const char **argv)
|
|
{
|
|
const char *trash_directory = getenv("TRASH_DIRECTORY");
|
|
struct strbuf buf = STRBUF_INIT;
|
|
FILE *f;
|
|
int i;
|
|
struct child_process cmd = CHILD_PROCESS_INIT;
|
|
|
|
/* First, print all parameters into $TRASH_DIRECTORY/ssh-output */
|
|
if (!trash_directory)
|
|
die("Need a TRASH_DIRECTORY!");
|
|
strbuf_addf(&buf, "%s/ssh-output", trash_directory);
|
|
f = fopen(buf.buf, "w");
|
|
if (!f)
|
|
die("Could not write to %s", buf.buf);
|
|
strbuf_release(&buf);
|
|
for (i = 0; i < argc; i++)
|
|
fprintf(f, "%s%s", i > 0 ? " " : "", i > 0 ? argv[i] : "ssh:");
|
|
fprintf(f, "\n");
|
|
fclose(f);
|
|
|
|
/* Now, evaluate the *last* parameter */
|
|
if (argc < 2)
|
|
return 0;
|
|
cmd.use_shell = 1;
|
|
strvec_push(&cmd.args, argv[argc - 1]);
|
|
return run_command(&cmd);
|
|
}
|