#!/usr/bin/env python3 import subprocess import sys out = subprocess.check_output(["git", "status", "-zs"]) for line in out.split(b"\0"): line = line.decode("UTF-8") if len(line) >= 2 and line[1] == "M": pathname = line[3:] print(pathname) # XXX stages files... subprocess.run(["git", "update-index", "--refresh", pathname])