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