Skip to content

Commit

Permalink
move patch discarding inside try for staged_files_only
Browse files Browse the repository at this point in the history
there's a rare race outlined in #2287
  • Loading branch information
asottile committed Apr 2, 2022
1 parent 7602abc commit a138c85
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pre_commit/staged_files_only.py
Expand Up @@ -66,9 +66,9 @@ def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]:

# prevent recursive post-checkout hooks (#1418)
no_checkout_env = dict(os.environ, _PRE_COMMIT_SKIP_POST_CHECKOUT='1')
cmd_output_b(*_CHECKOUT_CMD, env=no_checkout_env)

try:
cmd_output_b(*_CHECKOUT_CMD, env=no_checkout_env)
yield
finally:
# Try to apply the patch we saved
Expand Down

0 comments on commit a138c85

Please sign in to comment.