by patrec · 5y ago · 0 comments
git status -s | awk -vORS="\0" 'gsub(/^ D /,"")' | xargs -0 git checkout --
Which is about the same length. This will still break for malicious input (newlines in filename), but for the original use case that's not a concern.Anyway, I suspect the following is POSIX compliant:
git status -s | awk 'gsub(/^ M /,"")' | tr \\0 \\n | ...I mostly hit things like these with alpine containers and openwrt. OpenWRT I guess could be considered "fringe operating system", but alpine (at least for containers) seems reasonably mainstream?
git status -s | awk 'gsub(/^ D /,"")' | tr \\n \\0 | ...