]> git.xonotic.org Git - xonotic/div0-gittools.git/blob - git-split-repository
oops, it's index, not work tree, here
[xonotic/div0-gittools.git] / git-split-repository
1 #!/bin/sh
2
3 set -ex
4
5 d="$PWD"
6 src=$1
7 shift
8
9 # expects command line options like
10 #       bspfiles='s,^data/(?=.*(?:\.bsp|/lm_.*\.tga)$),,' \
11 #       a_nonbsp=
12 # i.e. like filter-index, but with reponame= instead of .
13
14 repos=`for x in "$@"; do
15         case "$x" in
16                 delete=*)
17                         ;;
18                 *=*)
19                         echo "${x%%=*}"
20                         ;;
21         esac
22 done | sort -u`
23
24 export filterfile=`mktemp`
25
26 for r in $repos; do
27         rsync -vaSHP --delete "$src" "$r.git/"
28         cd "$r.git"
29         for x in "$@"; do
30                 case "$x" in
31                         *=*)
32                                 rr=${x%%=*}
33                                 f=${x#*=}
34                                 if [ x"$r" = x"$rr" ]; then
35                                         printf -- "+%s\0" "$f"
36                                 else
37                                         printf -- "-%s\0" "$f"
38                                 fi
39                                 ;;
40                 esac
41         done >"$filterfile"
42         git filter-repository "$filterfile"
43         cd "$d"
44 done
45
46 rm -f "$filterfile"