2006-12-27 15:17:59 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006, Shawn O. Pearce
|
|
|
|
#
|
|
|
|
# Cleanup unreachable files and optimize the repository.
|
|
|
|
|
2007-03-04 01:28:14 +08:00
|
|
|
USAGE='[--prune]'
|
2006-12-27 15:17:59 +08:00
|
|
|
SUBDIRECTORY_OK=Yes
|
|
|
|
. git-sh-setup
|
|
|
|
|
2007-01-22 15:28:28 +08:00
|
|
|
no_prune=:
|
|
|
|
while case $# in 0) break ;; esac
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--prune)
|
|
|
|
no_prune=
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2007-02-13 21:01:42 +08:00
|
|
|
case "$(git config --get gc.packrefs)" in
|
|
|
|
notbare|"")
|
|
|
|
test $(is_bare_repository) = true || pack_refs=true;;
|
|
|
|
*)
|
|
|
|
pack_refs=$(git config --bool --get gc.packrefs)
|
|
|
|
esac
|
|
|
|
|
|
|
|
test "true" != "$pack_refs" ||
|
2006-12-27 15:17:59 +08:00
|
|
|
git-pack-refs --prune &&
|
|
|
|
git-reflog expire --all &&
|
2006-12-28 06:23:21 +08:00
|
|
|
git-repack -a -d -l &&
|
2007-01-22 15:28:28 +08:00
|
|
|
$no_prune git-prune &&
|
2006-12-27 15:17:59 +08:00
|
|
|
git-rerere gc || exit
|