Fix potentially dangerous uses of mkpath and git_path
[git/jnareb-git.git] / contrib / examples / git-gc.sh
blob1597e9f33f5e001995085639a448f1214010b561
1 #!/bin/sh
3 # Copyright (c) 2006, Shawn O. Pearce
5 # Cleanup unreachable files and optimize the repository.
7 USAGE='[--prune]'
8 SUBDIRECTORY_OK=Yes
9 . git-sh-setup
11 no_prune=:
12 while test $# != 0
14 case "$1" in
15 --prune)
16 no_prune=
18 --)
19 usage
21 esac
22 shift
23 done
25 case "$(git config --get gc.packrefs)" in
26 notbare|"")
27 test $(is_bare_repository) = true || pack_refs=true;;
29 pack_refs=$(git config --bool --get gc.packrefs)
30 esac
32 test "true" != "$pack_refs" ||
33 git pack-refs --prune &&
34 git reflog expire --all &&
35 git-repack -a -d -l &&
36 $no_prune git prune &&
37 git rerere gc || exit