git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jim Meyering <jim@meyering.net>, git@vger.kernel.org
Cc: Matthias Lederhofer <matled@gmx.net>
Subject: Re: [PATCH 2/2] Check for IO errors after running a command
Date: Mon, 25 Jun 2007 02:44:14 -0700	[thread overview]
Message-ID: <7vy7i8xtap.fsf@assigned-by-dhcp.pobox.com> (raw)
In-Reply-To: alpine.LFD.0.98.0706241010480.3593@woody.linux-foundation.org

Linus Torvalds <torvalds@linux-foundation.org> writes:

> Side note: I think I made a mistake in making the run_command() a NORETURN 
> function and putting the exit() into it. It's probably better to instead 
> just make it return "int", and make the caller do
>
> 	exit(run_command(...));
>
> and that makes it much prettier to have "run_command()" just return early 
> if an error happens (or doesn't happen).
>
> For example, then we could just do
>
> 	status = p->fn(...);
> 	if (status)
> 		return status;
> 	/* Somebody closed stdout? */
> 	if (fstat(fileno(stdout), &st))
> 		return 0;
> 	/* Ignore write errors for pipes and sockets.. */
> 	if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))
> 		return 0;
>
> which makes it easy to explain what's going on, and avoids having any deep 
> indentation at all.

I took the liberty of munging your two patches to follow your
comments above (it was a perfect guinea-pig opportunity for
Johannes's "rebase -i").

The changes to git.c (run_command) conflicted with GIT_WORK_TREE
changes in a minor way.  Matthias, could you sanity check the
result once I push it out to 'next', please?

  reply	other threads:[~2007-06-25  9:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-23 15:13 (resend) [PATCH] Don't ignore write failure from git-diff, git-log, etc Jim Meyering
2007-06-24  9:01 ` Junio C Hamano
2007-06-24 17:08   ` Linus Torvalds
2007-06-24 17:10     ` [PATCH 1/2] Clean up internal command handling Linus Torvalds
2007-06-24 17:29     ` [PATCH 2/2] Check for IO errors after running a command Linus Torvalds
2007-06-25  9:44       ` Junio C Hamano [this message]
2007-06-25 13:20         ` Johannes Schindelin
2007-06-25 13:42           ` Johannes Sixt
2007-06-25 14:01         ` Jim Meyering
2007-06-25 15:57           ` Linus Torvalds
2007-06-26 13:33         ` Matthias Lederhofer
2007-06-25 19:54       ` Jim Meyering
2007-06-24 19:13     ` (resend) [PATCH] Don't ignore write failure from git-diff, git-log, etc Jim Meyering

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

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

  git send-email \
    --in-reply-to=7vy7i8xtap.fsf@assigned-by-dhcp.pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jim@meyering.net \
    --cc=torvalds@linux-foundation.org \
    /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.
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 NNTP newsgroup(s).