3 #==============================================================================
5 # File ID: 40e83476-57e6-11e7-9426-db5caa6d21d3
7 # Delete all files from Git checkout to save space
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
20 while test -n "$1"; do
22 -f|
--force) opt_force
=1; shift ;;
23 -h|
--help) opt_help
=1; shift ;;
24 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
25 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
26 --version) echo $progname $VERSION; exit 0 ;;
29 if printf '%s\n' "$1" |
grep -q ^
-; then
30 echo "$progname: $1: Unknown option" >&2
38 opt_verbose
=$
(($opt_verbose - $opt_quiet))
40 if test "$opt_help" = "1"; then
41 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
44 Delete all versioned files and directories from a Git checkout to save
45 disk space. If any files are modified, it waits until the checkout is
46 clean before continuing. All files can be restored with "git checkout
49 Usage: $progname -f [options]
54 Actually delete the files. This option is mandatory to avoid
55 accidentally deleting the files, even though it's easy to get them
60 Be more quiet. Can be repeated to increase silence.
62 Increase level of verbosity. Can be repeated.
64 Print version information.
70 if test "$opt_force" != "1"; then
71 echo $progname: -f/--force option not specified
, aborting
>&2
75 git wait-until-clean
-u ||
exit 1
76 git ls-files
-z |
xargs -0 --no-run-if-empty rm -f --
77 find .
-depth -type d
-print0 | \
78 grep -azv -e '/\.git/' | \
79 xargs -0 rmdir -- 2>/dev
/null
81 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :