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

Re: [PATCH 2/2] filter-branch: fail gracefully when a filter fails

From
David Kastrup <dak@gnu.org>
Date
Jul 6, 2007, 08:06 UTC
Message-ID
<863b02j6qs.fsf@lola.quinscape.zz>
In-Reply-To
<468DE9F3.B4489CDE@eudaptics.com>
Johannes Sixt <J.Sixt@eudaptics.com> writes:
Show 15 quoted lines
> Johannes Schindelin wrote:
>> -       sed -e '1,/^$/d' <../commit | \
>> -               eval "$filter_msg" | \
>> -               sh -c "$filter_commit" "git commit-tree" $(git write-tree) \
>> -                       $parentstr > ../map/$commit
>> +       (sed -e '1,/^$/d' <../commit |
>> +               (eval "$filter_msg" ||
>> +                die "msg filter failed: $filter_msg" 2>&3) |
>> +               (sh -c "$filter_commit" "git commit-tree" $(git write-tree) \
>> +                       $parentstr > ../map/$commit ||
>> +                die "commit filter failed: $filter_commit" 2>&3)) 3>&1 |
>> +        grep . && die
>
> You introduce a handful of new forks and an exec. Isn't an intermediate
> file much cheaper?

The number of forks can be reduced by using { ...; } instead of ( ... ) here (though it is possible the shell optimizes them away). grep . should likely redirect its output with >&2 so that it ends up on stderr. I'd probably prefer grep ^ or grep '' since that matches empty lines as well. When done that way, I don't see a "handful of new forks".

Instead of "grep ." one could also do something like
if read line then
  while echo "$line" && read line; do :; done
  die
fi
which is fork-less.
-- 
David Kastrup
Previous: Johannes SixtNext: Junio C Hamano
Message 6 of 10 in “filter-branch: fail gracefully when a filter fails”
  1. 2/2 filter-branch: fail gracefully when a filter failsJohannes Schindelin, Jul 4, 2007
  2. Jeff KingJul 5, 2007
  3. Johannes SchindelinJul 5, 2007
  4. Junio C HamanoJul 5, 2007
  5. Johannes SixtJul 6, 2007
  6. David KastrupJul 6, 2007
  7. Junio C HamanoJul 6, 2007
  8. Jeff KingJul 6, 2007
  9. Josh TriplettJul 6, 2007
  10. Johannes SchindelinJul 6, 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.