]> git.phdru.name Git - git-scripts.git/blob - delete
Feat(submodules/remove): Add option `-c`
[git-scripts.git] / delete
1 #! /bin/sh
2
3 if [ -z "$1" -o -n "$3" ]; then
4     echo "Usage: $0 /path/to/repo" >&2
5     exit 1
6 fi
7
8 start_dir="`pwd`" &&
9 path_to_repo="$1" &&
10 cd "$path_to_repo" &&
11 path_to_repo="`pwd`" &&
12 cd "$start_dir" &&
13
14 cd "`dirname \"$0\"`" &&
15 if ! grep -q "^$path_to_repo\$" locate-all.list; then
16     echo "$path_to_repo" is not a known repository >&2
17     exit 1
18 fi
19
20 rm -rf "$path_to_repo" &&
21
22 tmpfile="`mktemp`" &&
23 grep -v "^$path_to_repo\$" locate-all.list > "$tmpfile" &&
24 if cmp -s mv "$tmpfile" locate-all.list; then
25     exec rm -f "$tmpfile"
26 else
27     exec mv "$tmpfile" locate-all.list
28 fi