mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-24 17:59:23 -06:00
Fix staged-files-only for git add --intent-to-add files
This commit is contained in:
@@ -97,6 +97,20 @@ def get_staged_files():
|
||||
)[1])
|
||||
|
||||
|
||||
def intent_to_add_files():
|
||||
_, stdout_binary, _ = cmd_output('git', 'status', '--porcelain', '-z')
|
||||
parts = list(reversed(zsplit(stdout_binary)))
|
||||
intent_to_add = []
|
||||
while parts:
|
||||
line = parts.pop()
|
||||
status, filename = line[:3], line[3:]
|
||||
if status[0] in {'C', 'R'}: # renames / moves have an additional arg
|
||||
parts.pop()
|
||||
if status[1] == 'A':
|
||||
intent_to_add.append(filename)
|
||||
return intent_to_add
|
||||
|
||||
|
||||
def get_all_files():
|
||||
return zsplit(cmd_output('git', 'ls-files', '-z')[1])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user