]>
Commit | Line | Data |
---|---|---|
30f610b7 SP |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006, Shawn O. Pearce | |
4 | # | |
5 | # Cleanup unreachable files and optimize the repository. | |
6 | ||
81035bba | 7 | USAGE='[--prune]' |
30f610b7 SP |
8 | SUBDIRECTORY_OK=Yes |
9 | . git-sh-setup | |
10 | ||
e3ff4b24 | 11 | no_prune=: |
822f7c73 | 12 | while test $# != 0 |
e3ff4b24 JH |
13 | do |
14 | case "$1" in | |
15 | --prune) | |
16 | no_prune= | |
17 | ;; | |
18 | --) | |
19 | usage | |
20 | ;; | |
21 | esac | |
22 | shift | |
23 | done | |
24 | ||
c2120e5e JS |
25 | case "$(git config --get gc.packrefs)" in |
26 | notbare|"") | |
27 | test $(is_bare_repository) = true || pack_refs=true;; | |
28 | *) | |
29 | pack_refs=$(git config --bool --get gc.packrefs) | |
30 | esac | |
31 | ||
32 | test "true" != "$pack_refs" || | |
5be60078 JH |
33 | git pack-refs --prune && |
34 | git reflog expire --all && | |
a3c11db9 | 35 | git-repack -a -d -l && |
5be60078 JH |
36 | $no_prune git prune && |
37 | git rerere gc || exit |