3 #==============================================================================
5 # File ID: 8853c3a0-6be6-11df-8fcb-90e6ba3022ac
7 # Store a list of all directories to $dirfile to be able to restore empty
8 # directories. The list is \0-separated in case there are some directory names
9 # containing (ugh) \n. Use git-restore-dirs(1) to recreate directories.
11 # Author: Øyvind A. Holm <sunny@sunbase.org>
12 # License: GNU General Public License version 2 or later.
13 #==============================================================================
15 progname
=git-store-dirs
22 while test -n "$1"; do
24 -h|
--help) opt_help
=1; shift ;;
25 -l|
--local) opt_local
=1; shift ;;
26 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
27 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
28 --version) echo $progname $VERSION; exit 0 ;;
31 if printf '%s\n' "$1" |
grep -q ^
-; then
32 echo "$progname: $1: Unknown option" >&2
40 opt_verbose
=$
(($opt_verbose - $opt_quiet))
44 if test "$opt_help" = "1"; then
45 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
48 Store a list of all directories to $dirfile to be able to restore empty
49 directories. The list is \\0-separated in case there are some directory
50 names containing (ugh) \\n. Use git-restore-dirs(1) to recreate
53 Usage: $progname [options]
60 Create $dirfile in the current subdirectory.
62 Be more quiet. Can be repeated to increase silence.
64 Increase level of verbosity. Can be repeated.
66 Print version information.
72 if test "$opt_local" != "1"; then
74 echo -n "$progname: Has to be run from the toplevel " >&2
75 echo of the working tree
>&2
79 find .
-type d
-empty -print0 |
80 grep -E -v -z '/\.git(/|$)' |
81 LC_ALL
=C
sort -z >$dirfile
82 test "$(cat $dirfile)" = "" &&
86 echo "$0: No empty directories found, deleting $dirfile" >&2
89 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :