summaryrefslogtreecommitdiff
path: root/Documentation/technical/api-run-command.txt
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-05-15 08:33:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-05-15 16:49:09 (GMT)
commitc460c0ecdca46be85f6d9c845f9df7ce0e45c3c2 (patch)
tree84de4c342f5af7f070a33b974691f3282892426b /Documentation/technical/api-run-command.txt
parent6308767f0bb58116cb405e1f4f77f5dfc1589920 (diff)
downloadgit-c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2.zip
git-c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2.tar.gz
git-c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2.tar.bz2
run-command: store an optional argv_array
All child_process structs need to point to an argv. For flexibility, we do not mandate the use of a dynamic argv_array. However, because the child_process does not own the memory, this can make memory management with a separate argv_array difficult. For example, if a function calls start_command but not finish_command, the argv memory must persist. The code needs to arrange to clean up the argv_array separately after finish_command runs. As a result, some of our code in this situation just leaks the memory. To help such cases, this patch adds a built-in argv_array to the child_process, which gets cleaned up automatically (both in finish_command and when start_command fails). Callers may use it if they choose, but can continue to use the raw argv if they wish. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/technical/api-run-command.txt')
-rw-r--r--Documentation/technical/api-run-command.txt7
1 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
index 5d7d7f2..69510ae 100644
--- a/Documentation/technical/api-run-command.txt
+++ b/Documentation/technical/api-run-command.txt
@@ -109,6 +109,13 @@ terminated), of which .argv[0] is the program name to run (usually
without a path). If the command to run is a git command, set argv[0] to
the command name without the 'git-' prefix and set .git_cmd = 1.
+Note that the ownership of the memory pointed to by .argv stays with the
+caller, but it should survive until `finish_command` completes. If the
+.argv member is NULL, `start_command` will point it at the .args
+`argv_array` (so you may use one or the other, but you must use exactly
+one). The memory in .args will be cleaned up automatically during
+`finish_command` (or during `start_command` when it is unsuccessful).
+
The members .in, .out, .err are used to redirect stdin, stdout,
stderr as follows: