Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4bca29e

Browse files
committed
Change intent_to_add_files from using git status to git diff
1 parent 5840635 commit 4bca29e

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

pre_commit/git.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,10 @@ def get_staged_files(cwd: str | None = None) -> list[str]:
150150

151151
def intent_to_add_files() -> list[str]:
152152
_, stdout, _ = cmd_output(
153-
'git', 'status', '--ignore-submodules', '--porcelain', '-z',
153+
'git', 'diff', '--ignore-submodules', '--diff-filter=A',
154+
'--name-only', '-z',
154155
)
155-
parts = list(reversed(zsplit(stdout)))
156-
intent_to_add = []
157-
while parts:
158-
line = parts.pop()
159-
status, filename = line[:3], line[3:]
160-
if status[0] in {'C', 'R'}: # renames / moves have an additional arg
161-
parts.pop()
162-
if status[1] == 'A':
163-
intent_to_add.append(filename)
164-
return intent_to_add
156+
return zsplit(stdout)
165157

166158

167159
def get_all_files() -> list[str]:

0 commit comments

Comments
 (0)