prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Windows: Large number of files causes `xargs: ... Bad file number`
  Originally here: https://github.com/pre-commit/pre-commit-hooks/issues/41
  
  
  </issue>
  <code>
  [start of pre_commit/languages/helpers.py]
  1 from __future__ import unicode_literals
  2 
  3 import pipes
  4 
  5 
  6 def file_args_to_stdin(file_args):
  7     return '\0'.join(list(file_args) + [''])
  8 
  9 
  10 def run_hook(env, hook, file_args):
  11     quoted_args = [pipes.quote(arg) for arg in hook['args']]
  12     return env.run(
  13         ' '.join(['xargs', '-0', hook['entry']] + quoted_args),
  14         stdin=file_args_to_stdin(file_args),
  15         retcode=None,
  16     )
  17 
  18 
  19 class Environment(object):
  20     def __init__(self, repo_cmd_runner):
  21         self.repo_cmd_runner = repo_cmd_runner
  22 
  23     @property
  24     def env_prefix(self):
  25         """env_prefix is a value that is prefixed to the command that is run.
  26 
  27         Usually this is to source a virtualenv, etc.
  28 
  29         Commands basically end up looking like:
  30 
  31         bash -c '{env_prefix} {cmd}'
  32 
  33         so you'll often want to end your prefix with &&
  34         """
  35         raise NotImplementedError
  36 
  37     def run(self, cmd, **kwargs):
  38         """Returns (returncode, stdout, stderr)."""
  39         return self.repo_cmd_runner.run(
  40             ['bash', '-c', ' '.join([self.env_prefix, cmd])], **kwargs
  41         )
  42
  [end of pre_commit/languages/helpers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pre_commit/languages/helpers.py b/pre_commit/languages/helpers.py
  --- a/pre_commit/languages/helpers.py
  +++ b/pre_commit/languages/helpers.py
  @@ -10,7 +10,9 @@
   def run_hook(env, hook, file_args):
       quoted_args = [pipes.quote(arg) for arg in hook['args']]
       return env.run(
  -        ' '.join(['xargs', '-0', hook['entry']] + quoted_args),
  +        # Use -s 4000 (slightly less than posix mandated minimum)
  +        # This is to prevent "xargs: ... Bad file number" on windows
  +        ' '.join(['xargs', '-0', '-s4000', hook['entry']] + quoted_args),
           stdin=file_args_to_stdin(file_args),
           retcode=None,
       )
  
verification_info: {"golden_diff": "diff --git a/pre_commit/languages/helpers.py b/pre_commit/languages/helpers.py\n--- a/pre_commit/languages/helpers.py\n+++ b/pre_commit/languages/helpers.py\n@@ -10,7 +10,9 @@\n def run_hook(env, hook, file_args):\n     quoted_args = [pipes.quote(arg) for arg in hook['args']]\n     return env.run(\n-        ' '.join(['xargs', '-0', hook['entry']] + quoted_args),\n+        # Use -s 4000 (slightly less than posix mandated minimum)\n+        # This is to prevent \"xargs: ... Bad file number\" on windows\n+        ' '.join(['xargs', '-0', '-s4000', hook['entry']] + quoted_args),\n         stdin=file_args_to_stdin(file_args),\n         retcode=None,\n     )\n", "issue": "Windows: Large number of files causes `xargs: ... Bad file number`\nOriginally here: https://github.com/pre-commit/pre-commit-hooks/issues/41\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport pipes\n\n\ndef file_args_to_stdin(file_args):\n    return '\\0'.join(list(file_args) + [''])\n\n\ndef run_hook(env, hook, file_args):\n    quoted_args = [pipes.quote(arg) for arg in hook['args']]\n    return env.run(\n        ' '.join(['xargs', '-0', hook['entry']] + quoted_args),\n        stdin=file_args_to_stdin(file_args),\n        retcode=None,\n    )\n\n\nclass Environment(object):\n    def __init__(self, repo_cmd_runner):\n        self.repo_cmd_runner = repo_cmd_runner\n\n    @property\n    def env_prefix(self):\n        \"\"\"env_prefix is a value that is prefixed to the command that is run.\n\n        Usually this is to source a virtualenv, etc.\n\n        Commands basically end up looking like:\n\n        bash -c '{env_prefix} {cmd}'\n\n        so you'll often want to end your prefix with &&\n        \"\"\"\n        raise NotImplementedError\n\n    def run(self, cmd, **kwargs):\n        \"\"\"Returns (returncode, stdout, stderr).\"\"\"\n        return self.repo_cmd_runner.run(\n            ['bash', '-c', ' '.join([self.env_prefix, cmd])], **kwargs\n        )\n", "path": "pre_commit/languages/helpers.py"}]}