dotfiles/.local/bin/scripts/git-moves

11 lines
373 B
Plaintext
Raw Normal View History

2022-07-06 06:59:22 +00:00
#!/bin/sh -e
2021-11-11 11:15:41 +00:00
# Stage moved files fitting the already staged ones
2022-07-06 06:59:22 +00:00
set -o pipefail
2021-11-11 11:15:41 +00:00
git diff --name-only --cached >/tmp/staged
2021-11-11 16:31:53 +00:00
root=$(git rev-parse --show-toplevel)
git add "$root"
2021-11-17 14:55:46 +00:00
git status --porcelain --find-renames=.2 |
2021-11-11 16:31:53 +00:00
grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' |
xargs git -C "$root" restore --staged
test "$1" = "-q" || git status --short --find-renames=.2