prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  pre-commit -i does not install the file with +x
  No executable = no run :'(
  
  
  </issue>
  <code>
  [start of pre_commit/git.py]
  1 import functools
  2 import os
  3 import os.path
  4 import pkg_resources
  5 import re
  6 from plumbum import local
  7 
  8 from pre_commit.util import memoize_by_cwd
  9 
  10 
  11 def _get_root_new():
  12     path = os.getcwd()
  13     while len(path) > 1:
  14         if os.path.exists(os.path.join(path, '.git')):
  15             return path
  16         else:
  17             path = os.path.normpath(os.path.join(path, '../'))
  18     raise AssertionError('called from outside of the gits')
  19 
  20 
  21 @memoize_by_cwd
  22 def get_root():
  23     return _get_root_new()
  24 
  25 
  26 @memoize_by_cwd
  27 def get_pre_commit_path():
  28     return os.path.join(get_root(), '.git/hooks/pre-commit')
  29 
  30 
  31 def create_pre_commit():
  32     path = get_pre_commit_path()
  33     pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
  34     local.path(path).write(local.path(pre_commit_file).read())
  35 
  36 
  37 def remove_pre_commit():
  38     local.path(get_pre_commit_path()).delete()
  39 
  40 
  41 def get_head_sha(git_repo_path):
  42     with local.cwd(git_repo_path):
  43         return local['git']['rev-parse', 'HEAD']().strip()
  44 
  45 
  46 @memoize_by_cwd
  47 def get_staged_files():
  48     return local['git']['diff', '--staged', '--name-only']().splitlines()
  49 
  50 
  51 @memoize_by_cwd
  52 def get_all_files():
  53     return local['git']['ls-files']().splitlines()
  54 
  55 
  56 def get_files_matching(all_file_list_strategy):
  57     @functools.wraps(all_file_list_strategy)
  58     @memoize_by_cwd
  59     def wrapper(expr):
  60         regex = re.compile(expr)
  61         return set(filter(os.path.exists, (
  62             filename
  63             for filename in all_file_list_strategy()
  64             if regex.search(filename)
  65         )))
  66     return wrapper
  67 
  68 
  69 get_staged_files_matching = get_files_matching(get_staged_files)
  70 get_all_files_matching = get_files_matching(get_all_files)
  71
  [end of pre_commit/git.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/git.py b/pre_commit/git.py
  --- a/pre_commit/git.py
  +++ b/pre_commit/git.py
  @@ -3,6 +3,7 @@
   import os.path
   import pkg_resources
   import re
  +import stat
   from plumbum import local
   
   from pre_commit.util import memoize_by_cwd
  @@ -32,6 +33,8 @@
       path = get_pre_commit_path()
       pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
       local.path(path).write(local.path(pre_commit_file).read())
  +    original_mode = os.stat(path).st_mode
  +    os.chmod(path, original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
   
   
   def remove_pre_commit():
  
verification_info: {"golden_diff": "diff --git a/pre_commit/git.py b/pre_commit/git.py\n--- a/pre_commit/git.py\n+++ b/pre_commit/git.py\n@@ -3,6 +3,7 @@\n import os.path\n import pkg_resources\n import re\n+import stat\n from plumbum import local\n \n from pre_commit.util import memoize_by_cwd\n@@ -32,6 +33,8 @@\n     path = get_pre_commit_path()\n     pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n     local.path(path).write(local.path(pre_commit_file).read())\n+    original_mode = os.stat(path).st_mode\n+    os.chmod(path, original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n \n \n def remove_pre_commit():\n", "issue": "pre-commit -i does not install the file with +x\nNo executable = no run :'(\n\n", "before_files": [{"content": "import functools\nimport os\nimport os.path\nimport pkg_resources\nimport re\nfrom plumbum import local\n\nfrom pre_commit.util import memoize_by_cwd\n\n\ndef _get_root_new():\n    path = os.getcwd()\n    while len(path) > 1:\n        if os.path.exists(os.path.join(path, '.git')):\n            return path\n        else:\n            path = os.path.normpath(os.path.join(path, '../'))\n    raise AssertionError('called from outside of the gits')\n\n\n@memoize_by_cwd\ndef get_root():\n    return _get_root_new()\n\n\n@memoize_by_cwd\ndef get_pre_commit_path():\n    return os.path.join(get_root(), '.git/hooks/pre-commit')\n\n\ndef create_pre_commit():\n    path = get_pre_commit_path()\n    pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n    local.path(path).write(local.path(pre_commit_file).read())\n\n\ndef remove_pre_commit():\n    local.path(get_pre_commit_path()).delete()\n\n\ndef get_head_sha(git_repo_path):\n    with local.cwd(git_repo_path):\n        return local['git']['rev-parse', 'HEAD']().strip()\n\n\n@memoize_by_cwd\ndef get_staged_files():\n    return local['git']['diff', '--staged', '--name-only']().splitlines()\n\n\n@memoize_by_cwd\ndef get_all_files():\n    return local['git']['ls-files']().splitlines()\n\n\ndef get_files_matching(all_file_list_strategy):\n    @functools.wraps(all_file_list_strategy)\n    @memoize_by_cwd\n    def wrapper(expr):\n        regex = re.compile(expr)\n        return set(filter(os.path.exists, (\n            filename\n            for filename in all_file_list_strategy()\n            if regex.search(filename)\n        )))\n    return wrapper\n\n\nget_staged_files_matching = get_files_matching(get_staged_files)\nget_all_files_matching = get_files_matching(get_all_files)\n", "path": "pre_commit/git.py"}]}