<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/run-command.h, branch v2.4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.4.9</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2015-03-23T04:38:31Z</updated>
<entry>
<title>run-command: introduce capture_command helper</title>
<updated>2015-03-23T04:38:31Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-03-23T03:53:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=911ec99b688fc4d5673a0fc8984b22ff2251e490'/>
<id>urn:sha1:911ec99b688fc4d5673a0fc8984b22ff2251e490</id>
<content type='text'>
Something as simple as reading the stdout from a command
turns out to be rather hard to do right. Doing:

  cmd.out = -1;
  run_command(&amp;cmd);
  strbuf_read(&amp;buf, cmd.out, 0);

can result in deadlock if the child process produces a large
amount of output. What happens is:

  1. The parent spawns the child with its stdout connected
     to a pipe, of which the parent is the sole reader.

  2. The parent calls wait(), blocking until the child exits.

  3. The child writes to stdout. If it writes more data than
     the OS pipe buffer can hold, the write() call will
     block.

This is a deadlock; the parent is waiting for the child to
exit, and the child is waiting for the parent to call
read().

So we might try instead:

  start_command(&amp;cmd);
  strbuf_read(&amp;buf, cmd.out, 0);
  finish_command(&amp;cmd);

But that is not quite right either. We are examining cmd.out
and running finish_command whether start_command succeeded
or not, which is wrong. Moreover, these snippets do not do
any error handling. If our read() fails, we must make sure
to still call finish_command (to reap the child process).
And both snippets failed to close the cmd.out descriptor,
which they must do (provided start_command succeeded).

Let's introduce a run-command helper that can make this a
bit simpler for callers to get right.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/hook-cleanup'</title>
<updated>2014-12-22T20:27:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-12-22T20:27:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=77a801d23788991a752a19a45a7474fa8b707082'/>
<id>urn:sha1:77a801d23788991a752a19a45a7474fa8b707082</id>
<content type='text'>
Remove unused code.

* jc/hook-cleanup:
  run-command.c: retire unused run_hook_with_custom_index()
</content>
</entry>
<entry>
<title>run-command.c: retire unused run_hook_with_custom_index()</title>
<updated>2014-12-01T16:39:43Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-12-01T16:39:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=814dd8e07890c442480c5aacff9a7f1d10beb062'/>
<id>urn:sha1:814dd8e07890c442480c5aacff9a7f1d10beb062</id>
<content type='text'>
This was originally meant to be used to rewrite run_commit_hook()
that only special cases the GIT_INDEX_FILE environment, but the
run_hook_ve() refactoring done earlier made the implementation of
run_commit_hook() thin and clean enough.

Nobody uses this, so retire it as an unfinished clean-up made
unnecessary.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: add env_array, an optional argv_array for env</title>
<updated>2014-10-19T22:26:31Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-10-19T11:13:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=19a583dc39e3e1110f746e837c5ce1953d6ebfa1'/>
<id>urn:sha1:19a583dc39e3e1110f746e837c5ce1953d6ebfa1</id>
<content type='text'>
Similar to args, add a struct argv_array member to struct child_process
that simplifies specifying the environment for children.  It is freed
automatically by finish_command() or if start_command() encounters an
error.

Suggested-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: introduce child_process_init()</title>
<updated>2014-08-20T16:54:58Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-08-19T19:10:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=483bbd4e4ce8a5c717cd47d732893317a14c965a'/>
<id>urn:sha1:483bbd4e4ce8a5c717cd47d732893317a14c965a</id>
<content type='text'>
Add a helper function for initializing those struct child_process
variables for which the macro CHILD_PROCESS_INIT can't be used.

Suggested-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: introduce CHILD_PROCESS_INIT</title>
<updated>2014-08-20T16:53:37Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-08-19T19:09:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d3180279322c7450a47decf8833de47f444ca93f'/>
<id>urn:sha1:d3180279322c7450a47decf8833de47f444ca93f</id>
<content type='text'>
Most struct child_process variables are cleared using memset first after
declaration.  Provide a macro, CHILD_PROCESS_INIT, that can be used to
initialize them statically instead.  That's shorter, doesn't require a
function call and is slightly more readable (especially given that we
already have STRBUF_INIT, ARGV_ARRAY_INIT etc.).

Helped-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: store an optional argv_array</title>
<updated>2014-05-15T16:49:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-05-15T08:33:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2'/>
<id>urn:sha1:c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2</id>
<content type='text'>
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 &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: mark run_hook_with_custom_index as deprecated</title>
<updated>2014-03-18T18:26:12Z</updated>
<author>
<name>Benoit Pierre</name>
<email>benoit.pierre@gmail.com</email>
</author>
<published>2014-03-18T10:00:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b549be0da7ff9075c0b3de14c1d5d03583ca8d2d'/>
<id>urn:sha1:b549be0da7ff9075c0b3de14c1d5d03583ca8d2d</id>
<content type='text'>
Signed-off-by: Benoit Pierre &lt;benoit.pierre@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>commit: fix patch hunk editing with "commit -p -m"</title>
<updated>2014-03-18T18:25:12Z</updated>
<author>
<name>Benoit Pierre</name>
<email>benoit.pierre@gmail.com</email>
</author>
<published>2014-03-18T10:00:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=15048f8a9ace23df67161746ca76b4f46114deee'/>
<id>urn:sha1:15048f8a9ace23df67161746ca76b4f46114deee</id>
<content type='text'>
Don't change git environment: move the GIT_EDITOR=":" override to the
hook command subprocess, like it's already done for GIT_INDEX_FILE.

Signed-off-by: Benoit Pierre &lt;benoit.pierre@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Add the LAST_ARG_MUST_BE_NULL macro</title>
<updated>2013-07-19T16:26:15Z</updated>
<author>
<name>Ramsay Jones</name>
<email>ramsay@ramsay1.demon.co.uk</email>
</author>
<published>2013-07-18T20:02:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9fe3edc47f1f17a53272671c572c90ba71eb4f74'/>
<id>urn:sha1:9fe3edc47f1f17a53272671c572c90ba71eb4f74</id>
<content type='text'>
The sentinel function attribute is not understood by versions of
the gcc compiler prior to v4.0. At present, for earlier versions
of gcc, the build issues 108 warnings related to the unknown
attribute. In order to suppress the warnings, we conditionally
define the LAST_ARG_MUST_BE_NULL macro to provide the sentinel attribute
for gcc v4.0 and newer.

Signed-off-by: Ramsay Jones &lt;ramsay@ramsay1.demon.co.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
