git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] sub-process: print the cmd when a capability is unsupported

From
Christian Couder <christian.couder@gmail.com>
Date
Aug 15, 2017, 19:29 UTC
Message-ID
<CAP8UFD2KBEVwZE8obaDxf+0AyU4zH0+5bWJzzHazFywgWT9QjQ@mail.gmail.com>
In-Reply-To
<836F754B-C78C-4D19-8365-875D96B3F115@gmail.com>

On Tue, Aug 15, 2017 at 9:00 PM, Lars Schneider <larsxschneider@gmail.com> wrote:

Show 48 quoted lines
>
>> On 15 Aug 2017, at 19:36, Christian Couder <christian.couder@gmail.com> wrote:
>>
>> In handshake_capabilities() we use warning() when a capability
>> is not supported, so the exit code of the function is 0 and no
>> further error is shown. This is a problem because the warning
>> message doesn't tell us which subprocess cmd failed.
>>
>> On the contrary if we cannot write a packet from this function,
>> we use error() and then subprocess_start() outputs:
>>
>>    initialization for subprocess '<cmd>' failed
>>
>> so we can know which subprocess cmd failed.
>>
>> Let's improve the warning() message, so that we can know which
>> subprocess cmd failed.
>>
>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
>> ---
>> sub-process.c | 13 ++++++++-----
>> 1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/sub-process.c b/sub-process.c
>> index 6edb97c1c6..6b133f8dce 100644
>> --- a/sub-process.c
>> +++ b/sub-process.c
>> @@ -158,7 +158,8 @@ static int handshake_version(struct child_process *process,
>>
>> static int handshake_capabilities(struct child_process *process,
>>                                 struct subprocess_capability *capabilities,
>> -                               unsigned int *supported_capabilities)
>> +                               unsigned int *supported_capabilities,
>> +                               const char *cmd)
>> {
>>       int i;
>>       char *line;
>> @@ -184,8 +185,8 @@ static int handshake_capabilities(struct child_process *process,
>>                       if (supported_capabilities)
>>                               *supported_capabilities |= capabilities[i].flag;
>>               } else {
>> -                     warning("external filter requested unsupported filter capability '%s'",
>> -                             p);
>> +                     warning("subprocess '%s' requested unsupported capability '%s'",
>> +                             cmd, p);
>
> Wouldn't it be possible to use "process->argv[0]"?
> Shouldn't that be the same as "cmd"?
Well in sub-process.h there is:
/* Members should not be accessed directly. */
struct subprocess_entry {
    struct hashmap_entry ent; /* must be the first member! */
    const char *cmd;
    struct child_process process;
};

so if cmd is always the same as process->argv[0], maybe there is no need for the cmd member in the first place?

Previous: Junio C HamanoNext: Christian Couder
Message 12 of 16 in “sub-process: print the cmd when a capability is unsupported”
  1. sub-process: print the cmd when a capability is unsupportedChristian Couder, Aug 15, 2017
  2. Jonathan TanAug 15, 2017
  3. Jonathan NiederAug 16, 2017
  4. Christian CouderAug 16, 2017
  5. Junio C HamanoAug 16, 2017
  6. Christian CouderAug 17, 2017
  7. Junio C HamanoAug 17, 2017
  8. Lars SchneiderAug 17, 2017
  9. Jonathan TanAug 17, 2017
  10. Lars SchneiderAug 15, 2017
  11. Junio C HamanoAug 15, 2017
  12. Christian CouderAug 15, 2017
  13. Christian CouderAug 15, 2017
  14. Lars SchneiderAug 15, 2017
  15. Christian CouderAug 15, 2017
  16. Ben PeartAug 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.