Fix staged-files-only for git add --intent-to-add files

This commit is contained in:
Anthony Sottile
2018-12-13 10:08:57 -08:00
parent 2941a1142b
commit e60579d9f3
4 changed files with 71 additions and 5 deletions

View File

@@ -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])