git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: "Johannes Sixt" <j6t@kdbg.org>, git <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Karsten Blees" <karsten.blees@gmail.com>,
	"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>,
	"Stefan Beller" <sbeller@google.com>,
	"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
	"Christian Couder" <chriscool@tuxfamily.org>
Subject: Re: [PATCH 80/83] run-command: make dup_devnull() non static
Date: Sat, 7 May 2016 15:46:58 +0200	[thread overview]
Message-ID: <CAP8UFD2wFZgOzmadm7X2988RyDGve92TsoMHPf2S5Ydyhc=Nyg@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1605071409490.2963@virtualbox>

Hi Dscho,

On Sat, May 7, 2016 at 2:13 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi Chris,
>
> On Sat, 7 May 2016, Christian Couder wrote:
>
>> On Fri, May 6, 2016 at 5:34 PM, Johannes Schindelin
>> <Johannes.Schindelin@gmx.de> wrote:
>> >
>> > No, you should change the code that requires that ugly dup()ing so that it
>> > can be configured to shut up.
>>
>> After taking a look, it looks like a routine that does nothing could
>> be passed to set_error_routine() and that could do part of the trick.
>>
>> This part might not be too ugly, but it would anyway be more complex,
>> less close to what the code is doing now and more error prone, as one
>> also need to make sure that for example no warning() or
>> fprintf(stderr, ...) are called and nothing is printed on stdout.
>
> I am afraid that you *have* to do that, though, if you truly want to
> libify the code.
>
> Of course you can go with really ugly workarounds instead. Something like
> a global flag that die() and error() and warning() respect. It would
> incur some technical debt, but it would make your life easier in the short
> run.
>
> Both the real solution and the workaround would be better than the current
> version of the patches that dup() back and forth, just to avoid addressing
> the real problem.

The code that is now in master in builtin/am.c does:

    if (state->threeway && !index_file) {
        cp.no_stdout = 1;
        cp.no_stderr = 1;
    }

and in run-command.c there is already:

        if (cmd->no_stdout)
            dup_devnull(1);
        [...]
        if (cmd->no_stderr)
            dup_devnull(2);

for Linux and the following for Windows:

    if (cmd->no_stderr)
        fherr = open("/dev/null", O_RDWR);
        [...]
    if (cmd->no_stdout)
        fhout = open("/dev/null", O_RDWR);

so the current code is already using dup_devnull() for Linux that you
don't want me to use, and it looks like there is already a simple way
to do that on Windows.

So what's the problem? Isn't it just that you don't want a
dup_devnull() for Windows that would be a few lines long?

You keep saying that what is done in this patch is "ugly" or that
there is a "real problem", but frankly I don't see why. Could you
explain exactly why?
Because the more I look at it, the more it looks to me like the
solution that is the simplest (even for Windows), the safest and the
closest to what the current code is doing.

Thanks,
Christian.

  reply	other threads:[~2016-05-07 13:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 13:39 [PATCH 80/83] run-command: make dup_devnull() non static Christian Couder
2016-04-24 13:39 ` [PATCH 81/83] apply: roll back index in case of error Christian Couder
2016-04-25 16:06   ` Johannes Schindelin
2016-05-02  7:07     ` Johannes Schindelin
2016-05-02  7:18       ` Eric Sunshine
2016-05-03 12:57     ` Christian Couder
2016-04-24 13:39 ` [PATCH 82/83] environment: add set_index_file() Christian Couder
2016-05-03 15:36   ` Junio C Hamano
2016-05-04 11:50     ` Christian Couder
2016-04-24 13:39 ` [PATCH 83/83] builtin/am: use apply api in run_apply() Christian Couder
2016-04-25 15:03   ` Johannes Schindelin
2016-05-05 10:04     ` Christian Couder
2016-04-25 15:05 ` [PATCH 80/83] run-command: make dup_devnull() non static Johannes Schindelin
2016-05-05  9:50   ` Christian Couder
2016-05-05 20:07     ` Johannes Sixt
2016-05-06 13:56       ` Christian Couder
2016-05-06 15:34         ` Johannes Schindelin
2016-05-07 10:12           ` Christian Couder
2016-05-07 12:13             ` Johannes Schindelin
2016-05-07 13:46               ` Christian Couder [this message]
2016-05-08  6:33                 ` Johannes Schindelin
2016-05-08 10:15                   ` Duy Nguyen
2016-05-09 15:05                     ` Johannes Schindelin
2016-05-09 17:40                     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP8UFD2wFZgOzmadm7X2988RyDGve92TsoMHPf2S5Ydyhc=Nyg@mail.gmail.com' \
    --to=christian.couder@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=avarab@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=karsten.blees@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).