RelNotes draft for 1.5.3 update.
[git/mingw/4msysgit/wingit-dll.git] / contrib / examples / git-gc.sh
blob2ae235b081ea9829a51758bba5a0d0d64111d32c
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 case $# in 0) break ;; esac
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