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

Re: [PATCH] Don't ignore write failure from git-diff, git-log, etc.

From
MRMarco Roeland <marco.roeland@xs4all.nl>
Date
May 28, 2007, 15:46 UTC
Message-ID
<20070528154630.GA9176@fiberbit.xs4all.nl>
In-Reply-To
<87sl9hw0o0.fsf@rho.meyering.net>
On monday May 28th 2007 at 15:14 Jim Meyering wrote:
Show 24 quoted lines
> > I don't know how many people remember all the _stupid_ problems we had
> > exactly because many versions of bash are crap, crap, crap, and people
> > (including you) don't realize that EPIPE is _different_ from other write
> > errors.
> >
> > Just do a google search for
> >
> > 	"broken pipe" bash
> >
> > and not only will you see a lot of complaints, but the #5 entry is a
> > complaint for a git issue that we had tons of problems with. See for
> > example
> >
> > 	http://www.gelato.unsw.edu.au/archives/git/0504/2602.html
> 
> Whether bash should print a diagnostic when it kills a process with
> SIGPIPE is _different_ from whether the writing process should diagnose
> its own write failure arising from a handled SIGPIPE.
> 
> I suspect that git's special treatment of EPIPE was a shoot-the-messenger
> reaction to the work-around (trap '' PIPE) required to avoid diagnostics
> from porcelain being interpreted by what would now be a 2-year-old
> version of bash.  It is time to remove that work-around, because it
> can obscure real errors, and removing it will be largely unnoticed.

Good point. But also notice that when you are stuck with a shell that does complain about SIGPIPE it is _really_ annoying!

On current Debian 'sid' with your patch this does not seem to be the case.

The second chunk of your patch (to git.c) contains a small copy-paste accident methinks:

Show 14 quoted lines
> @@ -321,7 +322,15 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
>  			die("%s must be run in a work tree", cmd);
>  		trace_argv_printf(argv, argc, "trace: built-in: git");
> 
> -		exit(p->fn(argc, argv, prefix));
> +		status = p->fn(argc, argv, prefix);
> +
> +		/* Close stdout if necessary, and diagnose any failure.  */
> +		if (fcntl(fileno (stdout), F_GETFD) >= 0)
> +		    && (ferror(stdout) || fclose(stdout)))
> +			die("write failure on standard output: %s",
> +			    strerror(errno));
> +
> +		exit(status);
The if statement with 'fcntl' is missing a brace, it should be:

+ if ((fcntl(fileno (stdout), F_GETFD) >= 0) + && (ferror(stdout) || fclose(stdout)))

-- 
Marco Roeland
Previous: Jim MeyeringNext: Jim Meyering
Message 8 of 29 in “Don't ignore write failure from git-diff, git-log, etc.”
  1. Don't ignore write failure from git-diff, git-log, etc.Jim Meyering, May 26, 2007
  2. Linus TorvaldsMay 26, 2007
  3. Junio C HamanoMay 26, 2007
  4. Nicolas PitreMay 27, 2007
  5. Jim MeyeringMay 27, 2007
  6. Linus TorvaldsMay 27, 2007
  7. Jim MeyeringMay 28, 2007
  8. Marco RoelandMay 28, 2007
  9. Jim MeyeringMay 28, 2007
  10. Marco RoelandMay 28, 2007
  11. Jim MeyeringMay 28, 2007
  12. Petr BaudisMay 28, 2007
  13. Junio C HamanoMay 28, 2007
  14. Jim MeyeringMay 29, 2007
  15. Junio C HamanoMay 29, 2007
  16. Jim MeyeringMay 30, 2007
  17. Linus TorvaldsMay 28, 2007
  18. Jim MeyeringMay 28, 2007
  19. Linus TorvaldsMay 29, 2007
  20. Jim MeyeringMay 29, 2007
  21. Linus TorvaldsMay 29, 2007
  22. Jim MeyeringMay 30, 2007
  23. Linus TorvaldsMay 30, 2007
  24. Jim MeyeringMay 30, 2007
  25. Junio C HamanoMay 28, 2007
  26. Linus TorvaldsMay 29, 2007
  27. Jim MeyeringMay 30, 2007
  28. Junio C HamanoMay 30, 2007
  29. Jim MeyeringMay 30, 2007

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.