now we can specify a commit range for git-obliterate

This commit is contained in:
spacewander 2015-08-01 20:39:02 +08:00
parent 3c5523617e
commit 94bf129721

View file

@ -1,4 +1,23 @@
#!/usr/bin/env bash
file="$1"
file=""
range=""
for i in "$@"
do
# use '--' to seperate file list and rev-list arguments
test "$i" == '--' && shift && break
file="$file"' '"$i"
shift
done
test -n "$*" && range="$*"
test -z "$file" && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached '$file' --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
if [ -z "$range" ]
then
git filter-branch -f --index-filter "git rm -r --cached ""$file"" --ignore-unmatch" \
--prune-empty --tag-name-filter cat -- --all
else
# don't quote $range so that we can forward multiple rev-list arguments
git filter-branch -f --index-filter "git rm -r --cached ""$file"" --ignore-unmatch" \
--prune-empty --tag-name-filter cat -- $range
fi