File: git-obliterate

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (23 lines) | stat: -rwxr-xr-x 687 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash

file=""
range=""
for i in "$@"
do
    # use '--' to separate 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
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
    # $range is an array 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